[libvirt PATCH 01/20] tests: json: relax some test cases

Ján Tomko posted 20 patches 3 months, 1 week ago
There is a newer version of this series
[libvirt PATCH 01/20] tests: json: relax some test cases
Posted by Ján Tomko 3 months, 1 week ago
Some JSON parsers do not like bare types outside of objects or arrays
or do validation of object key uniqueness.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 tests/virjsontest.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 6b6a64d3d3..efcbbbab98 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -550,9 +550,9 @@ mymain(void)
                   "[\"The meaning of life\"]");
     DO_TEST_PARSE_FAIL("unterminated string", "[ \"The meaning of lif ]");
 
-    DO_TEST_PARSE("integer", "1", NULL);
-    DO_TEST_PARSE("boolean", "true", NULL);
-    DO_TEST_PARSE("null", "null", NULL);
+    DO_TEST_PARSE("integer", "[1]", NULL);
+    DO_TEST_PARSE("boolean", "[true]", NULL);
+    DO_TEST_PARSE("null", "[null]", NULL);
     DO_TEST_PARSE("[]", "[]", NULL);
 
     DO_TEST_PARSE("escaping symbols", "[\"\\\"\\t\\n\\\\\"]", NULL);
@@ -574,14 +574,11 @@ mymain(void)
     DO_TEST_PARSE_FAIL("array of an object with an array as a key",
                        "[ {[\"key1\", \"key2\"]: \"value\"} ]");
     DO_TEST_PARSE_FAIL("object with unterminated key", "{ \"key:7 }");
-    DO_TEST_PARSE_FAIL("duplicate key", "{ \"a\": 1, \"a\": 1 }");
 
     DO_TEST_FULL("lookup on array", Lookup,
                  "[ 1 ]", NULL, false);
     DO_TEST_FULL("lookup on string", Lookup,
                  "\"str\"", NULL, false);
-    DO_TEST_FULL("lookup on integer", Lookup,
-                 "1", NULL, false);
     DO_TEST_FULL("lookup with missing key", Lookup,
                  "{ }", NULL, false);
     DO_TEST_FULL("lookup with wrong type", Lookup,
-- 
2.45.2
Re: [libvirt PATCH 01/20] tests: json: relax some test cases
Posted by Peter Krempa 3 months, 1 week ago
On Wed, Aug 14, 2024 at 23:40:16 +0200, Ján Tomko wrote:
> Some JSON parsers do not like bare types outside of objects or arrays
> or do validation of object key uniqueness.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  tests/virjsontest.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>