mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
add tests of json parser
This commit is contained in:
parent
6dd75f3797
commit
d71f24504b
@ -210,7 +210,7 @@ wf_impl_json_parse_array(
|
|||||||
}
|
}
|
||||||
} while ((result) && (',' == c));
|
} while ((result) && (',' == c));
|
||||||
|
|
||||||
if ((result) && (']' != c))
|
if (']' != c)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -272,9 +272,9 @@ wf_impl_json_parse_object(
|
|||||||
wf_impl_json_reader_skip_whitespace(reader);
|
wf_impl_json_reader_skip_whitespace(reader);
|
||||||
c = wf_impl_json_reader_get_char(reader);
|
c = wf_impl_json_reader_get_char(reader);
|
||||||
}
|
}
|
||||||
} while ((reader) && (',' == c));
|
} while ((result) && (',' == c));
|
||||||
|
|
||||||
if ((reader) && ('}' != c))
|
if ('}' != c)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,16 @@ TEST(json_parser, fail_unterminated_array)
|
|||||||
ASSERT_FALSE(try_parse("[1"));
|
ASSERT_FALSE(try_parse("[1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(json_parser, fail_missing_array_separator)
|
||||||
|
{
|
||||||
|
ASSERT_FALSE(try_parse("[1 2]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(json_parser, fail_missing_array_value)
|
||||||
|
{
|
||||||
|
ASSERT_FALSE(try_parse("[1,]"));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(json_parser, empty_object)
|
TEST(json_parser, empty_object)
|
||||||
{
|
{
|
||||||
ASSERT_TRUE(try_parse("{}"));
|
ASSERT_TRUE(try_parse("{}"));
|
||||||
@ -101,3 +111,13 @@ TEST(json_parser, fail_missing_object_value)
|
|||||||
{
|
{
|
||||||
ASSERT_FALSE(try_parse("{\"a\":}"));
|
ASSERT_FALSE(try_parse("{\"a\":}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(json_parser, fail_missing_object_separator)
|
||||||
|
{
|
||||||
|
ASSERT_FALSE(try_parse("{\"a\":1 \"b\":2}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(json_parser, fail_missing_object_item)
|
||||||
|
{
|
||||||
|
ASSERT_FALSE(try_parse("{\"a\":1,}"));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user