aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2022-01-01 15:53:35 +0000
committerLouis Pilfold <louis@lpil.uk>2022-01-01 15:53:35 +0000
commitb2d421a778fc9d203acae92e3e0590de1d536d44 (patch)
tree989d913ba00d5ce96010d9fed13559be640144a6 /test
parent30248f52a042fa5de08b08e79d76aa3d6a9c4eaf (diff)
downloadgleam_json-b2d421a778fc9d203acae92e3e0590de1d536d44.tar.gz
gleam_json-b2d421a778fc9d203acae92e3e0590de1d536d44.zip
Missing types
Diffstat (limited to 'test')
-rw-r--r--test/gleam_json_test.gleam18
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()