Commit a6f9cb85 authored by Milo Yip's avatar Milo Yip

Third trial on writer coverage

parent 3da4afd2
...@@ -136,47 +136,50 @@ TEST(SIMD, SIMD_SUFFIX(ScanCopyUnescapedString)) { ...@@ -136,47 +136,50 @@ TEST(SIMD, SIMD_SUFFIX(ScanCopyUnescapedString)) {
} }
TEST(SIMD, SIMD_SUFFIX(ScanWriteUnescapedString)) { TEST(SIMD, SIMD_SUFFIX(ScanWriteUnescapedString)) {
for (size_t step = 0; step < 1024; step++) { char buffer[2048 + 1 + 32];
char s[2048 + 1]; for (size_t offset = 0; offset < 32; offset++) {
char *p = s; for (size_t step = 0; step < 1024; step++) {
for (size_t i = 0; i < step; i++) char* s = buffer + offset;
*p++= "ABCD"[i % 4]; char* p = s;
char escape = "\0\n\\\""[step % 4]; for (size_t i = 0; i < step; i++)
*p++ = escape; *p++ = "ABCD"[i % 4];
for (size_t i = 0; i < step; i++) char escape = "\0\n\\\""[step % 4];
*p++= "ABCD"[i % 4]; *p++ = escape;
for (size_t i = 0; i < step; i++)
StringBuffer sb; *p++ = "ABCD"[i % 4];
Writer<StringBuffer> writer(sb);
writer.String(s, SizeType(step * 2 + 1)); StringBuffer sb;
const char* q = sb.GetString(); Writer<StringBuffer> writer(sb);
EXPECT_EQ('\"', *q++); writer.String(s, SizeType(step * 2 + 1));
for (size_t i = 0; i < step; i++) const char* q = sb.GetString();
EXPECT_EQ("ABCD"[i % 4], *q++); EXPECT_EQ('\"', *q++);
if (escape == '\0') { for (size_t i = 0; i < step; i++)
EXPECT_EQ('\\', *q++); EXPECT_EQ("ABCD"[i % 4], *q++);
EXPECT_EQ('u', *q++); if (escape == '\0') {
EXPECT_EQ('0', *q++); EXPECT_EQ('\\', *q++);
EXPECT_EQ('0', *q++); EXPECT_EQ('u', *q++);
EXPECT_EQ('0', *q++); EXPECT_EQ('0', *q++);
EXPECT_EQ('0', *q++); EXPECT_EQ('0', *q++);
} EXPECT_EQ('0', *q++);
else if (escape == '\n') { EXPECT_EQ('0', *q++);
EXPECT_EQ('\\', *q++); }
EXPECT_EQ('n', *q++); else if (escape == '\n') {
} EXPECT_EQ('\\', *q++);
else if (escape == '\\') { EXPECT_EQ('n', *q++);
EXPECT_EQ('\\', *q++); }
EXPECT_EQ('\\', *q++); else if (escape == '\\') {
} EXPECT_EQ('\\', *q++);
else if (escape == '\"') { EXPECT_EQ('\\', *q++);
EXPECT_EQ('\\', *q++); }
else if (escape == '\"') {
EXPECT_EQ('\\', *q++);
EXPECT_EQ('\"', *q++);
}
for (size_t i = 0; i < step; i++)
EXPECT_EQ("ABCD"[i % 4], *q++);
EXPECT_EQ('\"', *q++); EXPECT_EQ('\"', *q++);
EXPECT_EQ('\0', *q++);
} }
for (size_t i = 0; i < step; i++)
EXPECT_EQ("ABCD"[i % 4], *q++);
EXPECT_EQ('\"', *q++);
EXPECT_EQ('\0', *q++);
} }
} }
......
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