aboutsummaryrefslogtreecommitdiff
path: root/test/int_test.gleam
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 /test/int_test.gleam
parentafdabad5cd2df77eb3f309aab9da3d34e36a0b49 (diff)
downloadgleam_stdlib-077aaf3468c640b84ff53fc92171292ddae55bf4.tar.gz
gleam_stdlib-077aaf3468c640b84ff53fc92171292ddae55bf4.zip
Int and float modules
Diffstat (limited to 'test/int_test.gleam')
-rw-r--r--test/int_test.gleam52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/int_test.gleam b/test/int_test.gleam
new file mode 100644
index 0000000..d5f0f58
--- /dev/null
+++ b/test/int_test.gleam
@@ -0,0 +1,52 @@
+import expect
+import int
+
+pub fn to_string() {
+ 123
+ |> int:to_string
+ |> expect:equal(_, "123")
+
+ -123
+ |> int:to_string
+ |> expect:equal(_, "-123")
+
+ 0123
+ |> int:to_string
+ |> expect:equal(_, "123")
+}
+
+pub fn parse() {
+ "123"
+ |> int:parse
+ |> expect:equal(_, Ok(123))
+
+ "-123"
+ |> int:parse
+ |> expect:equal(_, Ok(-123))
+
+ "0123"
+ |> int:parse
+ |> expect:equal(_, Ok(123))
+
+ ""
+ |> int:parse
+ |> expect:is_error
+
+ "what"
+ |> int:parse
+ |> expect:is_error
+
+ "1.23"
+ |> int:parse
+ |> expect:is_error
+}
+
+pub fn to_base_string() {
+ 100
+ |> int:to_base_string(_, 16)
+ |> expect:equal(_, "64")
+
+ -100
+ |> int:to_base_string(_, 16)
+ |> expect:equal(_, "-64")
+}