aboutsummaryrefslogtreecommitdiff
path: root/gen/test/int_test.erl
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-04-22 22:33:15 +0000
committerLouis Pilfold <louis@lpil.uk>2019-04-22 22:33:15 +0000
commit077aaf3468c640b84ff53fc92171292ddae55bf4 (patch)
treea152edcc2240f053681ca6ba315dfeb9ed8fa793 /gen/test/int_test.erl
parentafdabad5cd2df77eb3f309aab9da3d34e36a0b49 (diff)
downloadgleam_stdlib-077aaf3468c640b84ff53fc92171292ddae55bf4.tar.gz
gleam_stdlib-077aaf3468c640b84ff53fc92171292ddae55bf4.zip
Int and float modules
Diffstat (limited to 'gen/test/int_test.erl')
-rw-r--r--gen/test/int_test.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/gen/test/int_test.erl b/gen/test/int_test.erl
new file mode 100644
index 0000000..a50b5e6
--- /dev/null
+++ b/gen/test/int_test.erl
@@ -0,0 +1,21 @@
+-module(int_test).
+-compile(no_auto_import).
+
+-export([to_string/0, parse/0, to_base_string/0]).
+
+to_string() ->
+ expect:equal(int:to_string(123), <<"123">>),
+ expect:equal(int:to_string(-123), <<"-123">>),
+ expect:equal(int:to_string(123), <<"123">>).
+
+parse() ->
+ expect:equal(int:parse(<<"123">>), {ok, 123}),
+ expect:equal(int:parse(<<"-123">>), {ok, -123}),
+ expect:equal(int:parse(<<"0123">>), {ok, 123}),
+ expect:is_error(int:parse(<<"">>)),
+ expect:is_error(int:parse(<<"what">>)),
+ expect:is_error(int:parse(<<"1.23">>)).
+
+to_base_string() ->
+ expect:equal(int:to_base_string(100, 16), <<"64">>),
+ expect:equal(int:to_base_string(-100, 16), <<"-64">>).