aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2022-02-05 09:37:37 +0000
committerLouis Pilfold <louis@lpil.uk>2022-02-05 09:37:37 +0000
commit6821a758373686042096a3b54f39743532c32aaa (patch)
tree35993985463cd39b62807e34d8a59f39c276a87d /test
parentce5c3bbbd7f4ed811f9bbaadce05165fe483c4f6 (diff)
downloadgleam_json-6821a758373686042096a3b54f39743532c32aaa.tar.gz
gleam_json-6821a758373686042096a3b54f39743532c32aaa.zip
decode_bits
Diffstat (limited to 'test')
-rw-r--r--test/gleam_json_test.gleam22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam
index fb55c90..6460e51 100644
--- a/test/gleam_json_test.gleam
+++ b/test/gleam_json_test.gleam
@@ -32,6 +32,28 @@ pub fn decode_unexpected_format_test() {
])))
}
+pub fn decode_bits_test() {
+ json.decode_bits(from: <<"5":utf8>>, using: dynamic.int)
+ |> should.equal(Ok(5))
+}
+
+pub fn decode_bits_empty_test() {
+ json.decode_bits(from: <<"":utf8>>, using: dynamic.int)
+ |> should.equal(Error(json.UnexpectedEndOfInput))
+}
+
+pub fn decode_bits_unexpected_byte_test() {
+ json.decode_bits(from: <<"[}":utf8>>, using: dynamic.int)
+ |> should.equal(Error(json.UnexpectedByte("0x7D", 1)))
+}
+
+pub fn decode_bits_unexpected_format_test() {
+ json.decode_bits(from: <<"[]":utf8>>, 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\"")