aboutsummaryrefslogtreecommitdiff
path: root/test/gleam_json_test.gleam
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2024-05-23 19:24:29 +0100
committerLouis Pilfold <louis@lpil.uk>2024-05-23 19:32:48 +0100
commit9753cfad7d937c42db64baee5b9cc818effe984b (patch)
tree62f4aa9582a2c3d60ca832bbccb1160d5c124822 /test/gleam_json_test.gleam
parent1979919b792910e6c75f3e28596f017d980b45ee (diff)
downloadgleam_json-9753cfad7d937c42db64baee5b9cc818effe984b.tar.gz
gleam_json-9753cfad7d937c42db64baee5b9cc818effe984b.zip
Encoding also!
Diffstat (limited to 'test/gleam_json_test.gleam')
-rw-r--r--test/gleam_json_test.gleam16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam
index fcc4a62..e2f3542 100644
--- a/test/gleam_json_test.gleam
+++ b/test/gleam_json_test.gleam
@@ -93,6 +93,17 @@ pub fn encode_object_test() {
|> should_encode("{\"foo\":5}")
}
+pub fn encode_empty_object_test() {
+ json.object([])
+ |> should_encode("{}")
+}
+
+pub fn encode_empty_array_test() {
+ []
+ |> json.array(of: json.int)
+ |> should_encode("[]")
+}
+
pub fn encode_array_test() {
[5, 6, 1, 4]
|> json.array(of: json.int)
@@ -104,6 +115,11 @@ pub fn encode_preprocessed_array_test() {
|> should_encode("[5,6]")
}
+pub fn encode_empty_preprocessed_array_test() {
+ json.preprocessed_array([])
+ |> should_encode("[]")
+}
+
pub fn encode_nullable_some_test() {
json.nullable(Some(5), of: json.int)
|> should_encode("5")