mirror of
https://github.com/google/googletest.git
synced 2026-10-28 18:07:18 +08:00
Merge pull request #5082 from Muszic:fix-json-utf8-output
PiperOrigin-RevId: 978191552 Change-Id: I2744f219171a97622333f7b84aa76f78dd63e975
This commit is contained in:
commit
7e91a413e8
@ -4648,7 +4648,7 @@ std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) {
|
|||||||
m << "\\r";
|
m << "\\r";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (ch < ' ') {
|
if (static_cast<unsigned char>(ch) < ' ' || ch == '\x7F') {
|
||||||
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
|
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
|
||||||
} else {
|
} else {
|
||||||
m << ch;
|
m << ch;
|
||||||
|
|||||||
@ -336,7 +336,7 @@ EXPECTED_NON_EMPTY = {
|
|||||||
'time': '*',
|
'time': '*',
|
||||||
'timestamp': '*',
|
'timestamp': '*',
|
||||||
'classname': 'PropertyRecordingTest',
|
'classname': 'PropertyRecordingTest',
|
||||||
'key_1': '1',
|
'key_1': '\u007f!caf\u00e9 \u4e2d',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'IntValuedProperty',
|
'name': 'IntValuedProperty',
|
||||||
@ -878,7 +878,7 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|||||||
'the expected exit code %s.'
|
'the expected exit code %s.'
|
||||||
% (command, p.exit_code, expected_exit_code),
|
% (command, p.exit_code, expected_exit_code),
|
||||||
)
|
)
|
||||||
with open(json_path) as f:
|
with open(json_path, encoding='utf-8') as f:
|
||||||
actual = json.load(f)
|
actual = json.load(f)
|
||||||
return actual
|
return actual
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ It is good practice to tell why you skip a test.
|
|||||||
</properties>
|
</properties>
|
||||||
<testcase name="OneProperty" file="gtest_xml_output_unittest_.cc" line="125" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
|
<testcase name="OneProperty" file="gtest_xml_output_unittest_.cc" line="125" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="key_1" value="1"/>
|
<property name="key_1" value="\u007f!caf\u00e9 \u4e2d"/>
|
||||||
</properties>
|
</properties>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="129" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
|
<testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="129" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class PropertyRecordingTest : public Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(PropertyRecordingTest, OneProperty) {
|
TEST_F(PropertyRecordingTest, OneProperty) {
|
||||||
RecordProperty("key_1", "1");
|
RecordProperty("key_1", "\x7F!caf\xC3\xA9 \xE4\xB8\xAD");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PropertyRecordingTest, IntValuedProperty) {
|
TEST_F(PropertyRecordingTest, IntValuedProperty) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user