diff options
-rw-r--r-- | test/gleam_json_test.gleam | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam index 768a994..80849e3 100644 --- a/test/gleam_json_test.gleam +++ b/test/gleam_json_test.gleam @@ -13,10 +13,16 @@ pub fn decode_test() { json.decode("5") |> result.map(dynamic.from) |> should.equal(Ok(dynamic.from(5))) +} + +pub fn decode_empty_test() { + json.decode("") + |> should.equal(Error(json.UnexpectedEndOfInput)) +} - json.decode(".") - |> result.nil_error() - |> should.equal(Error(Nil)) +pub fn decode_unexpected_byte_test() { + json.decode("[}") + |> should.equal(Error(json.UnexpectedByte("0x7D", 1))) } pub fn encode_string_test() { @@ -37,6 +43,12 @@ pub fn encode_object_test() { |> should.equal("{\"foo\":5}") } +pub fn encode_list_test() { + json.list([json.int(5), json.int(6)]) + |> json.to_string() + |> should.equal("[5,6]") +} + pub fn encode_nullable_test() { json.nullable(Some(5), json.int) |> json.to_string() |