* [PATCH 8/8] unit: add test for nested arrays
@ 2022-01-05 18:46 James Prestwood
0 siblings, 0 replies; only message in thread
From: James Prestwood @ 2022-01-05 18:46 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1382 bytes --]
These are not yet supported, but test anyway to ensure iteration
does not work and doesn't result in any unexpected behavior.
---
unit/test-json.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/unit/test-json.c b/unit/test-json.c
index 52e3f675..5ffd36ec 100644
--- a/unit/test-json.c
+++ b/unit/test-json.c
@@ -424,6 +424,27 @@ static void test_json_arrays(const void *data)
json_contents_free(c);
}
+static void test_json_nested_arrays(const void *data)
+{
+ char json[] = "{\"array\":[[1, 2], [3, 4]]}";
+ int count = 0;
+ struct json_iter iter;
+ struct json_iter array;
+ struct json_contents *c = json_contents_new(json, strlen(json));
+
+ json_iter_init(&iter, c);
+ assert(json_iter_parse(&iter,
+ JSON_MANDATORY("array", JSON_ARRAY, &array),
+ JSON_UNDEFINED));
+
+ while (json_iter_next(&array))
+ count++;
+
+ assert(count == 0);
+
+ json_contents_free(c);
+}
+
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
@@ -436,6 +457,7 @@ int main(int argc, char *argv[])
l_test_add("json larger object", test_json_larger_object, NULL);
l_test_add("json test primitives", test_json_primitives, NULL);
l_test_add("json test arrays", test_json_arrays, NULL);
+ l_test_add("json test nested arrays", test_json_nested_arrays, NULL);
return l_test_run();
}
--
2.31.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-05 18:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-05 18:46 [PATCH 8/8] unit: add test for nested arrays James Prestwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox