diff options
author | Arun Raghavan <arun@arunraghavan.net> | 2016-06-01 17:18:33 +0530 |
---|---|---|
committer | Arun Raghavan <arun@arunraghavan.net> | 2016-06-22 21:04:47 +0530 |
commit | 708b4aac91ce8220480df6a34ccb491be2b8d490 (patch) | |
tree | a94059344fc9ad012faf1559a7556c4477ae3511 /src/tests | |
parent | c692ec3afdba560398fd9a6871cddcca6d5c9cc5 (diff) |
json: Correctly handle bad strings with missing closing quotes
Also add a test for this case.
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/json-test.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tests/json-test.c b/src/tests/json-test.c index 2e1ca6b92..7d273d70c 100644 --- a/src/tests/json-test.c +++ b/src/tests/json-test.c @@ -216,6 +216,18 @@ START_TEST(array_test) { } END_TEST +START_TEST(bad_test) { + unsigned int i; + const char *bad_parse[] = { + "\"" /* Quote not closed */, + }; + + for (i = 0; i < PA_ELEMENTSOF(bad_parse); i++) { + fail_unless(pa_json_parse(bad_parse[i]) == NULL); + } +} +END_TEST + int main(int argc, char *argv[]) { int failed = 0; Suite *s; @@ -231,6 +243,7 @@ int main(int argc, char *argv[]) { tcase_add_test(tc, bool_test); tcase_add_test(tc, object_test); tcase_add_test(tc, array_test); + tcase_add_test(tc, bad_test); suite_add_tcase(s, tc); sr = srunner_create(s); |