aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRobert Attard <robert.attard@mail.mcgill.ca>2021-10-13 04:08:46 -0400
committerGitHub <noreply@github.com>2021-10-13 09:08:46 +0100
commit8abe053e33c3d3b99d2d069fef11ef9f1402b168 (patch)
treef76df8decf4fa88190a36e1f7f634cdd2256720d /test
parenta2984381b7cac464adf35b446981bbd5da710466 (diff)
downloadgleam_stdlib-8abe053e33c3d3b99d2d069fef11ef9f1402b168.tar.gz
gleam_stdlib-8abe053e33c3d3b99d2d069fef11ef9f1402b168.zip
#238 : result returned from int.to_string_base and add int.to_baseN (#239)
Diffstat (limited to 'test')
-rw-r--r--test/gleam/int_test.gleam58
1 files changed, 57 insertions, 1 deletions
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index bec9624..07832dd 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -70,11 +70,67 @@ pub fn parse_test() {
pub fn to_base_string_test() {
100
|> int.to_base_string(16)
- |> should.equal("64")
+ |> should.equal(Ok("64"))
-100
|> int.to_base_string(16)
+ |> should.equal(Ok("-64"))
+
+ 100
+ |> int.to_base_string(1)
+ |> should.equal(Error(int.InvalidBase))
+
+ 100
+ |> int.to_base_string(37)
+ |> should.equal(Error(int.InvalidBase))
+}
+
+pub fn to_base2_test() {
+ 100
+ |> int.to_base2()
+ |> should.equal("1100100")
+
+ -100
+ |> int.to_base2()
+ |> should.equal("-1100100")
+}
+
+pub fn to_base8_test() {
+ 100
+ |> int.to_base8()
+ |> should.equal("144")
+
+ -100
+ |> int.to_base8()
+ |> should.equal("-144")
+}
+
+pub fn to_base16_test() {
+ 100
+ |> int.to_base16()
+ |> should.equal("64")
+
+ -100
+ |> int.to_base16()
|> should.equal("-64")
+
+ 43981
+ |> int.to_base16()
+ |> should.equal("ABCD")
+
+ -43981
+ |> int.to_base16()
+ |> should.equal("-ABCD")
+}
+
+pub fn to_base36_test() {
+ 100
+ |> int.to_base36()
+ |> should.equal("2S")
+
+ -100
+ |> int.to_base36()
+ |> should.equal("-2S")
}
pub fn to_float_test() {