Skip to content

Commit ca53323

Browse files
CrowdHailerlpil
authored andcommitted
dynamic to string does not check utf8 encoding
1 parent 181062b commit ca53323

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/gleam/dynamic_test.gleam

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ pub fn bit_string_test() {
1010
""
1111
|> dynamic.from
1212
|> dynamic.bit_string
13-
|> should.equal(Ok(bit_string.from_string("")))
13+
|> should.equal(Ok(<<"":utf8>>))
1414

1515
"Hello"
1616
|> dynamic.from
1717
|> dynamic.bit_string
18-
|> should.equal(Ok(bit_string.from_string("Hello")))
18+
|> should.equal(Ok(<<"Hello":utf8>>))
19+
20+
<<0, 2>>
21+
|> dynamic.from
22+
|> dynamic.bit_string
23+
|> should.equal(Ok(<<0, 2>>))
1924

2025
1
2126
|> dynamic.from
@@ -39,6 +44,11 @@ pub fn string_test() {
3944
|> dynamic.string
4045
|> should.equal(Ok("Hello"))
4146

47+
<<0, 2>>
48+
|> dynamic.from
49+
|> dynamic.string
50+
|> should.equal(Error("Expected a string, got a bit_string"))
51+
4252
1
4353
|> dynamic.from
4454
|> dynamic.string

0 commit comments

Comments
 (0)