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
template <unsigned parseFlags, typename StreamType>
void TestScanCopyUnescapedString() {
for (size_t step = 0; step < 1024; step++) {
char json[1024 + 5];
char *p = json;
*p ++= '\"';
for (size_t i = 0; i < step; i++)
*p++= "ABCD"[i % 4];
*p++ = '\\';
*p++ = '\\';
*p++ = '\"';
*p++ = '\0';
StreamType s(json);
Reader reader;
ScanCopyUnescapedStringHandler h;
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]);
char buffer[1024 + 5 + 32];
for (size_t offset = 0; offset < 32; offset++) {
for (size_t step = 0; step < 1024; step++) {
char* json = buffer + offset;
char *p = json;
*p++ = '\"';
for (size_t i = 0; i < step; i++)
*p++ = "ABCD"[i % 4];
*p++ = '\\';
*p++ = '\\';
*p++ = '\"';
*p++ = '\0';
StreamType s(json);
Reader reader;
ScanCopyUnescapedStringHandler h;
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) {
StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(nan));
GenericStringBuffer<UTF16<> > buffer2;
Writer<GenericStringBuffer<UTF16<> > > writer2(buffer2);
EXPECT_FALSE(writer2.Double(nan));
}
TEST(Writer, Inf) {
......@@ -456,7 +460,7 @@ TEST(Writer, Inf) {
StringBuffer buffer;
{
Writer<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(inf));
EXPECT_FALSE(writer.Double(inf));
}
{
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