]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: virjson: Test parsing and formatting of strings with escaped chars
authorPeter Krempa <pkrempa@redhat.com>
Mon, 3 Jul 2017 14:39:21 +0000 (16:39 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 19 Jul 2017 15:59:09 +0000 (17:59 +0200)
Make sure that JSON strings can contain characters which need to be
escaped (double quotes, backslashes, tabs, etc.).

tests/virjsontest.c

index a6e158179645b41e7df987a1e86305aeb8813a32..d5a823431b6291b397951f79778043530e4e105b 100644 (file)
@@ -490,6 +490,10 @@ mymain(void)
     DO_TEST_PARSE("integer", "1", NULL);
     DO_TEST_PARSE("boolean", "true", NULL);
     DO_TEST_PARSE("null", "null", NULL);
+
+    DO_TEST_PARSE("escaping symbols", "[\"\\\"\\t\\n\\\\\"]", NULL);
+    DO_TEST_PARSE("escaped strings", "[\"{\\\"blurb\\\":\\\"test\\\"}\"]", NULL);
+
     DO_TEST_PARSE_FAIL("incomplete keyword", "tr");
     DO_TEST_PARSE_FAIL("overdone keyword", "[ truest ]");
     DO_TEST_PARSE_FAIL("unknown keyword", "huh");