From b2d421a778fc9d203acae92e3e0590de1d536d44 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Sat, 1 Jan 2022 15:53:35 +0000 Subject: Missing types --- test/gleam_json_test.gleam | 18 +++++++++++++++--- 1 file 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() -- cgit v1.2.3