Commit 3da4afd2 authored by Milo Yip's avatar Milo Yip

Another trial on writer coverage

parent 8fcc65bf
...@@ -105,24 +105,28 @@ struct ScanCopyUnescapedStringHandler : BaseReaderHandler<UTF8<>, ScanCopyUnesca ...@@ -105,24 +105,28 @@ struct ScanCopyUnescapedStringHandler : BaseReaderHandler<UTF8<>, ScanCopyUnesca
template <unsigned parseFlags, typename StreamType> template <unsigned parseFlags, typename StreamType>
void TestScanCopyUnescapedString() { void TestScanCopyUnescapedString() {
for (size_t step = 0; step < 1024; step++) { char buffer[1024 + 5 + 32];
char json[1024 + 5];
char *p = json; for (size_t offset = 0; offset < 32; offset++) {
*p ++= '\"'; for (size_t step = 0; step < 1024; step++) {
for (size_t i = 0; i < step; i++) char* json = buffer + offset;
*p++= "ABCD"[i % 4]; char *p = json;
*p++ = '\\'; *p++ = '\"';
*p++ = '\\'; for (size_t i = 0; i < step; i++)
*p++ = '\"'; *p++ = "ABCD"[i % 4];
*p++ = '\0'; *p++ = '\\';
*p++ = '\\';
StreamType s(json); *p++ = '\"';
Reader reader; *p++ = '\0';
ScanCopyUnescapedStringHandler h;
reader.Parse<parseFlags>(s, h); StreamType s(json);
EXPECT_TRUE(memcmp(h.buffer, json + 1, step) == 0); Reader reader;
EXPECT_EQ('\\', h.buffer[step]); // escaped ScanCopyUnescapedStringHandler h;
EXPECT_EQ('\0', h.buffer[step + 1]); reader.Parse<parseFlags>(s, h);
EXPECT_TRUE(memcmp(h.buffer, json + 1, step) == 0);
EXPECT_EQ('\\', h.buffer[step]); // escaped
EXPECT_EQ('\0', h.buffer[step + 1]);
}
} }
} }
......
...@@ -448,6 +448,10 @@ TEST(Writer, NaN) { ...@@ -448,6 +448,10 @@ TEST(Writer, NaN) {
StringBuffer buffer; StringBuffer buffer;
Writer<StringBuffer> writer(buffer); Writer<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(nan)); EXPECT_FALSE(writer.Double(nan));
GenericStringBuffer<UTF16<> > buffer2;
Writer<GenericStringBuffer<UTF16<> > > writer2(buffer2);
EXPECT_FALSE(writer2.Double(nan));
} }
TEST(Writer, Inf) { TEST(Writer, Inf) {
...@@ -456,7 +460,7 @@ TEST(Writer, Inf) { ...@@ -456,7 +460,7 @@ TEST(Writer, Inf) {
StringBuffer buffer; StringBuffer buffer;
{ {
Writer<StringBuffer> writer(buffer); Writer<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(inf)); EXPECT_FALSE(writer.Double(inf));
} }
{ {
Writer<StringBuffer> writer(buffer); Writer<StringBuffer> writer(buffer);
......
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