Skip to content

Commit 0b6a3a5

Browse files
committed
fix test by stopping early enough to punt on utf8-input.
1 parent c158322 commit 0b6a3a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/test_lib_json/main.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,20 +2678,26 @@ JSONTEST_FIXTURE_LOCAL(StreamWriterTest, escapeControlCharacters) {
26782678
b.settings_["emitUTF8"] = emitUTF8;
26792679

26802680
for (unsigned i = 0; i != 0x100; ++i) {
2681+
if (!emitUTF8 && i >= 0x80)
2682+
break; // The algorithm would try to parse UTF-8, so stop here.
2683+
26812684
std::string raw({static_cast<char>(i)});
26822685
std::string esc = raw;
26832686
if (i < 0x20)
26842687
esc = uEscape(i);
26852688
if (const char* shEsc = shortEscape(i))
26862689
esc = shEsc;
2687-
if (!emitUTF8 && i >= 0x80)
2688-
esc = uEscape(i);
2690+
2691+
// std::cout << "emit=" << emitUTF8 << ", i=" << std::hex << i << std::dec
2692+
// << std::endl;
26892693

26902694
Json::Value root;
26912695
root["test"] = raw;
26922696
JSONTEST_ASSERT_STRING_EQUAL(
26932697
std::string("{\n\t\"test\" : \"").append(esc).append("\"\n}"),
2694-
Json::writeString(b, root));
2698+
Json::writeString(b, root))
2699+
<< ", emit=" << emitUTF8 << ", i=" << i << ", raw=\"" << raw << "\""
2700+
<< ", esc=\"" << esc << "\"";
26952701
}
26962702
}
26972703
}

0 commit comments

Comments
 (0)