aboutsummaryrefslogtreecommitdiff
path: root/test/int_test.gleam
diff options
context:
space:
mode:
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")
+}