diff options
author | Louis Pilfold <louis@lpil.uk> | 2021-07-30 20:35:57 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-07-30 20:35:57 +0100 |
commit | 12d91899bf20c95c491f1c7323ec9e198208ebac (patch) | |
tree | fe591676915769aeec2d1c80ac2a7a7ff43110b6 /test | |
parent | f37b2a7389cb7946d8a21381eb134cd3d579abc0 (diff) | |
download | gleam_stdlib-12d91899bf20c95c491f1c7323ec9e198208ebac.tar.gz gleam_stdlib-12d91899bf20c95c491f1c7323ec9e198208ebac.zip |
Bit string JS funtions
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/bit_string_test.gleam | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/test/gleam/bit_string_test.gleam b/test/gleam/bit_string_test.gleam index 8012587..199e1cb 100644 --- a/test/gleam/bit_string_test.gleam +++ b/test/gleam/bit_string_test.gleam @@ -57,45 +57,48 @@ if erlang { |> bit_string.part(1, 6) |> should.equal(Error(Nil)) } +} - pub fn u32_test() { - let Ok(bin) = bit_string.int_to_u32(0) - should.equal(4, bit_string.byte_size(bin)) - should.equal(Ok(0), bit_string.int_from_u32(bin)) - - let Ok(bin) = bit_string.int_to_u32(4294967295) - should.equal(4, bit_string.byte_size(bin)) - should.equal(Ok(4294967295), bit_string.int_from_u32(bin)) - - should.equal( - Error(Nil), - bit_string.int_from_u32(bit_string.from_string("")), - ) - should.equal( - Error(Nil), - bit_string.int_from_u32(bit_string.from_string("12345")), - ) - } +pub fn to_string_test() { + <<>> + |> bit_string.to_string + |> should.equal(Ok("")) - pub fn to_string_test() { - <<>> - |> bit_string.to_string - |> should.equal(Ok("")) + <<"":utf8>> + |> bit_string.to_string + |> should.equal(Ok("")) - <<"":utf8>> - |> bit_string.to_string - |> should.equal(Ok("")) + <<"Hello":utf8>> + |> bit_string.to_string + |> should.equal(Ok("Hello")) - <<"Hello":utf8>> - |> bit_string.to_string - |> should.equal(Ok("Hello")) + <<"ø":utf8>> + |> bit_string.to_string + |> should.equal(Ok("ø")) - <<"ø":utf8>> - |> bit_string.to_string - |> should.equal(Ok("ø")) + <<65535>> + |> bit_string.to_string + |> should.equal(Error(Nil)) +} - <<65535:16>> - |> bit_string.to_string - |> should.equal(Error(Nil)) - } +pub fn is_utf8_test() { + <<>> + |> bit_string.is_utf8 + |> should.be_true + + <<"":utf8>> + |> bit_string.is_utf8 + |> should.be_true + + <<"Hello":utf8>> + |> bit_string.is_utf8 + |> should.be_true + + <<"ø":utf8>> + |> bit_string.is_utf8 + |> should.be_true + + <<65535>> + |> bit_string.is_utf8 + |> should.be_false } |