aboutsummaryrefslogtreecommitdiff
path: root/test/gleam_json_test.gleam
diff options
context:
space:
mode:
Diffstat (limited to 'test/gleam_json_test.gleam')
-rw-r--r--test/gleam_json_test.gleam16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam
index 7e93ab7..fb55c90 100644
--- a/test/gleam_json_test.gleam
+++ b/test/gleam_json_test.gleam
@@ -11,21 +11,27 @@ pub fn main() {
}
pub fn decode_test() {
- json.decode("5")
- |> result.map(dynamic.from)
- |> should.equal(Ok(dynamic.from(5)))
+ json.decode(from: "5", using: dynamic.int)
+ |> should.equal(Ok(5))
}
pub fn decode_empty_test() {
- json.decode("")
+ json.decode(from: "", using: dynamic.int)
|> should.equal(Error(json.UnexpectedEndOfInput))
}
pub fn decode_unexpected_byte_test() {
- json.decode("[}")
+ json.decode(from: "[}", using: dynamic.int)
|> should.equal(Error(json.UnexpectedByte("0x7D", 1)))
}
+pub fn decode_unexpected_format_test() {
+ json.decode(from: "[]", using: dynamic.int)
+ |> should.equal(Error(json.UnexpectedFormat([
+ dynamic.DecodeError(expected: "Int", found: "List", path: []),
+ ])))
+}
+
pub fn encode_string_test() {
json.string("hello")
|> should_encode("\"hello\"")