From 6821a758373686042096a3b54f39743532c32aaa Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Sat, 5 Feb 2022 09:37:37 +0000 Subject: decode_bits --- test/gleam_json_test.gleam | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/gleam_json_test.gleam') 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\"") -- cgit v1.2.3