Improve comment parsing code coverage

This commit is contained in:
Milo Yip 2016-02-03 09:32:34 +08:00
parent efe4140208
commit b8a273705e

View File

@ -1459,6 +1459,26 @@ TEST(Reader, IncompleteMultilineComment) {
EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode());
}
TEST(Reader, IncompleteMultilineComment2) {
const char* json = "{\"hello\" : \"world\" /* *\0 */}";
StringStream s(json);
ParseObjectHandler h;
Reader reader;
EXPECT_FALSE(reader.Parse<kParseCommentsFlag>(s, h));
EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode());
}
TEST(Reader, UnrecognizedComment) {
const char* json = "{\"hello\" : \"world\" /! }";
StringStream s(json);
ParseObjectHandler h;
Reader reader;
EXPECT_FALSE(reader.Parse<kParseCommentsFlag>(s, h));
EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode());
}
#ifdef __GNUC__
RAPIDJSON_DIAG_POP
#endif