1 parent
44c2382402
commit
2075bec60f
2 files changed
+14
No files matched your search
@@ -101,6 +101,14 @@ static void run_jq_tests(FILE *testdata) {
|
|||||||
|
|
||||||
|
|
||||||
static void jv_test() {
|
static void jv_test() {
|
||||||
|
/// JSON parser regression tests
|
||||||
|
{
|
||||||
|
jv v = jv_parse("{\"a':\"12\"}");
|
||||||
|
assert(jv_get_kind(v) == JV_KIND_INVALID);
|
||||||
|
v = jv_invalid_get_msg(v);
|
||||||
|
assert(strcmp(jv_string_value(v), "Expected separator between values at line 1, column 9 (while parsing '{\"a':\"12\"}')") == 0);
|
||||||
|
jv_free(v);
|
||||||
|
}
|
||||||
/// Arrays and numbers
|
/// Arrays and numbers
|
||||||
{
|
{
|
||||||
jv a = jv_array();
|
jv a = jv_array();
|
||||||
|
|||||||
@@ -456,9 +456,15 @@ jv jv_parser_next(struct jv_parser* p) {
|
|||||||
} else if (msg) {
|
} else if (msg) {
|
||||||
parser_reset(p);
|
parser_reset(p);
|
||||||
if (ch != '\036' && (p->flags & JV_PARSE_SEQ)) {
|
if (ch != '\036' && (p->flags & JV_PARSE_SEQ)) {
|
||||||
|
// Skip to the next RS
|
||||||
p->st = JV_PARSER_WAITING_FOR_RS;
|
p->st = JV_PARSER_WAITING_FOR_RS;
|
||||||
return jv_invalid_with_msg(jv_string_fmt("%s at line %d, column %d (need RS to resync)", msg, p->line, p->column));
|
return jv_invalid_with_msg(jv_string_fmt("%s at line %d, column %d (need RS to resync)", msg, p->line, p->column));
|
||||||
}
|
}
|
||||||
|
if (!(p->flags & JV_PARSE_SEQ)) {
|
||||||
|
// We're not parsing a JSON text sequence; throw this buffer away.
|
||||||
|
p->curr_buf = 0;
|
||||||
|
p->curr_buf_pos = 0;
|
||||||
|
} // Else ch must be RS; don't clear buf so we can start parsing again after this ch
|
||||||
return jv_invalid_with_msg(jv_string_fmt("%s at line %d, column %d", msg, p->line, p->column));
|
return jv_invalid_with_msg(jv_string_fmt("%s at line %d, column %d", msg, p->line, p->column));
|
||||||
} else if (p->curr_buf_is_partial) {
|
} else if (p->curr_buf_is_partial) {
|
||||||
assert(p->curr_buf_pos == p->curr_buf_length);
|
assert(p->curr_buf_pos == p->curr_buf_length);
|
||||||
|
|||||||
Reference in new issue
Block a user