diff options
author | Serge Zaitsev <zaitsev.serge@gmail.com> | 2016-10-12 17:09:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 17:09:07 +0800 |
commit | 1682c32e9ae5990ddd0f0e907270a0f6dde5cbe9 (patch) | |
tree | f51130a2de677962d35f47b6c1c150e344504050 /test | |
parent | 0f574ea35becadb10f302795a5ffbc0b8bda8934 (diff) | |
parent | c3131d05a6db72c1ddefb1ad4c95ddbc604d1fa6 (diff) |
Merge pull request #94 from pt300/master
Fix for no error with unmatched closing bracket with PARENT_LINKS
Diffstat (limited to 'test')
-rw-r--r-- | test/tests.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/tests.c b/test/tests.c index a72689ec0..d5f0c5300 100644 --- a/test/tests.c +++ b/test/tests.c @@ -357,6 +357,25 @@ int test_nonstrict(void) { return 0; } +int test_unmatched_brackets(void) { + const char *js; + js = "\"key 1\": 1234}"; + check(parse(js, JSMN_ERROR_INVAL, 2)); + js = "{\"key 1\": 1234"; + check(parse(js, JSMN_ERROR_PART, 3)); + js = "{\"key 1\": 1234}}"; + check(parse(js, JSMN_ERROR_INVAL, 3)); + js = "\"key 1\"}: 1234"; + check(parse(js, JSMN_ERROR_INVAL, 3)); + js = "\"key {1\": 1234"; + check(parse(js, 2, 2, + JSMN_STRING, "key {1", 1, + JSMN_PRIMITIVE, "1234")); + js = "{{\"key 1\": 1234}"; + check(parse(js, JSMN_ERROR_PART, 4)); + return 0; +} + int main(void) { test(test_empty, "test for a empty JSON objects/arrays"); test(test_object, "test for a JSON objects"); @@ -373,6 +392,7 @@ int main(void) { test(test_issue_27, "test issue #27"); test(test_count, "test tokens count estimation"); test(test_nonstrict, "test for non-strict mode"); + test(test_unmatched_brackets, "test for unmatched brackets"); printf("\nPASSED: %d\nFAILED: %d\n", test_passed, test_failed); return (test_failed > 0); } |