Compare commits
31 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4ffd5dd550 | ||
![]() |
a5712997ef | ||
![]() |
20119880fd | ||
![]() |
1a08e33b83 | ||
![]() |
47f7a5540c | ||
![]() |
2ccc40f89b | ||
![]() |
fa25b703e5 | ||
![]() |
8de367f996 | ||
![]() |
279d116dca | ||
![]() |
23b00904c8 | ||
![]() |
6cd37a4f9b | ||
![]() |
5305348899 | ||
![]() |
6d4e7d14ce | ||
![]() |
677984e961 | ||
![]() |
ca7581cbb0 | ||
![]() |
fc69576978 | ||
![]() |
d24ad72034 | ||
![]() |
a54f0623c5 | ||
![]() |
515df6b21e | ||
![]() |
1fd0a513ff | ||
![]() |
3d0006fe89 | ||
![]() |
15126e0048 | ||
![]() |
cdd9240142 | ||
![]() |
1a42c54981 | ||
![]() |
ccc1be32be | ||
![]() |
5f40d8f061 | ||
![]() |
75c6bae602 | ||
![]() |
ab7eb3874f | ||
![]() |
2636b5e21d | ||
![]() |
d6315a9541 | ||
![]() |
f9ffd1ce6b |
21 changed files with 945 additions and 989 deletions
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: EUnit
|
||||
name: Integration tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
@ -10,22 +10,22 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
name: Test on OTP ${{ matrix.otp_version }} and ${{ matrix.os }}
|
||||
name: OTP ${{ matrix.otp_version }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
container:
|
||||
image: erlang:${{matrix.otp_version}}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
otp_version: ['26.2', '25.3', '25.2', '23.2']
|
||||
otp_version: ['27', '25', '23']
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Compile
|
||||
run: rebar3 compile
|
||||
- name: Dialyze
|
||||
- name: Dialyzer
|
||||
run: rebar3 as test dialyzer
|
||||
- name: EUnit tests
|
||||
- name: EUnit
|
||||
run: TERM=xterm rebar3 eunit
|
||||
|
|
|
@ -4,7 +4,8 @@ Erlware Commons
|
|||
Current Status
|
||||
--------------
|
||||
|
||||

|
||||
[](https://hex.pm/packages/erlware_commons)
|
||||
[](https://github.com/erlware/erlware_commons/actions)
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
IsRebar3 = case application:get_key(rebar, vsn) of
|
||||
{ok, Vsn} ->
|
||||
[MajorVersion|_] = string:tokens(Vsn, "."),
|
||||
(list_to_integer(MajorVersion) >= 3);
|
||||
undefined ->
|
||||
false
|
||||
end,
|
||||
NoDialWarns = {dialyzer, [{warnings, [no_unknown]}]},
|
||||
OTPRelease = erlang:list_to_integer(erlang:system_info(otp_release)),
|
||||
|
||||
Rebar2Deps = [
|
||||
{cf, ".*", {git, "https://github.com/project-fifo/cf", {tag, "0.2.2"}}}
|
||||
],
|
||||
|
||||
NoDialWarns = {dialyzer, [{warnings, [no_unknown]}]},
|
||||
OTPRelease = erlang:list_to_integer(erlang:system_info(otp_release)),
|
||||
WarnsRemoved = case OTPRelease<26 of
|
||||
true -> fun(Config) -> Config end;
|
||||
false -> fun(Config) -> lists:keystore(dialyzer, 1, Config, NoDialWarns) end
|
||||
end,
|
||||
|
||||
case IsRebar3 of
|
||||
true -> WarnsRemoved(CONFIG);
|
||||
false ->
|
||||
lists:keyreplace(deps, 1, WarnsRemoved(CONFIG), {deps, Rebar2Deps})
|
||||
case OTPRelease<26 of
|
||||
true -> CONFIG;
|
||||
false -> lists:keystore(dialyzer, 1, CONFIG, NoDialWarns)
|
||||
end.
|
||||
|
|
|
@ -40,22 +40,17 @@
|
|||
warn/3,
|
||||
log_level/1,
|
||||
atom_log_level/1,
|
||||
colorize/4,
|
||||
format/1]).
|
||||
|
||||
-include("ec_cmd_log.hrl").
|
||||
|
||||
-define(RED, $r).
|
||||
-define(GREEN, $g).
|
||||
-define(YELLOW, $y).
|
||||
-define(BLUE, $b).
|
||||
-define(MAGENTA, $m).
|
||||
-define(CYAN, $c).
|
||||
-include("include/ec_cmd_log.hrl").
|
||||
-include("src/ec_cmd_log.hrl").
|
||||
|
||||
-define(PREFIX, "===> ").
|
||||
|
||||
-record(state_t, {log_level=0 :: int_log_level(),
|
||||
caller=api :: caller(),
|
||||
intensity=low :: none | low | high}).
|
||||
intensity=low :: intensity()}).
|
||||
|
||||
%%============================================================================
|
||||
%% types
|
||||
|
@ -260,44 +255,3 @@ colorize(#state_t{caller=command_line, intensity = low},
|
|||
lists:flatten(cf:format("~!" ++ [Color] ++"~ts~!!~ts", [?PREFIX, Msg]));
|
||||
colorize(_LogState, _Color, _Bold, Msg) ->
|
||||
Msg.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Test Functions
|
||||
%%%===================================================================
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
should_test() ->
|
||||
ErrorLogState = new(error),
|
||||
?assertMatch(true, should(ErrorLogState, ?EC_ERROR)),
|
||||
?assertMatch(true, not should(ErrorLogState, ?EC_INFO)),
|
||||
?assertMatch(true, not should(ErrorLogState, ?EC_DEBUG)),
|
||||
?assertEqual(?EC_ERROR, log_level(ErrorLogState)),
|
||||
?assertEqual(error, atom_log_level(ErrorLogState)),
|
||||
|
||||
InfoLogState = new(info),
|
||||
?assertMatch(true, should(InfoLogState, ?EC_ERROR)),
|
||||
?assertMatch(true, should(InfoLogState, ?EC_INFO)),
|
||||
?assertMatch(true, not should(InfoLogState, ?EC_DEBUG)),
|
||||
?assertEqual(?EC_INFO, log_level(InfoLogState)),
|
||||
?assertEqual(info, atom_log_level(InfoLogState)),
|
||||
|
||||
DebugLogState = new(debug),
|
||||
?assertMatch(true, should(DebugLogState, ?EC_ERROR)),
|
||||
?assertMatch(true, should(DebugLogState, ?EC_INFO)),
|
||||
?assertMatch(true, should(DebugLogState, ?EC_DEBUG)),
|
||||
?assertEqual(?EC_DEBUG, log_level(DebugLogState)),
|
||||
?assertEqual(debug, atom_log_level(DebugLogState)).
|
||||
|
||||
|
||||
no_color_test() ->
|
||||
LogState = new(debug, command_line, none),
|
||||
?assertEqual("test",
|
||||
colorize(LogState, ?RED, true, "test")).
|
||||
|
||||
color_test() ->
|
||||
LogState = new(debug, command_line, high),
|
||||
?assertEqual("\e[1;31m===> test\e[0m",
|
||||
colorize(LogState, ?RED, true, "test")).
|
||||
-endif.
|
||||
|
|
7
src/ec_cmd_log.hrl
Normal file
7
src/ec_cmd_log.hrl
Normal file
|
@ -0,0 +1,7 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-define(RED, $r).
|
||||
-define(GREEN, $g).
|
||||
-define(YELLOW, $y).
|
||||
-define(BLUE, $b).
|
||||
-define(MAGENTA, $m).
|
||||
-define(CYAN, $c).
|
|
@ -212,36 +212,3 @@ to_atom(X)
|
|||
erlang:list_to_existing_atom(X);
|
||||
to_atom(X) ->
|
||||
to_atom(to_list(X)).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Tests
|
||||
%%%===================================================================
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
to_integer_test() ->
|
||||
?assertError(badarg, to_integer(1.5, strict)).
|
||||
|
||||
to_float_test() ->
|
||||
?assertError(badarg, to_float(10, strict)).
|
||||
|
||||
to_atom_test() ->
|
||||
?assertMatch(true, to_atom("true")),
|
||||
?assertMatch(true, to_atom(<<"true">>)),
|
||||
?assertMatch(false, to_atom(<<"false">>)),
|
||||
?assertMatch(false, to_atom(false)),
|
||||
?assertError(badarg, to_atom("hello_foo_bar_baz")),
|
||||
|
||||
S = erlang:list_to_atom("1"),
|
||||
?assertMatch(S, to_atom(1)).
|
||||
|
||||
to_boolean_test()->
|
||||
?assertMatch(true, to_boolean(<<"true">>)),
|
||||
?assertMatch(true, to_boolean("true")),
|
||||
?assertMatch(true, to_boolean(true)),
|
||||
?assertMatch(false, to_boolean(<<"false">>)),
|
||||
?assertMatch(false, to_boolean("false")),
|
||||
?assertMatch(false, to_boolean(false)).
|
||||
|
||||
-endif.
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
-define( is_month(X), ( (is_integer(X) andalso X =< 12) orelse ?is_hinted_month(X) ) ).
|
||||
-define( is_tz_offset(H1,H2,M1,M2), (?is_num(H1) andalso ?is_num(H2) andalso ?is_num(M1) andalso ?is_num(M2)) ).
|
||||
|
||||
-define(GREGORIAN_SECONDS_1970, 62167219200).
|
||||
-define(GREGORIAN_SECONDS_1970, 62_167_219_200).
|
||||
-define(ISO_8601_DATETIME_FORMAT, "Y-m-dTH:i:sZ").
|
||||
-define(ISO_8601_DATETIME_WITH_MS_FORMAT, "Y-m-dTH:i:s.fZ").
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
|||
-type hour() :: 0..23.
|
||||
-type minute() :: 0..59.
|
||||
-type second() :: 0..59.
|
||||
-type microsecond() :: 0..999999.
|
||||
-type microsecond() :: 0..999_999.
|
||||
|
||||
-type daynum() :: 1..7.
|
||||
-type date() :: {year(),month(),day()}.
|
||||
|
@ -138,11 +138,11 @@ nparse(Date) ->
|
|||
{DateS, {H, M, S, Ms} } ->
|
||||
GSeconds = calendar:datetime_to_gregorian_seconds({DateS, {H, M, S} }),
|
||||
ESeconds = GSeconds - ?GREGORIAN_SECONDS_1970,
|
||||
{ESeconds div 1000000, ESeconds rem 1000000, Ms};
|
||||
{ESeconds div 1_000_000, ESeconds rem 1_000_000, Ms};
|
||||
DateTime ->
|
||||
GSeconds = calendar:datetime_to_gregorian_seconds(DateTime),
|
||||
ESeconds = GSeconds - ?GREGORIAN_SECONDS_1970,
|
||||
{ESeconds div 1000000, ESeconds rem 1000000, 0}
|
||||
{ESeconds div 1_000_000, ESeconds rem 1_000_000, 0}
|
||||
end.
|
||||
|
||||
%%
|
||||
|
@ -151,7 +151,7 @@ nparse(Date) ->
|
|||
|
||||
parse([Year, X, Month, X, Day, Hour, $:, Min, $:, Sec, $., Micros, $Z ], _Now, _Opts)
|
||||
when ?is_world_sep(X)
|
||||
andalso (Micros >= 0 andalso Micros < 1000000)
|
||||
andalso (Micros >= 0 andalso Micros < 1_000_000)
|
||||
andalso Year > 31 ->
|
||||
{{Year, Month, Day}, {hour(Hour, []), Min, Sec}, {Micros}};
|
||||
|
||||
|
@ -162,7 +162,7 @@ parse([Year, X, Month, X, Day, Hour, $:, Min, $:, Sec, $Z ], _Now, _Opts)
|
|||
|
||||
parse([Year, X, Month, X, Day, Hour, $:, Min, $:, Sec, $., Micros, $+, Off | _Rest ], _Now, _Opts)
|
||||
when (?is_us_sep(X) orelse ?is_world_sep(X))
|
||||
andalso (Micros >= 0 andalso Micros < 1000000)
|
||||
andalso (Micros >= 0 andalso Micros < 1_000_000)
|
||||
andalso Year > 31 ->
|
||||
{{Year, Month, Day}, {hour(Hour, []) - Off, Min, Sec}, {Micros}};
|
||||
|
||||
|
@ -173,7 +173,7 @@ parse([Year, X, Month, X, Day, Hour, $:, Min, $:, Sec, $+, Off | _Rest ], _Now,
|
|||
|
||||
parse([Year, X, Month, X, Day, Hour, $:, Min, $:, Sec, $., Micros, $-, Off | _Rest ], _Now, _Opts)
|
||||
when (?is_us_sep(X) orelse ?is_world_sep(X))
|
||||
andalso (Micros >= 0 andalso Micros < 1000000)
|
||||
andalso (Micros >= 0 andalso Micros < 1_000_000)
|
||||
andalso Year > 31 ->
|
||||
{{Year, Month, Day}, {hour(Hour, []) + Off, Min, Sec}, {Micros}};
|
||||
|
||||
|
@ -316,11 +316,11 @@ tokenise([$., N1, N2, N3, N4 | Rest], Acc)
|
|||
when ?is_num(N1), ?is_num(N2), ?is_num(N3), ?is_num(N4) ->
|
||||
tokenise(Rest, [ ltoi([N1, N2, N3, N4]) * 100, $. | Acc]);
|
||||
tokenise([$., N1, N2, N3 | Rest], Acc) when ?is_num(N1), ?is_num(N2), ?is_num(N3) ->
|
||||
tokenise(Rest, [ ltoi([N1, N2, N3]) * 1000, $. | Acc]);
|
||||
tokenise(Rest, [ ltoi([N1, N2, N3]) * 1_000, $. | Acc]);
|
||||
tokenise([$., N1, N2 | Rest], Acc) when ?is_num(N1), ?is_num(N2) ->
|
||||
tokenise(Rest, [ ltoi([N1, N2]) * 10000, $. | Acc]);
|
||||
tokenise(Rest, [ ltoi([N1, N2]) * 10_000, $. | Acc]);
|
||||
tokenise([$., N1 | Rest], Acc) when ?is_num(N1) ->
|
||||
tokenise(Rest, [ ltoi([N1]) * 100000, $. | Acc]);
|
||||
tokenise(Rest, [ ltoi([N1]) * 100_000, $. | Acc]);
|
||||
|
||||
tokenise([N1, N2, N3, N4, N5, N6 | Rest], Acc)
|
||||
when ?is_num(N1), ?is_num(N2), ?is_num(N3), ?is_num(N4), ?is_num(N5), ?is_num(N6) ->
|
||||
|
@ -718,7 +718,7 @@ ltoi(X) ->
|
|||
|
||||
|
||||
-define(DATE, {{2001,3,10},{17,16,17}}).
|
||||
-define(DATEMS, {{2001,3,10},{17,16,17,123456}}).
|
||||
-define(DATEMS, {{2001,3,10},{17,16,17,123_456}}).
|
||||
-define(DATE_NOON, {{2001,3,10},{12,0,0}}).
|
||||
-define(DATE_MIDNIGHT, {{2001,3,10},{0,0,0}}).
|
||||
-define(ISO, "o \\WW").
|
||||
|
@ -955,7 +955,7 @@ ms_test_() ->
|
|||
Now=os:timestamp(),
|
||||
[
|
||||
?_assertEqual({{2012,12,12}, {12,12,12,1234}}, parse("2012-12-12T12:12:12.001234")),
|
||||
?_assertEqual({{2012,12,12}, {12,12,12,123000}}, parse("2012-12-12T12:12:12.123")),
|
||||
?_assertEqual({{2012,12,12}, {12,12,12,123_000}}, parse("2012-12-12T12:12:12.123")),
|
||||
?_assertEqual(format("H:m:s.f \\m \\i\\s \\m\\o\\n\\t\\h",?DATEMS),
|
||||
"17:03:17.123456 m is month"),
|
||||
?_assertEqual(format("Y-m-d\\TH:i:s.f",?DATEMS),
|
||||
|
@ -994,21 +994,21 @@ format_iso8601_test_() ->
|
|||
?_assertEqual("2001-03-10T17:16:17.000000Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,0}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.100000Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,100000}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,100_000}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.120000Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,120000}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,120_000}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.123000Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,123000}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,123_000}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.123400Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,123400}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,123_400}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.123450Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,123450}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,123_450}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.123456Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,123456}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,123_456}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.023456Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,23456}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,23_456}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.003456Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,3456}})),
|
||||
format_iso8601({{2001,3,10},{17,16,17,3_456}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.000456Z",
|
||||
format_iso8601({{2001,3,10},{17,16,17,456}})),
|
||||
?_assertEqual("2001-03-10T17:16:17.000056Z",
|
||||
|
@ -1020,21 +1020,21 @@ format_iso8601_test_() ->
|
|||
?_assertEqual("2001-03-10T07:16:17.000000Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,0}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.100000Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,100000}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,100_000}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.120000Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,120000}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,120_000}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.123000Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,123000}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,123_000}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.123400Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,123400}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,123_400}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.123450Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,123450}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,123_450}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.123456Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,123456}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,123_456}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.023456Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,23456}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,23_456}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.003456Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,3456}})),
|
||||
format_iso8601({{2001,3,10},{07,16,17,3_456}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.000456Z",
|
||||
format_iso8601({{2001,3,10},{07,16,17,456}})),
|
||||
?_assertEqual("2001-03-10T07:16:17.000056Z",
|
||||
|
@ -1051,31 +1051,31 @@ parse_iso8601_test_() ->
|
|||
parse("2001-03-10T17:16:17.000Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,0}},
|
||||
parse("2001-03-10T17:16:17.000000Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,100000}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,100_000}},
|
||||
parse("2001-03-10T17:16:17.1Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,120000}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,120_000}},
|
||||
parse("2001-03-10T17:16:17.12Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123000}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123_000}},
|
||||
parse("2001-03-10T17:16:17.123Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123400}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123_400}},
|
||||
parse("2001-03-10T17:16:17.1234Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123450}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123_450}},
|
||||
parse("2001-03-10T17:16:17.12345Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123456}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123_456}},
|
||||
parse("2001-03-10T17:16:17.123456Z")),
|
||||
|
||||
?_assertEqual({{2001,3,10},{15,16,17,100000}},
|
||||
?_assertEqual({{2001,3,10},{15,16,17,100_000}},
|
||||
parse("2001-03-10T16:16:17.1+01:00")),
|
||||
?_assertEqual({{2001,3,10},{15,16,17,123456}},
|
||||
?_assertEqual({{2001,3,10},{15,16,17,123_456}},
|
||||
parse("2001-03-10T16:16:17.123456+01:00")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,100000}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,100_000}},
|
||||
parse("2001-03-10T16:16:17.1-01:00")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123456}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123_456}},
|
||||
parse("2001-03-10T16:16:17.123456-01:00")),
|
||||
|
||||
?_assertEqual({{2001,3,10},{17,16,17,456}},
|
||||
parse("2001-03-10T17:16:17.000456Z")),
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123000}},
|
||||
?_assertEqual({{2001,3,10},{17,16,17,123_000}},
|
||||
parse("2001-03-10T17:16:17.123000Z"))
|
||||
].
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ real_dir_path(Path) ->
|
|||
%% function of the same name.
|
||||
-spec insecure_mkdtemp() -> TmpDirPath::file:name() | {error, term()}.
|
||||
insecure_mkdtemp() ->
|
||||
UniqueNumber = erlang:integer_to_list(erlang:trunc(random_uniform() * 1000000000000)),
|
||||
UniqueNumber = erlang:integer_to_list(erlang:trunc(rand:uniform() * 1_000_000_000_000)),
|
||||
TmpDirPath =
|
||||
filename:join([tmp(), lists:flatten([".tmp_dir", UniqueNumber])]),
|
||||
|
||||
|
@ -375,95 +375,3 @@ hex0(I) -> $0 + I.
|
|||
sub_files(From) ->
|
||||
{ok, SubFiles} = file:list_dir(From),
|
||||
[filename:join(From, SubFile) || SubFile <- SubFiles].
|
||||
|
||||
random_uniform() ->
|
||||
rand:uniform().
|
||||
|
||||
%%%===================================================================
|
||||
%%% Test Functions
|
||||
%%%===================================================================
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
setup_test() ->
|
||||
Dir = insecure_mkdtemp(),
|
||||
mkdir_path(Dir),
|
||||
?assertMatch(false, is_symlink(Dir)),
|
||||
?assertMatch(true, filelib:is_dir(Dir)).
|
||||
|
||||
md5sum_test() ->
|
||||
?assertMatch("cfcd208495d565ef66e7dff9f98764da", md5sum("0")).
|
||||
|
||||
sha1sum_test() ->
|
||||
?assertMatch("b6589fc6ab0dc82cf12099d1c2d40ab994e8410c", sha1sum("0")).
|
||||
|
||||
file_test() ->
|
||||
Dir = insecure_mkdtemp(),
|
||||
TermFile = filename:join(Dir, "ec_file/dir/file.term"),
|
||||
TermFileCopy = filename:join(Dir, "ec_file/dircopy/file.term"),
|
||||
filelib:ensure_dir(TermFile),
|
||||
filelib:ensure_dir(TermFileCopy),
|
||||
write_term(TermFile, "term"),
|
||||
?assertMatch({ok, <<"\"term\". ">>}, read(TermFile)),
|
||||
copy(filename:dirname(TermFile),
|
||||
filename:dirname(TermFileCopy),
|
||||
[recursive]).
|
||||
|
||||
teardown_test() ->
|
||||
Dir = insecure_mkdtemp(),
|
||||
remove(Dir, [recursive]),
|
||||
?assertMatch(false, filelib:is_dir(Dir)).
|
||||
|
||||
setup_base_and_target() ->
|
||||
BaseDir = insecure_mkdtemp(),
|
||||
DummyContents = <<"This should be deleted">>,
|
||||
SourceDir = filename:join([BaseDir, "source"]),
|
||||
ok = file:make_dir(SourceDir),
|
||||
Name1 = filename:join([SourceDir, "fileone"]),
|
||||
Name2 = filename:join([SourceDir, "filetwo"]),
|
||||
Name3 = filename:join([SourceDir, "filethree"]),
|
||||
NoName = filename:join([SourceDir, "noname"]),
|
||||
|
||||
ok = file:write_file(Name1, DummyContents),
|
||||
ok = file:write_file(Name2, DummyContents),
|
||||
ok = file:write_file(Name3, DummyContents),
|
||||
ok = file:write_file(NoName, DummyContents),
|
||||
{BaseDir, SourceDir, {Name1, Name2, Name3, NoName}}.
|
||||
|
||||
exists_test() ->
|
||||
BaseDir = insecure_mkdtemp(),
|
||||
SourceDir = filename:join([BaseDir, "source1"]),
|
||||
NoName = filename:join([SourceDir, "noname"]),
|
||||
ok = file:make_dir(SourceDir),
|
||||
Name1 = filename:join([SourceDir, "fileone"]),
|
||||
ok = file:write_file(Name1, <<"Testn">>),
|
||||
?assertMatch(true, exists(Name1)),
|
||||
?assertMatch(false, exists(NoName)).
|
||||
|
||||
real_path_test() ->
|
||||
BaseDir = "foo",
|
||||
Dir = filename:absname(filename:join(BaseDir, "source1")),
|
||||
LinkDir = filename:join([BaseDir, "link"]),
|
||||
ok = mkdir_p(Dir),
|
||||
file:make_symlink(Dir, LinkDir),
|
||||
?assertEqual(Dir, real_dir_path(LinkDir)),
|
||||
?assertEqual(directory, type(Dir)),
|
||||
?assertEqual(symlink, type(LinkDir)),
|
||||
TermFile = filename:join(BaseDir, "test_file"),
|
||||
ok = write_term(TermFile, foo),
|
||||
?assertEqual(file, type(TermFile)),
|
||||
?assertEqual(true, is_symlink(LinkDir)),
|
||||
?assertEqual(false, is_symlink(Dir)).
|
||||
|
||||
find_test() ->
|
||||
%% Create a directory in /tmp for the test. Clean everything afterwards
|
||||
{BaseDir, _SourceDir, {Name1, Name2, Name3, _NoName}} = setup_base_and_target(),
|
||||
Result = find(BaseDir, "file[a-z]+\$"),
|
||||
?assertMatch(3, erlang:length(Result)),
|
||||
?assertEqual(true, lists:member(Name1, Result)),
|
||||
?assertEqual(true, lists:member(Name2, Result)),
|
||||
?assertEqual(true, lists:member(Name3, Result)),
|
||||
remove(BaseDir, [recursive]).
|
||||
|
||||
-endif.
|
||||
|
|
|
@ -135,79 +135,3 @@ from_list(List) when is_list(List) ->
|
|||
-spec keys(gb_trees:tree(K,_V)) -> [ec_dictionary:key(K)].
|
||||
keys(Data) ->
|
||||
gb_trees:keys(Data).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Tests
|
||||
%%%===================================================================
|
||||
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
%% For me unit testing initially is about covering the obvious case. A
|
||||
%% check to make sure that what you expect the tested functionality to
|
||||
%% do, it actually does. As time goes on and people detect bugs you
|
||||
%% add tests for those specific problems to the unit test suit.
|
||||
%%
|
||||
%% However, when getting started you can only test your basic
|
||||
%% expectations. So here are the expectations I have for the add
|
||||
%% functionality.
|
||||
%%
|
||||
%% 1) I can put arbitrary terms into the dictionary as keys
|
||||
%% 2) I can put arbitrary terms into the dictionary as values
|
||||
%% 3) When I put a value in the dictionary by a key, I can retrieve
|
||||
%% that same value
|
||||
%% 4) When I put a different value in the dictionary by key it does
|
||||
%% not change other key value pairs.
|
||||
%% 5) When I update a value the new value in available by the new key
|
||||
%% 6) When a value does not exist a not found exception is created
|
||||
|
||||
add_test() ->
|
||||
Dict0 = ec_dictionary:new(ec_gb_trees),
|
||||
|
||||
Key1 = foo,
|
||||
Key2 = [1, 3],
|
||||
Key3 = {"super"},
|
||||
Key4 = <<"fabulous">>,
|
||||
Key5 = {"Sona", 2, <<"Zuper">>},
|
||||
|
||||
Value1 = Key5,
|
||||
Value2 = Key4,
|
||||
Value3 = Key2,
|
||||
Value4 = Key3,
|
||||
Value5 = Key1,
|
||||
|
||||
Dict01 = ec_dictionary:add(Key1, Value1, Dict0),
|
||||
Dict02 = ec_dictionary:add(Key3, Value3,
|
||||
ec_dictionary:add(Key2, Value2,
|
||||
Dict01)),
|
||||
Dict1 =
|
||||
ec_dictionary:add(Key5, Value5,
|
||||
ec_dictionary:add(Key4, Value4,
|
||||
Dict02)),
|
||||
|
||||
?assertMatch(Value1, ec_dictionary:get(Key1, Dict1)),
|
||||
?assertMatch(Value2, ec_dictionary:get(Key2, Dict1)),
|
||||
?assertMatch(Value3, ec_dictionary:get(Key3, Dict1)),
|
||||
?assertMatch(Value4, ec_dictionary:get(Key4, Dict1)),
|
||||
?assertMatch(Value5, ec_dictionary:get(Key5, Dict1)),
|
||||
|
||||
|
||||
Dict2 = ec_dictionary:add(Key3, Value5,
|
||||
ec_dictionary:add(Key2, Value4, Dict1)),
|
||||
|
||||
|
||||
?assertMatch(Value1, ec_dictionary:get(Key1, Dict2)),
|
||||
?assertMatch(Value4, ec_dictionary:get(Key2, Dict2)),
|
||||
?assertMatch(Value5, ec_dictionary:get(Key3, Dict2)),
|
||||
?assertMatch(Value4, ec_dictionary:get(Key4, Dict2)),
|
||||
?assertMatch(Value5, ec_dictionary:get(Key5, Dict2)),
|
||||
|
||||
|
||||
?assertThrow(not_found, ec_dictionary:get(should_blow_up, Dict2)),
|
||||
?assertThrow(not_found, ec_dictionary:get("This should blow up too",
|
||||
Dict2)).
|
||||
|
||||
|
||||
|
||||
-endif.
|
||||
|
|
|
@ -17,6 +17,13 @@
|
|||
-export([new/0,
|
||||
vsn/1]).
|
||||
|
||||
-ifdef(TEST).
|
||||
-export([parse_tags/1,
|
||||
get_patch_count/1,
|
||||
collect_default_refcount/1
|
||||
]).
|
||||
-endif.
|
||||
|
||||
-export_type([t/0]).
|
||||
|
||||
%%%===================================================================
|
||||
|
@ -98,16 +105,3 @@ parse_tags(Pattern) ->
|
|||
Vsn1 = string:trim(string:trim(Vsn, leading, "v"), trailing, "\n"),
|
||||
{Tag, Vsn1}
|
||||
end.
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
parse_tags_test() ->
|
||||
?assertEqual({undefined, ""}, parse_tags("a.b.c")).
|
||||
|
||||
get_patch_count_test() ->
|
||||
?assertEqual(0, get_patch_count("a.b.c")).
|
||||
|
||||
collect_default_refcount_test() ->
|
||||
?assertMatch({"", _, _}, collect_default_refcount("a.b.c")).
|
||||
-endif.
|
||||
|
|
181
src/ec_lists.erl
181
src/ec_lists.erl
|
@ -63,184 +63,3 @@ fetch(Fun, List) when is_list(List), is_function(Fun) ->
|
|||
error ->
|
||||
throw(not_found)
|
||||
end.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Test Functions
|
||||
%%%===================================================================
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
find1_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = find(fun(5) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 5}, Result),
|
||||
|
||||
Result2 = find(fun(37) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(error, Result2).
|
||||
|
||||
find2_test() ->
|
||||
TestData = ["one", "two", "three", "four", "five", "six"],
|
||||
Result = find(fun("five") ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, "five"}, Result),
|
||||
|
||||
Result2 = find(fun(super_duper) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(error, Result2).
|
||||
|
||||
|
||||
|
||||
find3_test() ->
|
||||
TestData = [{"one", 1}, {"two", 2}, {"three", 3}, {"four", 5}, {"five", 5},
|
||||
{"six", 6}],
|
||||
Result = find(fun({"one", 1}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, {"one", 1}}, Result),
|
||||
|
||||
Result2 = find(fun([fo, bar, baz]) ->
|
||||
true;
|
||||
({"onehundred", 100}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(error, Result2).
|
||||
|
||||
|
||||
|
||||
fetch1_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = fetch(fun(5) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(5, Result),
|
||||
|
||||
?assertThrow(not_found,
|
||||
fetch(fun(37) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData)).
|
||||
|
||||
fetch2_test() ->
|
||||
TestData = ["one", "two", "three", "four", "five", "six"],
|
||||
Result = fetch(fun("five") ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch("five", Result),
|
||||
|
||||
?assertThrow(not_found,
|
||||
fetch(fun(super_duper) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData)).
|
||||
|
||||
fetch3_test() ->
|
||||
TestData = [{"one", 1}, {"two", 2}, {"three", 3}, {"four", 5}, {"five", 5},
|
||||
{"six", 6}],
|
||||
Result = fetch(fun({"one", 1}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({"one", 1}, Result),
|
||||
|
||||
?assertThrow(not_found,
|
||||
fetch(fun([fo, bar, baz]) ->
|
||||
true;
|
||||
({"onehundred", 100}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData)).
|
||||
|
||||
search1_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = search(fun(5) ->
|
||||
{ok, 5};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 5, 5}, Result),
|
||||
|
||||
Result2 = search(fun(37) ->
|
||||
{ok, 37};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(not_found, Result2).
|
||||
|
||||
search2_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = search(fun(1) ->
|
||||
{ok, 10};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 10, 1}, Result),
|
||||
|
||||
Result2 = search(fun(6) ->
|
||||
{ok, 37};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 37, 6}, Result2).
|
||||
|
||||
search3_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = search(fun(10) ->
|
||||
{ok, 10};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(not_found, Result),
|
||||
|
||||
Result2 = search(fun(-1) ->
|
||||
{ok, 37};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(not_found, Result2).
|
||||
|
||||
-endif.
|
||||
|
|
|
@ -309,455 +309,3 @@ internal_pes(VsnA, {{LM, LMI, LP, LMP}, Alpha})
|
|||
lt(VsnA, {{LM, LMI, LP + 1, 0}, {[], []}});
|
||||
internal_pes(Vsn, LVsn) ->
|
||||
gte(Vsn, LVsn).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Test Functions
|
||||
%%%===================================================================
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
eql_test() ->
|
||||
?assertMatch(true, eql("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, eql("v1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, eql("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, eql("v1",
|
||||
"v1.0.0")),
|
||||
?assertMatch(true, eql("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, eql("1.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, eql("1.0.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, eql("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, eql("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, eql("1.0-alpha.1+build.1",
|
||||
"1.0.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, eql("1.0-alpha.1+build.1",
|
||||
"v1.0.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, eql("1.0-pre-alpha.1",
|
||||
"1.0.0-pre-alpha.1")),
|
||||
?assertMatch(true, eql("aa", "aa")),
|
||||
?assertMatch(true, eql("AA.BB", "AA.BB")),
|
||||
?assertMatch(true, eql("BBB-super", "BBB-super")),
|
||||
?assertMatch(true, not eql("1.0.0",
|
||||
"1.0.1")),
|
||||
?assertMatch(true, not eql("1.0.0-alpha",
|
||||
"1.0.1+alpha")),
|
||||
?assertMatch(true, not eql("1.0.0+build.1",
|
||||
"1.0.1+build.2")),
|
||||
?assertMatch(true, not eql("1.0.0.0+build.1",
|
||||
"1.0.0.1+build.2")),
|
||||
?assertMatch(true, not eql("FFF", "BBB")),
|
||||
?assertMatch(true, not eql("1", "1BBBB")).
|
||||
|
||||
gt_test() ->
|
||||
?assertMatch(true, gt("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, gt("1.0.0.1-alpha.1",
|
||||
"1.0.0.1-alpha")),
|
||||
?assertMatch(true, gt("1.0.0.4-alpha.1",
|
||||
"1.0.0.2-alpha")),
|
||||
?assertMatch(true, gt("1.0.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, gt("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, gt("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, gt("1.0.0-pre-alpha.14",
|
||||
"1.0.0-pre-alpha.3")),
|
||||
?assertMatch(true, gt("1.0.0-beta.11",
|
||||
"1.0.0.0-beta.2")),
|
||||
?assertMatch(true, gt("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, gt("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, gt("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, gt("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, gt("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, gt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, gt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7.0+build")),
|
||||
?assertMatch(true, gt("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, gt("aa.cc",
|
||||
"aa.bb")),
|
||||
?assertMatch(true, not gt("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not gt("1.0.0-alpha",
|
||||
"1.0.0.0-alpha.1")),
|
||||
?assertMatch(true, not gt("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not gt("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, not gt("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, not gt("1.0.0-pre-alpha.3",
|
||||
"1.0.0-pre-alpha.14")),
|
||||
?assertMatch(true, not gt("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not gt("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not gt("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, not gt("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not gt("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, not gt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")),
|
||||
?assertMatch(true, not gt("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not gt("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not gt("aa.bb",
|
||||
"aa.bb")),
|
||||
?assertMatch(true, not gt("aa.cc",
|
||||
"aa.dd")),
|
||||
?assertMatch(true, not gt("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not gt("1.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, not gt("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, not gt("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")).
|
||||
|
||||
lt_test() ->
|
||||
?assertMatch(true, lt("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, lt("1.0.0-alpha",
|
||||
"1.0.0.0-alpha.1")),
|
||||
?assertMatch(true, lt("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, lt("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, lt("1.0.0-pre-alpha.3",
|
||||
"1.0.0-pre-alpha.14")),
|
||||
?assertMatch(true, lt("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, lt("1.0.0.1-beta.11",
|
||||
"1.0.0.1-rc.1")),
|
||||
?assertMatch(true, lt("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, lt("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, lt("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, lt("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, lt("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, lt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")),
|
||||
?assertMatch(true, not lt("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not lt("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, lt("1",
|
||||
"1.0.0.1")),
|
||||
?assertMatch(true, lt("AA.DD",
|
||||
"AA.EE")),
|
||||
?assertMatch(true, not lt("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not lt("1.0.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, not lt("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, not lt("AA.DD", "AA.CC")),
|
||||
?assertMatch(true, not lt("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, not lt("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not lt("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not lt("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not lt("1.0.0-pre-alpha.14",
|
||||
"1.0.0-pre-alpha.3")),
|
||||
?assertMatch(true, not lt("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, not lt("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, not lt("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not lt("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, not lt("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, not lt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not lt("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")).
|
||||
|
||||
gte_test() ->
|
||||
?assertMatch(true, gte("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
|
||||
?assertMatch(true, gte("1",
|
||||
"1.0.0")),
|
||||
|
||||
?assertMatch(true, gte("1.0",
|
||||
"1.0.0")),
|
||||
|
||||
?assertMatch(true, gte("1.0.0",
|
||||
"1")),
|
||||
|
||||
?assertMatch(true, gte("1.0.0.0",
|
||||
"1")),
|
||||
|
||||
?assertMatch(true, gte("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
|
||||
?assertMatch(true, gte("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
|
||||
?assertMatch(true, gte("1.0.0-alpha.1+build.1",
|
||||
"1.0.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, gte("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, gte("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha")),
|
||||
?assertMatch(true, gte("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, gte("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, gte("aa.bb", "aa.bb")),
|
||||
?assertMatch(true, gte("dd", "aa")),
|
||||
?assertMatch(true, gte("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, gte("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, gte("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, gte("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, gte("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, gte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, gte("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, not gte("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not gte("1.0.0-pre-alpha",
|
||||
"1.0.0-pre-alpha.1")),
|
||||
?assertMatch(true, not gte("CC", "DD")),
|
||||
?assertMatch(true, not gte("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not gte("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, not gte("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, not gte("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not gte("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not gte("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, not gte("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not gte("1.0.0",
|
||||
"1.0.0+build.1")),
|
||||
?assertMatch(true, not gte("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, not gte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")).
|
||||
lte_test() ->
|
||||
?assertMatch(true, lte("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, lte("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, lte("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, lte("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha.11")),
|
||||
?assertMatch(true, lte("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, lte("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, lte("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, lte("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, lte("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, lte("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, lte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")),
|
||||
?assertMatch(true, lte("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, lte("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, lte("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, lte("1.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, lte("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, lte("1.0.0.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, lte("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, lte("aa","cc")),
|
||||
?assertMatch(true, lte("cc","cc")),
|
||||
?assertMatch(true, not lte("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not lte("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha")),
|
||||
?assertMatch(true, not lte("cc", "aa")),
|
||||
?assertMatch(true, not lte("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not lte("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not lte("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, not lte("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, not lte("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not lte("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, not lte("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, not lte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not lte("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")).
|
||||
|
||||
between_test() ->
|
||||
?assertMatch(true, between("1.0.0-alpha",
|
||||
"1.0.0-alpha.3",
|
||||
"1.0.0-alpha.2")),
|
||||
?assertMatch(true, between("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2",
|
||||
"1.0.0-alpha.25")),
|
||||
?assertMatch(true, between("1.0.0-beta.2",
|
||||
"1.0.0-beta.11",
|
||||
"1.0.0-beta.7")),
|
||||
?assertMatch(true, between("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha.11",
|
||||
"1.0.0-pre-alpha.7")),
|
||||
?assertMatch(true, between("1.0.0-beta.11",
|
||||
"1.0.0-rc.3",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, between("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.3",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
|
||||
?assertMatch(true, between("1.0.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.3",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, between("1.0.0-rc.1+build.1",
|
||||
"1.0.0",
|
||||
"1.0.0-rc.33")),
|
||||
?assertMatch(true, between("1.0.0",
|
||||
"1.0.0+0.3.7",
|
||||
"1.0.0+0.2")),
|
||||
?assertMatch(true, between("1.0.0+0.3.7",
|
||||
"1.3.7+build",
|
||||
"1.2")),
|
||||
?assertMatch(true, between("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.1")),
|
||||
?assertMatch(true, between("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.10.a36faa")),
|
||||
?assertMatch(true, between("1.0.0-alpha",
|
||||
"1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, between("1",
|
||||
"1.0.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, between("1.0",
|
||||
"1.0.0",
|
||||
"1.0.0")),
|
||||
|
||||
?assertMatch(true, between("1.0",
|
||||
"1.0.0.0",
|
||||
"1.0.0.0")),
|
||||
?assertMatch(true, between("1.0.0",
|
||||
"1",
|
||||
"1")),
|
||||
?assertMatch(true, between("1.0+alpha.1",
|
||||
"1.0.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, between("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, between("aaa",
|
||||
"ddd",
|
||||
"cc")),
|
||||
?assertMatch(true, not between("1.0.0-alpha.1",
|
||||
"1.0.0-alpha.22",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not between("1.0.0-pre-alpha.1",
|
||||
"1.0.0-pre-alpha.22",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not between("1.0.0",
|
||||
"1.0.0-alpha.1",
|
||||
"2.0")),
|
||||
?assertMatch(true, not between("1.0.0-beta.1",
|
||||
"1.0.0-beta.11",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not between("1.0.0-beta.11", "1.0.0-rc.1",
|
||||
"1.0.0-rc.22")),
|
||||
?assertMatch(true, not between("aaa", "ddd", "zzz")).
|
||||
|
||||
pes_test() ->
|
||||
?assertMatch(true, pes("1.0.0-rc.0", "1.0.0-rc.0")),
|
||||
?assertMatch(true, pes("1.0.0-rc.1", "1.0.0-rc.0")),
|
||||
?assertMatch(true, pes("1.0.0", "1.0.0-rc.0")),
|
||||
?assertMatch(false, pes("1.0.0-rc.0", "1.0.0-rc.1")),
|
||||
?assertMatch(true, pes("2.6.0", "2.6")),
|
||||
?assertMatch(true, pes("2.7", "2.6")),
|
||||
?assertMatch(true, pes("2.8", "2.6")),
|
||||
?assertMatch(true, pes("2.9", "2.6")),
|
||||
?assertMatch(true, pes("A.B", "A.A")),
|
||||
?assertMatch(true, not pes("3.0.0", "2.6")),
|
||||
?assertMatch(true, not pes("2.5", "2.6")),
|
||||
?assertMatch(true, pes("2.6.5", "2.6.5")),
|
||||
?assertMatch(true, pes("2.6.6", "2.6.5")),
|
||||
?assertMatch(true, pes("2.6.7", "2.6.5")),
|
||||
?assertMatch(true, pes("2.6.8", "2.6.5")),
|
||||
?assertMatch(true, pes("2.6.9", "2.6.5")),
|
||||
?assertMatch(true, pes("2.6.0.9", "2.6.0.5")),
|
||||
?assertMatch(true, not pes("2.7", "2.6.5")),
|
||||
?assertMatch(true, not pes("2.1.7", "2.1.6.5")),
|
||||
?assertMatch(true, not pes("A.A", "A.B")),
|
||||
?assertMatch(true, not pes("2.5", "2.6.5")).
|
||||
|
||||
parse_test() ->
|
||||
?assertEqual({1, {[],[]}}, parse(<<"1">>)),
|
||||
?assertEqual({{1,2,34},{[],[]}}, parse(<<"1.2.34">>)),
|
||||
?assertEqual({<<"a">>, {[],[]}}, parse(<<"a">>)),
|
||||
?assertEqual({{<<"a">>,<<"b">>}, {[],[]}}, parse(<<"a.b">>)),
|
||||
?assertEqual({1, {[],[]}}, parse(<<"1">>)),
|
||||
?assertEqual({{1,2}, {[],[]}}, parse(<<"1.2">>)),
|
||||
?assertEqual({{1,2,2}, {[],[]}}, parse(<<"1.2.2">>)),
|
||||
?assertEqual({{1,99,2}, {[],[]}}, parse(<<"1.99.2">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"alpha">>],[]}}, parse(<<"1.99.2-alpha">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"alpha">>,1], []}}, parse(<<"1.99.2-alpha.1">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"pre-alpha">>,1], []}}, parse(<<"1.99.2-pre-alpha.1">>)),
|
||||
?assertEqual({{1,99,2}, {[], [<<"build">>, 1, <<"a36">>]}},
|
||||
parse(<<"1.99.2+build.1.a36">>)),
|
||||
?assertEqual({{1,99,2,44}, {[], [<<"build">>, 1, <<"a36">>]}},
|
||||
parse(<<"1.99.2.44+build.1.a36">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"alpha">>, 1], [<<"build">>, 1, <<"a36">>]}},
|
||||
parse("1.99.2-alpha.1+build.1.a36")),
|
||||
?assertEqual({{1,99,2}, {[<<"pre-alpha">>, 1], [<<"build">>, 1, <<"a36">>]}},
|
||||
parse("1.99.2-pre-alpha.1+build.1.a36")).
|
||||
|
||||
version_format_test() ->
|
||||
?assertEqual(["1", [], []], format({1, {[],[]}})),
|
||||
?assertEqual(["1", ".", "2", ".", "34", [], []], format({{1,2,34},{[],[]}})),
|
||||
?assertEqual(<<"a">>, erlang:iolist_to_binary(format({<<"a">>, {[],[]}}))),
|
||||
?assertEqual(<<"a.b">>, erlang:iolist_to_binary(format({{<<"a">>,<<"b">>}, {[],[]}}))),
|
||||
?assertEqual(<<"1">>, erlang:iolist_to_binary(format({1, {[],[]}}))),
|
||||
?assertEqual(<<"1.2">>, erlang:iolist_to_binary(format({{1,2}, {[],[]}}))),
|
||||
?assertEqual(<<"1.2.2">>, erlang:iolist_to_binary(format({{1,2,2}, {[],[]}}))),
|
||||
?assertEqual(<<"1.99.2">>, erlang:iolist_to_binary(format({{1,99,2}, {[],[]}}))),
|
||||
?assertEqual(<<"1.99.2-alpha">>, erlang:iolist_to_binary(format({{1,99,2}, {[<<"alpha">>],[]}}))),
|
||||
?assertEqual(<<"1.99.2-alpha.1">>, erlang:iolist_to_binary(format({{1,99,2}, {[<<"alpha">>,1], []}}))),
|
||||
?assertEqual(<<"1.99.2-pre-alpha.1">>, erlang:iolist_to_binary(format({{1,99,2}, {[<<"pre-alpha">>,1], []}}))),
|
||||
?assertEqual(<<"1.99.2+build.1.a36">>,
|
||||
erlang:iolist_to_binary(format({{1,99,2}, {[], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1.99.2.44+build.1.a36">>,
|
||||
erlang:iolist_to_binary(format({{1,99,2,44}, {[], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1.99.2-alpha.1+build.1.a36">>,
|
||||
erlang:iolist_to_binary(format({{1,99,2}, {[<<"alpha">>, 1], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1.99.2-pre-alpha.1+build.1.a36">>,
|
||||
erlang:iolist_to_binary(format({{1,99,2}, {[<<"pre-alpha">>, 1], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1">>, erlang:iolist_to_binary(format({1, {[],[]}}))).
|
||||
|
||||
-endif.
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
say/1,
|
||||
say/2]).
|
||||
|
||||
-ifdef(TEST).
|
||||
-export([get_boolean/1,
|
||||
get_integer/1]).
|
||||
-endif.
|
||||
|
||||
-export_type([prompt/0,
|
||||
type/0,
|
||||
supported/0]).
|
||||
|
@ -196,26 +201,3 @@ get_string(String) ->
|
|||
false ->
|
||||
no_clue
|
||||
end.
|
||||
|
||||
%%%====================================================================
|
||||
%%% tests
|
||||
%%%====================================================================
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
general_test_() ->
|
||||
[?_test(42 == get_integer("42")),
|
||||
?_test(500211 == get_integer("500211")),
|
||||
?_test(1234567890 == get_integer("1234567890")),
|
||||
?_test(12345678901234567890 == get_integer("12345678901234567890")),
|
||||
?_test(true == get_boolean("true")),
|
||||
?_test(false == get_boolean("false")),
|
||||
?_test(true == get_boolean("Ok")),
|
||||
?_test(true == get_boolean("ok")),
|
||||
?_test(true == get_boolean("Y")),
|
||||
?_test(true == get_boolean("y")),
|
||||
?_test(false == get_boolean("False")),
|
||||
?_test(false == get_boolean("No")),
|
||||
?_test(false == get_boolean("no"))].
|
||||
|
||||
-endif.
|
||||
|
|
39
test/ec_cmd_log_tests.erl
Normal file
39
test/ec_cmd_log_tests.erl
Normal file
|
@ -0,0 +1,39 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_cmd_log_tests).
|
||||
|
||||
-include("include/ec_cmd_log.hrl").
|
||||
-include("src/ec_cmd_log.hrl").
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
should_test() ->
|
||||
ErrorLogState = ec_cmd_log:new(error),
|
||||
?assertMatch(true, ec_cmd_log:should(ErrorLogState, ?EC_ERROR)),
|
||||
?assertMatch(true, not ec_cmd_log:should(ErrorLogState, ?EC_INFO)),
|
||||
?assertMatch(true, not ec_cmd_log:should(ErrorLogState, ?EC_DEBUG)),
|
||||
?assertEqual(?EC_ERROR, ec_cmd_log:log_level(ErrorLogState)),
|
||||
?assertEqual(error, ec_cmd_log:atom_log_level(ErrorLogState)),
|
||||
|
||||
InfoLogState = ec_cmd_log:new(info),
|
||||
?assertMatch(true, ec_cmd_log:should(InfoLogState, ?EC_ERROR)),
|
||||
?assertMatch(true, ec_cmd_log:should(InfoLogState, ?EC_INFO)),
|
||||
?assertMatch(true, not ec_cmd_log:should(InfoLogState, ?EC_DEBUG)),
|
||||
?assertEqual(?EC_INFO, ec_cmd_log:log_level(InfoLogState)),
|
||||
?assertEqual(info, ec_cmd_log:atom_log_level(InfoLogState)),
|
||||
|
||||
DebugLogState = ec_cmd_log:new(debug),
|
||||
?assertMatch(true, ec_cmd_log:should(DebugLogState, ?EC_ERROR)),
|
||||
?assertMatch(true, ec_cmd_log:should(DebugLogState, ?EC_INFO)),
|
||||
?assertMatch(true, ec_cmd_log:should(DebugLogState, ?EC_DEBUG)),
|
||||
?assertEqual(?EC_DEBUG, ec_cmd_log:log_level(DebugLogState)),
|
||||
?assertEqual(debug, ec_cmd_log:atom_log_level(DebugLogState)).
|
||||
|
||||
|
||||
no_color_test() ->
|
||||
LogState = ec_cmd_log:new(debug, command_line, none),
|
||||
?assertEqual("test",
|
||||
ec_cmd_log:colorize(LogState, ?RED, true, "test")).
|
||||
|
||||
color_test() ->
|
||||
LogState = ec_cmd_log:new(debug, command_line, high),
|
||||
?assertEqual("\e[1;31m===> test\e[0m",
|
||||
ec_cmd_log:colorize(LogState, ?RED, true, "test")).
|
28
test/ec_cnv_tests.erl
Normal file
28
test/ec_cnv_tests.erl
Normal file
|
@ -0,0 +1,28 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_cnv_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
to_integer_test() ->
|
||||
?assertError(badarg, ec_cnv:to_integer(1.5, strict)).
|
||||
|
||||
to_float_test() ->
|
||||
?assertError(badarg, ec_cnv:to_float(10, strict)).
|
||||
|
||||
to_atom_test() ->
|
||||
?assertMatch(true, ec_cnv:to_atom("true")),
|
||||
?assertMatch(true, ec_cnv:to_atom(<<"true">>)),
|
||||
?assertMatch(false, ec_cnv:to_atom(<<"false">>)),
|
||||
?assertMatch(false, ec_cnv:to_atom(false)),
|
||||
?assertError(badarg, ec_cnv:to_atom("hello_foo_bar_baz")),
|
||||
|
||||
S = erlang:list_to_atom("1"),
|
||||
?assertMatch(S, ec_cnv:to_atom(1)).
|
||||
|
||||
to_boolean_test()->
|
||||
?assertMatch(true, ec_cnv:to_boolean(<<"true">>)),
|
||||
?assertMatch(true, ec_cnv:to_boolean("true")),
|
||||
?assertMatch(true, ec_cnv:to_boolean(true)),
|
||||
?assertMatch(false, ec_cnv:to_boolean(<<"false">>)),
|
||||
?assertMatch(false, ec_cnv:to_boolean("false")),
|
||||
?assertMatch(false, ec_cnv:to_boolean(false)).
|
84
test/ec_file_tests.erl
Normal file
84
test/ec_file_tests.erl
Normal file
|
@ -0,0 +1,84 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_file_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
setup_test() ->
|
||||
Dir = ec_file:insecure_mkdtemp(),
|
||||
ec_file:mkdir_path(Dir),
|
||||
?assertMatch(false, ec_file:is_symlink(Dir)),
|
||||
?assertMatch(true, filelib:is_dir(Dir)).
|
||||
|
||||
md5sum_test() ->
|
||||
?assertMatch("cfcd208495d565ef66e7dff9f98764da", ec_file:md5sum("0")).
|
||||
|
||||
sha1sum_test() ->
|
||||
?assertMatch("b6589fc6ab0dc82cf12099d1c2d40ab994e8410c", ec_file:sha1sum("0")).
|
||||
|
||||
file_test() ->
|
||||
Dir = ec_file:insecure_mkdtemp(),
|
||||
TermFile = filename:join(Dir, "ec_file/dir/file.term"),
|
||||
TermFileCopy = filename:join(Dir, "ec_file/dircopy/file.term"),
|
||||
filelib:ensure_dir(TermFile),
|
||||
filelib:ensure_dir(TermFileCopy),
|
||||
ec_file:write_term(TermFile, "term"),
|
||||
?assertMatch({ok, <<"\"term\". ">>}, ec_file:read(TermFile)),
|
||||
ec_file:copy(filename:dirname(TermFile),
|
||||
filename:dirname(TermFileCopy),
|
||||
[recursive]).
|
||||
|
||||
teardown_test() ->
|
||||
Dir = ec_file:insecure_mkdtemp(),
|
||||
ec_file:remove(Dir, [recursive]),
|
||||
?assertMatch(false, filelib:is_dir(Dir)).
|
||||
|
||||
setup_base_and_target() ->
|
||||
BaseDir = ec_file:insecure_mkdtemp(),
|
||||
DummyContents = <<"This should be deleted">>,
|
||||
SourceDir = filename:join([BaseDir, "source"]),
|
||||
ok = file:make_dir(SourceDir),
|
||||
Name1 = filename:join([SourceDir, "fileone"]),
|
||||
Name2 = filename:join([SourceDir, "filetwo"]),
|
||||
Name3 = filename:join([SourceDir, "filethree"]),
|
||||
NoName = filename:join([SourceDir, "noname"]),
|
||||
|
||||
ok = file:write_file(Name1, DummyContents),
|
||||
ok = file:write_file(Name2, DummyContents),
|
||||
ok = file:write_file(Name3, DummyContents),
|
||||
ok = file:write_file(NoName, DummyContents),
|
||||
{BaseDir, SourceDir, {Name1, Name2, Name3, NoName}}.
|
||||
|
||||
exists_test() ->
|
||||
BaseDir = ec_file:insecure_mkdtemp(),
|
||||
SourceDir = filename:join([BaseDir, "source1"]),
|
||||
NoName = filename:join([SourceDir, "noname"]),
|
||||
ok = file:make_dir(SourceDir),
|
||||
Name1 = filename:join([SourceDir, "fileone"]),
|
||||
ok = file:write_file(Name1, <<"Testn">>),
|
||||
?assertMatch(true, ec_file:exists(Name1)),
|
||||
?assertMatch(false, ec_file:exists(NoName)).
|
||||
|
||||
real_path_test() ->
|
||||
BaseDir = "foo",
|
||||
Dir = filename:absname(filename:join(BaseDir, "source1")),
|
||||
LinkDir = filename:join([BaseDir, "link"]),
|
||||
ok = ec_file:mkdir_p(Dir),
|
||||
file:make_symlink(Dir, LinkDir),
|
||||
?assertEqual(Dir, ec_file:real_dir_path(LinkDir)),
|
||||
?assertEqual(directory, ec_file:type(Dir)),
|
||||
?assertEqual(symlink, ec_file:type(LinkDir)),
|
||||
TermFile = filename:join(BaseDir, "test_file"),
|
||||
ok = ec_file:write_term(TermFile, foo),
|
||||
?assertEqual(file, ec_file:type(TermFile)),
|
||||
?assertEqual(true, ec_file:is_symlink(LinkDir)),
|
||||
?assertEqual(false, ec_file:is_symlink(Dir)).
|
||||
|
||||
find_test() ->
|
||||
%% Create a directory in /tmp for the test. Clean everything afterwards
|
||||
{BaseDir, _SourceDir, {Name1, Name2, Name3, _NoName}} = setup_base_and_target(),
|
||||
Result = ec_file:find(BaseDir, "file[a-z]+\$"),
|
||||
?assertMatch(3, erlang:length(Result)),
|
||||
?assertEqual(true, lists:member(Name1, Result)),
|
||||
?assertEqual(true, lists:member(Name2, Result)),
|
||||
?assertEqual(true, lists:member(Name3, Result)),
|
||||
ec_file:remove(BaseDir, [recursive]).
|
67
test/ec_gb_trees_tests.erl
Normal file
67
test/ec_gb_trees_tests.erl
Normal file
|
@ -0,0 +1,67 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_gb_trees_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
%% For me unit testing initially is about covering the obvious case. A
|
||||
%% check to make sure that what you expect the tested functionality to
|
||||
%% do, it actually does. As time goes on and people detect bugs you
|
||||
%% add tests for those specific problems to the unit test suit.
|
||||
%%
|
||||
%% However, when getting started you can only test your basic
|
||||
%% expectations. So here are the expectations I have for the add
|
||||
%% functionality.
|
||||
%%
|
||||
%% 1) I can put arbitrary terms into the dictionary as keys
|
||||
%% 2) I can put arbitrary terms into the dictionary as values
|
||||
%% 3) When I put a value in the dictionary by a key, I can retrieve
|
||||
%% that same value
|
||||
%% 4) When I put a different value in the dictionary by key it does
|
||||
%% not change other key value pairs.
|
||||
%% 5) When I update a value the new value in available by the new key
|
||||
%% 6) When a value does not exist a not found exception is created
|
||||
|
||||
add_test() ->
|
||||
Dict0 = ec_dictionary:new(ec_gb_trees),
|
||||
|
||||
Key1 = foo,
|
||||
Key2 = [1, 3],
|
||||
Key3 = {"super"},
|
||||
Key4 = <<"fabulous">>,
|
||||
Key5 = {"Sona", 2, <<"Zuper">>},
|
||||
|
||||
Value1 = Key5,
|
||||
Value2 = Key4,
|
||||
Value3 = Key2,
|
||||
Value4 = Key3,
|
||||
Value5 = Key1,
|
||||
|
||||
Dict01 = ec_dictionary:add(Key1, Value1, Dict0),
|
||||
Dict02 = ec_dictionary:add(Key3, Value3,
|
||||
ec_dictionary:add(Key2, Value2,
|
||||
Dict01)),
|
||||
Dict1 =
|
||||
ec_dictionary:add(Key5, Value5,
|
||||
ec_dictionary:add(Key4, Value4,
|
||||
Dict02)),
|
||||
|
||||
?assertMatch(Value1, ec_dictionary:get(Key1, Dict1)),
|
||||
?assertMatch(Value2, ec_dictionary:get(Key2, Dict1)),
|
||||
?assertMatch(Value3, ec_dictionary:get(Key3, Dict1)),
|
||||
?assertMatch(Value4, ec_dictionary:get(Key4, Dict1)),
|
||||
?assertMatch(Value5, ec_dictionary:get(Key5, Dict1)),
|
||||
|
||||
|
||||
Dict2 = ec_dictionary:add(Key3, Value5,
|
||||
ec_dictionary:add(Key2, Value4, Dict1)),
|
||||
|
||||
|
||||
?assertMatch(Value1, ec_dictionary:get(Key1, Dict2)),
|
||||
?assertMatch(Value4, ec_dictionary:get(Key2, Dict2)),
|
||||
?assertMatch(Value5, ec_dictionary:get(Key3, Dict2)),
|
||||
?assertMatch(Value4, ec_dictionary:get(Key4, Dict2)),
|
||||
?assertMatch(Value5, ec_dictionary:get(Key5, Dict2)),
|
||||
|
||||
|
||||
?assertThrow(not_found, ec_dictionary:get(should_blow_up, Dict2)),
|
||||
?assertThrow(not_found, ec_dictionary:get("This should blow up too",
|
||||
Dict2)).
|
13
test/ec_git_vsn_tests.erl
Normal file
13
test/ec_git_vsn_tests.erl
Normal file
|
@ -0,0 +1,13 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_git_vsn_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
parse_tags_test() ->
|
||||
?assertEqual({undefined, ""}, ec_git_vsn:parse_tags("a.b.c")).
|
||||
|
||||
get_patch_count_test() ->
|
||||
?assertEqual(0, ec_git_vsn:get_patch_count("a.b.c")).
|
||||
|
||||
collect_default_refcount_test() ->
|
||||
?assertMatch({"", _, _}, ec_git_vsn:collect_default_refcount("a.b.c")).
|
172
test/ec_lists_tests.erl
Normal file
172
test/ec_lists_tests.erl
Normal file
|
@ -0,0 +1,172 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_lists_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
find1_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = ec_lists:find(fun(5) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 5}, Result),
|
||||
|
||||
Result2 = ec_lists:find(fun(37) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(error, Result2).
|
||||
|
||||
find2_test() ->
|
||||
TestData = ["one", "two", "three", "four", "five", "six"],
|
||||
Result = ec_lists:find(fun("five") ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, "five"}, Result),
|
||||
|
||||
Result2 = ec_lists:find(fun(super_duper) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(error, Result2).
|
||||
|
||||
find3_test() ->
|
||||
TestData = [{"one", 1}, {"two", 2}, {"three", 3}, {"four", 5}, {"five", 5},
|
||||
{"six", 6}],
|
||||
Result = ec_lists:find(fun({"one", 1}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, {"one", 1}}, Result),
|
||||
|
||||
Result2 = ec_lists:find(fun([fo, bar, baz]) ->
|
||||
true;
|
||||
({"onehundred", 100}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(error, Result2).
|
||||
|
||||
fetch1_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = ec_lists:fetch(fun(5) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(5, Result),
|
||||
|
||||
?assertThrow(not_found,
|
||||
ec_lists:fetch(fun(37) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData)).
|
||||
|
||||
fetch2_test() ->
|
||||
TestData = ["one", "two", "three", "four", "five", "six"],
|
||||
Result = ec_lists:fetch(fun("five") ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch("five", Result),
|
||||
|
||||
?assertThrow(not_found,
|
||||
ec_lists:fetch(fun(super_duper) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData)).
|
||||
|
||||
fetch3_test() ->
|
||||
TestData = [{"one", 1}, {"two", 2}, {"three", 3}, {"four", 5}, {"five", 5},
|
||||
{"six", 6}],
|
||||
Result = ec_lists:fetch(fun({"one", 1}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({"one", 1}, Result),
|
||||
|
||||
?assertThrow(not_found,
|
||||
ec_lists:fetch(fun([fo, bar, baz]) ->
|
||||
true;
|
||||
({"onehundred", 100}) ->
|
||||
true;
|
||||
(_) ->
|
||||
false
|
||||
end,
|
||||
TestData)).
|
||||
|
||||
search1_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = ec_lists:search(fun(5) ->
|
||||
{ok, 5};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 5, 5}, Result),
|
||||
|
||||
Result2 = ec_lists:search(fun(37) ->
|
||||
{ok, 37};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(not_found, Result2).
|
||||
|
||||
search2_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = ec_lists:search(fun(1) ->
|
||||
{ok, 10};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 10, 1}, Result),
|
||||
|
||||
Result2 = ec_lists:search(fun(6) ->
|
||||
{ok, 37};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch({ok, 37, 6}, Result2).
|
||||
|
||||
search3_test() ->
|
||||
TestData = [1, 2, 3, 4, 5, 6],
|
||||
Result = ec_lists:search(fun(10) ->
|
||||
{ok, 10};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(not_found, Result),
|
||||
|
||||
Result2 = ec_lists:search(fun(-1) ->
|
||||
{ok, 37};
|
||||
(_) ->
|
||||
not_found
|
||||
end,
|
||||
TestData),
|
||||
?assertMatch(not_found, Result2).
|
447
test/ec_semver_tests.erl
Normal file
447
test/ec_semver_tests.erl
Normal file
|
@ -0,0 +1,447 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_semver_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
eql_test() ->
|
||||
?assertMatch(true, ec_semver:eql("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:eql("v1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:eql("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:eql("v1",
|
||||
"v1.0.0")),
|
||||
?assertMatch(true, ec_semver:eql("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:eql("1.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, ec_semver:eql("1.0.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, ec_semver:eql("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, ec_semver:eql("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, ec_semver:eql("1.0-alpha.1+build.1",
|
||||
"1.0.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, ec_semver:eql("1.0-alpha.1+build.1",
|
||||
"v1.0.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, ec_semver:eql("1.0-pre-alpha.1",
|
||||
"1.0.0-pre-alpha.1")),
|
||||
?assertMatch(true, ec_semver:eql("aa", "aa")),
|
||||
?assertMatch(true, ec_semver:eql("AA.BB", "AA.BB")),
|
||||
?assertMatch(true, ec_semver:eql("BBB-super", "BBB-super")),
|
||||
?assertMatch(true, not ec_semver:eql("1.0.0",
|
||||
"1.0.1")),
|
||||
?assertMatch(true, not ec_semver:eql("1.0.0-alpha",
|
||||
"1.0.1+alpha")),
|
||||
?assertMatch(true, not ec_semver:eql("1.0.0+build.1",
|
||||
"1.0.1+build.2")),
|
||||
?assertMatch(true, not ec_semver:eql("1.0.0.0+build.1",
|
||||
"1.0.0.1+build.2")),
|
||||
?assertMatch(true, not ec_semver:eql("FFF", "BBB")),
|
||||
?assertMatch(true, not ec_semver:eql("1", "1BBBB")).
|
||||
|
||||
gt_test() ->
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0.1-alpha.1",
|
||||
"1.0.0.1-alpha")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0.4-alpha.1",
|
||||
"1.0.0.2-alpha")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-pre-alpha.14",
|
||||
"1.0.0-pre-alpha.3")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-beta.11",
|
||||
"1.0.0.0-beta.2")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, ec_semver:gt("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, ec_semver:gt("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, ec_semver:gt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, ec_semver:gt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7.0+build")),
|
||||
?assertMatch(true, ec_semver:gt("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, ec_semver:gt("aa.cc",
|
||||
"aa.bb")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-alpha",
|
||||
"1.0.0.0-alpha.1")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-pre-alpha.3",
|
||||
"1.0.0-pre-alpha.14")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not ec_semver:gt("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, not ec_semver:gt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not ec_semver:gt("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:gt("aa.bb",
|
||||
"aa.bb")),
|
||||
?assertMatch(true, not ec_semver:gt("aa.cc",
|
||||
"aa.dd")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, not ec_semver:gt("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")).
|
||||
|
||||
lt_test() ->
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-alpha",
|
||||
"1.0.0.0-alpha.1")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-pre-alpha.3",
|
||||
"1.0.0-pre-alpha.14")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0.1-beta.11",
|
||||
"1.0.0.1-rc.1")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, ec_semver:lt("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, ec_semver:lt("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, ec_semver:lt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not ec_semver:lt("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:lt("1",
|
||||
"1.0.0.1")),
|
||||
?assertMatch(true, ec_semver:lt("AA.DD",
|
||||
"AA.EE")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, not ec_semver:lt("AA.DD", "AA.CC")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-pre-alpha.14",
|
||||
"1.0.0-pre-alpha.3")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not ec_semver:lt("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, not ec_semver:lt("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, not ec_semver:lt("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not ec_semver:lt("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")).
|
||||
|
||||
gte_test() ->
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1",
|
||||
"1.0.0")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1.0",
|
||||
"1.0.0")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1.0.0",
|
||||
"1")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1.0.0.0",
|
||||
"1")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-alpha.1+build.1",
|
||||
"1.0.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, ec_semver:gte("aa.bb", "aa.bb")),
|
||||
?assertMatch(true, ec_semver:gte("dd", "aa")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, ec_semver:gte("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, ec_semver:gte("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, ec_semver:gte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, ec_semver:gte("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-pre-alpha",
|
||||
"1.0.0-pre-alpha.1")),
|
||||
?assertMatch(true, not ec_semver:gte("CC", "DD")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not ec_semver:gte("1.0.0",
|
||||
"1.0.0+build.1")),
|
||||
?assertMatch(true, not ec_semver:gte("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, not ec_semver:gte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")).
|
||||
lte_test() ->
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-alpha",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-beta.2",
|
||||
"1.0.0-beta.11")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha.11")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-beta.11",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-rc.1+build.1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0",
|
||||
"1.0.0+0.3.7")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0+0.3.7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, ec_semver:lte("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7")),
|
||||
?assertMatch(true, ec_semver:lte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:lte("1",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:lte("1.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0",
|
||||
"1")),
|
||||
?assertMatch(true, ec_semver:lte("1.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, ec_semver:lte("1.0.0.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, ec_semver:lte("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, ec_semver:lte("aa","cc")),
|
||||
?assertMatch(true, ec_semver:lte("cc","cc")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0-alpha.1",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha")),
|
||||
?assertMatch(true, not ec_semver:lte("cc", "aa")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0-beta.2",
|
||||
"1.0.0-alpha.1")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0-beta.11",
|
||||
"1.0.0-beta.2")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0-rc.1", "1.0.0-beta.11")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0-rc.1+build.1", "1.0.0-rc.1")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0", "1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, not ec_semver:lte("1.0.0+0.3.7", "1.0.0")),
|
||||
?assertMatch(true, not ec_semver:lte("1.3.7+build", "1.0.0+0.3.7")),
|
||||
?assertMatch(true, not ec_semver:lte("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build")),
|
||||
?assertMatch(true, not ec_semver:lte("1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.2.b8f12d7")).
|
||||
|
||||
between_test() ->
|
||||
?assertMatch(true, ec_semver:between("1.0.0-alpha",
|
||||
"1.0.0-alpha.3",
|
||||
"1.0.0-alpha.2")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-alpha.1",
|
||||
"1.0.0-beta.2",
|
||||
"1.0.0-alpha.25")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-beta.2",
|
||||
"1.0.0-beta.11",
|
||||
"1.0.0-beta.7")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-pre-alpha.2",
|
||||
"1.0.0-pre-alpha.11",
|
||||
"1.0.0-pre-alpha.7")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-beta.11",
|
||||
"1.0.0-rc.3",
|
||||
"1.0.0-rc.1")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.3",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
|
||||
?assertMatch(true, ec_semver:between("1.0.0.0-rc.1",
|
||||
"1.0.0-rc.1+build.3",
|
||||
"1.0.0-rc.1+build.1")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-rc.1+build.1",
|
||||
"1.0.0",
|
||||
"1.0.0-rc.33")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0",
|
||||
"1.0.0+0.3.7",
|
||||
"1.0.0+0.2")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0+0.3.7",
|
||||
"1.3.7+build",
|
||||
"1.2")),
|
||||
?assertMatch(true, ec_semver:between("1.3.7+build",
|
||||
"1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.1")),
|
||||
?assertMatch(true, ec_semver:between("1.3.7+build.2.b8f12d7",
|
||||
"1.3.7+build.11.e0f985a",
|
||||
"1.3.7+build.10.a36faa")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0-alpha",
|
||||
"1.0.0-alpha",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, ec_semver:between("1",
|
||||
"1.0.0",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, ec_semver:between("1.0",
|
||||
"1.0.0",
|
||||
"1.0.0")),
|
||||
|
||||
?assertMatch(true, ec_semver:between("1.0",
|
||||
"1.0.0.0",
|
||||
"1.0.0.0")),
|
||||
?assertMatch(true, ec_semver:between("1.0.0",
|
||||
"1",
|
||||
"1")),
|
||||
?assertMatch(true, ec_semver:between("1.0+alpha.1",
|
||||
"1.0.0+alpha.1",
|
||||
"1.0.0+alpha.1")),
|
||||
?assertMatch(true, ec_semver:between("1.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1",
|
||||
"1.0.0-alpha.1+build.1")),
|
||||
?assertMatch(true, ec_semver:between("aaa",
|
||||
"ddd",
|
||||
"cc")),
|
||||
?assertMatch(true, not ec_semver:between("1.0.0-alpha.1",
|
||||
"1.0.0-alpha.22",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:between("1.0.0-pre-alpha.1",
|
||||
"1.0.0-pre-alpha.22",
|
||||
"1.0.0")),
|
||||
?assertMatch(true, not ec_semver:between("1.0.0",
|
||||
"1.0.0-alpha.1",
|
||||
"2.0")),
|
||||
?assertMatch(true, not ec_semver:between("1.0.0-beta.1",
|
||||
"1.0.0-beta.11",
|
||||
"1.0.0-alpha")),
|
||||
?assertMatch(true, not ec_semver:between("1.0.0-beta.11", "1.0.0-rc.1",
|
||||
"1.0.0-rc.22")),
|
||||
?assertMatch(true, not ec_semver:between("aaa", "ddd", "zzz")).
|
||||
|
||||
pes_test() ->
|
||||
?assertMatch(true, ec_semver:pes("1.0.0-rc.0", "1.0.0-rc.0")),
|
||||
?assertMatch(true, ec_semver:pes("1.0.0-rc.1", "1.0.0-rc.0")),
|
||||
?assertMatch(true, ec_semver:pes("1.0.0", "1.0.0-rc.0")),
|
||||
?assertMatch(false, ec_semver:pes("1.0.0-rc.0", "1.0.0-rc.1")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.0", "2.6")),
|
||||
?assertMatch(true, ec_semver:pes("2.7", "2.6")),
|
||||
?assertMatch(true, ec_semver:pes("2.8", "2.6")),
|
||||
?assertMatch(true, ec_semver:pes("2.9", "2.6")),
|
||||
?assertMatch(true, ec_semver:pes("A.B", "A.A")),
|
||||
?assertMatch(true, not ec_semver:pes("3.0.0", "2.6")),
|
||||
?assertMatch(true, not ec_semver:pes("2.5", "2.6")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.5", "2.6.5")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.6", "2.6.5")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.7", "2.6.5")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.8", "2.6.5")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.9", "2.6.5")),
|
||||
?assertMatch(true, ec_semver:pes("2.6.0.9", "2.6.0.5")),
|
||||
?assertMatch(true, not ec_semver:pes("2.7", "2.6.5")),
|
||||
?assertMatch(true, not ec_semver:pes("2.1.7", "2.1.6.5")),
|
||||
?assertMatch(true, not ec_semver:pes("A.A", "A.B")),
|
||||
?assertMatch(true, not ec_semver:pes("2.5", "2.6.5")).
|
||||
|
||||
parse_test() ->
|
||||
?assertEqual({1, {[],[]}}, ec_semver:parse(<<"1">>)),
|
||||
?assertEqual({{1,2,34},{[],[]}}, ec_semver:parse(<<"1.2.34">>)),
|
||||
?assertEqual({<<"a">>, {[],[]}}, ec_semver:parse(<<"a">>)),
|
||||
?assertEqual({{<<"a">>,<<"b">>}, {[],[]}}, ec_semver:parse(<<"a.b">>)),
|
||||
?assertEqual({1, {[],[]}}, ec_semver:parse(<<"1">>)),
|
||||
?assertEqual({{1,2}, {[],[]}}, ec_semver:parse(<<"1.2">>)),
|
||||
?assertEqual({{1,2,2}, {[],[]}}, ec_semver:parse(<<"1.2.2">>)),
|
||||
?assertEqual({{1,99,2}, {[],[]}}, ec_semver:parse(<<"1.99.2">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"alpha">>],[]}}, ec_semver:parse(<<"1.99.2-alpha">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"alpha">>,1], []}}, ec_semver:parse(<<"1.99.2-alpha.1">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"pre-alpha">>,1], []}}, ec_semver:parse(<<"1.99.2-pre-alpha.1">>)),
|
||||
?assertEqual({{1,99,2}, {[], [<<"build">>, 1, <<"a36">>]}},
|
||||
ec_semver:parse(<<"1.99.2+build.1.a36">>)),
|
||||
?assertEqual({{1,99,2,44}, {[], [<<"build">>, 1, <<"a36">>]}},
|
||||
ec_semver:parse(<<"1.99.2.44+build.1.a36">>)),
|
||||
?assertEqual({{1,99,2}, {[<<"alpha">>, 1], [<<"build">>, 1, <<"a36">>]}},
|
||||
ec_semver:parse("1.99.2-alpha.1+build.1.a36")),
|
||||
?assertEqual({{1,99,2}, {[<<"pre-alpha">>, 1], [<<"build">>, 1, <<"a36">>]}},
|
||||
ec_semver:parse("1.99.2-pre-alpha.1+build.1.a36")).
|
||||
|
||||
version_format_test() ->
|
||||
?assertEqual(["1", [], []], ec_semver:format({1, {[],[]}})),
|
||||
?assertEqual(["1", ".", "2", ".", "34", [], []], ec_semver:format({{1,2,34},{[],[]}})),
|
||||
?assertEqual(<<"a">>, erlang:iolist_to_binary(ec_semver:format({<<"a">>, {[],[]}}))),
|
||||
?assertEqual(<<"a.b">>, erlang:iolist_to_binary(ec_semver:format({{<<"a">>,<<"b">>}, {[],[]}}))),
|
||||
?assertEqual(<<"1">>, erlang:iolist_to_binary(ec_semver:format({1, {[],[]}}))),
|
||||
?assertEqual(<<"1.2">>, erlang:iolist_to_binary(ec_semver:format({{1,2}, {[],[]}}))),
|
||||
?assertEqual(<<"1.2.2">>, erlang:iolist_to_binary(ec_semver:format({{1,2,2}, {[],[]}}))),
|
||||
?assertEqual(<<"1.99.2">>, erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[],[]}}))),
|
||||
?assertEqual(<<"1.99.2-alpha">>, erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[<<"alpha">>],[]}}))),
|
||||
?assertEqual(<<"1.99.2-alpha.1">>, erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[<<"alpha">>,1], []}}))),
|
||||
?assertEqual(<<"1.99.2-pre-alpha.1">>, erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[<<"pre-alpha">>,1], []}}))),
|
||||
?assertEqual(<<"1.99.2+build.1.a36">>,
|
||||
erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1.99.2.44+build.1.a36">>,
|
||||
erlang:iolist_to_binary(ec_semver:format({{1,99,2,44}, {[], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1.99.2-alpha.1+build.1.a36">>,
|
||||
erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[<<"alpha">>, 1], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1.99.2-pre-alpha.1+build.1.a36">>,
|
||||
erlang:iolist_to_binary(ec_semver:format({{1,99,2}, {[<<"pre-alpha">>, 1], [<<"build">>, 1, <<"a36">>]}}))),
|
||||
?assertEqual(<<"1">>, erlang:iolist_to_binary(ec_semver:format({1, {[],[]}}))).
|
19
test/ec_talk_tests.erl
Normal file
19
test/ec_talk_tests.erl
Normal file
|
@ -0,0 +1,19 @@
|
|||
%%% @copyright 2024 Erlware, LLC.
|
||||
-module(ec_talk_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
general_test_() ->
|
||||
[?_test(42 == ec_talk:get_integer("42")),
|
||||
?_test(500_211 == ec_talk:get_integer("500211")),
|
||||
?_test(1_234_567_890 == ec_talk:get_integer("1234567890")),
|
||||
?_test(12_345_678_901_234_567_890 == ec_talk:get_integer("12345678901234567890")),
|
||||
?_test(true == ec_talk:get_boolean("true")),
|
||||
?_test(false == ec_talk:get_boolean("false")),
|
||||
?_test(true == ec_talk:get_boolean("Ok")),
|
||||
?_test(true == ec_talk:get_boolean("ok")),
|
||||
?_test(true == ec_talk:get_boolean("Y")),
|
||||
?_test(true == ec_talk:get_boolean("y")),
|
||||
?_test(false == ec_talk:get_boolean("False")),
|
||||
?_test(false == ec_talk:get_boolean("No")),
|
||||
?_test(false == ec_talk:get_boolean("no"))].
|
Loading…
Add table
Add a link
Reference in a new issue