From b8a273705e0df868658e818864b00fb83d24dcca Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Wed, 3 Feb 2016 09:32:34 +0800 Subject: [PATCH] Improve comment parsing code coverage --- test/unittest/readertest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 49888a9..61fd95c 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -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(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(s, h)); + EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode()); +} + #ifdef __GNUC__ RAPIDJSON_DIAG_POP #endif