Skip to content

Commit 8f9dcbf

Browse files
committed
tests: unique: test also invalid arguments
Make sure that erlang:unique_integer/1 fails with error:badarg when an invalid list is given. Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent 84fdf33 commit 8f9dcbf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/erlang_tests/unique.erl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
-module(unique).
2222

23-
-export([start/0]).
23+
-export([start/0, id/1, check_error/3]).
2424

2525
start() ->
2626
ok = unique_0(),
@@ -39,6 +39,20 @@ start() ->
3939
receive_messages(N),
4040
0.
4141

42+
test_invalid() ->
43+
ok = ?MODULE:check_error(fun() -> erlang:unique_integer(?MODULE:id(5)) end),
44+
ok = ?MODULE:check_error(fun() -> erlang:unique_integer(?MODULE:id([positive | monotonic])) end).
45+
46+
check_error(F, A, B) ->
47+
try F() of
48+
Result -> {unexpected, Result}
49+
catch
50+
A:B -> ok
51+
end.
52+
53+
id(X) ->
54+
X.
55+
4256
unique_0() ->
4357
A = erlang:unique_integer(),
4458
B = erlang:unique_integer(),

0 commit comments

Comments
 (0)