未验证 提交 a74ceb43 编写于 作者: N Nikolay Baklicharov 提交者: GitHub

Windows tab escape testing with custom locale (#1190)

上级 b395975b
......@@ -2702,6 +2702,34 @@ JSONTEST_FIXTURE_LOCAL(StreamWriterTest, escapeControlCharacters) {
}
}
#ifdef _WIN32
JSONTEST_FIXTURE_LOCAL(StreamWriterTest, escapeTabCharacterWindows) {
// Get the current locale before changing it
std::string currentLocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "English_United States.1252");
Json::Value root;
root["test"] = "\tTabTesting\t";
Json::StreamWriterBuilder b;
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"test\" : "
"\"\\tTabTesting\\t\"\n}");
b.settings_["emitUTF8"] = true;
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"test\" : "
"\"\\tTabTesting\\t\"\n}");
b.settings_["emitUTF8"] = false;
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"test\" : "
"\"\\tTabTesting\\t\"\n}");
// Restore the locale
if (!currentLocale.empty())
setlocale(LC_ALL, currentLocale.c_str());
}
#endif
struct ReaderTest : JsonTest::TestCase {
void setStrictMode() {
reader = std::unique_ptr<Json::Reader>(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册