Commit 3c6e2cf0 authored by Alejandro Martinez's avatar Alejandro Martinez

Added unittests for invalid ascii control chars

parent da4fd679
...@@ -725,6 +725,8 @@ TEST(Reader, ParseString_Error) { ...@@ -725,6 +725,8 @@ TEST(Reader, ParseString_Error) {
// Malform ASCII sequence // Malform ASCII sequence
TEST_STRINGENCODING_ERROR(ASCII<>, UTF8<>, char, ARRAY('[', '\"', char(0x80u), '\"', ']', '\0')); TEST_STRINGENCODING_ERROR(ASCII<>, UTF8<>, char, ARRAY('[', '\"', char(0x80u), '\"', ']', '\0'));
TEST_STRINGENCODING_ERROR(ASCII<>, UTF8<>, char, ARRAY('[', '\"', char(0x01u), '\"', ']', '\0'));
TEST_STRINGENCODING_ERROR(ASCII<>, UTF8<>, char, ARRAY('[', '\"', char(0x1Cu), '\"', ']', '\0'));
#undef ARRAY #undef ARRAY
#undef TEST_STRINGARRAY_ERROR #undef TEST_STRINGARRAY_ERROR
......
...@@ -401,6 +401,16 @@ TEST(Writer, InvalidEncoding) { ...@@ -401,6 +401,16 @@ TEST(Writer, InvalidEncoding) {
static const UTF32<>::Ch s[] = { 0x110000, 0 }; // Out of U+0000 to U+10FFFF static const UTF32<>::Ch s[] = { 0x110000, 0 }; // Out of U+0000 to U+10FFFF
EXPECT_FALSE(writer.String(s)); EXPECT_FALSE(writer.String(s));
} }
// Fail in decoding invalid ASCII control bytes
{
GenericStringBuffer<UTF16<> > buffer;
Writer<GenericStringBuffer<UTF16<> >, UTF8<>, UTF16<> > writer(buffer);
writer.StartArray();
EXPECT_FALSE(writer.String("\x01"));
EXPECT_FALSE(writer.String("\x1C"));
writer.EndArray();
}
} }
TEST(Writer, ValidateEncoding) { TEST(Writer, ValidateEncoding) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment