Commit 998e76fe authored by Milo Yip's avatar Milo Yip

Improves SkipWhitespace coverage

parent ee505261
...@@ -46,16 +46,18 @@ using namespace rapidjson_simd; ...@@ -46,16 +46,18 @@ using namespace rapidjson_simd;
#endif #endif
TEST(SIMD, SIMD_SUFFIX(SkipWhitespace)) { TEST(SIMD, SIMD_SUFFIX(SkipWhitespace)) {
char buffer[258]; char buffer[257];
for (size_t i = 0; i < 256; i++) for (size_t i = 0; i < 256; i++)
buffer[i] = " \t\r\n"[i % 4]; buffer[i] = " \t\r\n"[i % 4];
buffer[256] = 'X'; for (size_t i = 0; i < 256; i += 15)
buffer[257] = '\0'; buffer[i] = 'X';
buffer[256] = '\0';
// Try to start from different position, to test different memory alignments StringStream s(buffer);
for (size_t i = 0; i < 256; i++) { for(;;) {
StringStream s(buffer + i);
SkipWhitespace(s); SkipWhitespace(s);
EXPECT_EQ('X', s.Peek()); if (s.Peek() == '\0')
break;
EXPECT_EQ('X', s.Take());
} }
} }
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