Skip to content

Commit 8f7f35c

Browse files
authored
Replace Raw Unicode in Testcase (open-source-parsers#1127)
* use unicode code point * change values' order, because JSONTEST_ASSERT_EQUAL(expected, actual)
1 parent 7e5485a commit 8f7f35c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/test_lib_json/main.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, StaticString) {
18191819

18201820
JSONTEST_FIXTURE_LOCAL(ValueTest, WideString) {
18211821
// https://github.com/open-source-parsers/jsoncpp/issues/756
1822-
const std::string uni = u8"式,进"; // "\u5f0f\uff0c\u8fdb"
1822+
const std::string uni = u8"\u5f0f\uff0c\u8fdb"; // "式,进"
18231823
std::string styled;
18241824
{
18251825
Json::Value v;
@@ -2655,13 +2655,13 @@ struct ReaderTest : JsonTest::TestCase {
26552655
void checkStructuredErrors(
26562656
const std::vector<Json::Reader::StructuredError>& actual,
26572657
const std::vector<Json::Reader::StructuredError>& expected) {
2658-
JSONTEST_ASSERT_EQUAL(actual.size(), expected.size());
2658+
JSONTEST_ASSERT_EQUAL(expected.size(), actual.size());
26592659
for (size_t i = 0; i < actual.size(); ++i) {
26602660
const auto& a = actual[i];
26612661
const auto& e = expected[i];
2662-
JSONTEST_ASSERT_EQUAL(a.offset_start, e.offset_start) << i;
2663-
JSONTEST_ASSERT_EQUAL(a.offset_limit, e.offset_limit) << i;
2664-
JSONTEST_ASSERT_EQUAL(a.message, e.message) << i;
2662+
JSONTEST_ASSERT_EQUAL(e.offset_start, a.offset_start) << i;
2663+
JSONTEST_ASSERT_EQUAL(e.offset_limit, a.offset_limit) << i;
2664+
JSONTEST_ASSERT_EQUAL(e.message, a.message) << i;
26652665
}
26662666
}
26672667

@@ -2682,7 +2682,7 @@ struct ReaderTest : JsonTest::TestCase {
26822682
const std::vector<Json::Reader::StructuredError>& structured,
26832683
const std::string& formatted) {
26842684
checkParse(input, structured);
2685-
JSONTEST_ASSERT_EQUAL(reader->getFormattedErrorMessages(), formatted);
2685+
JSONTEST_ASSERT_EQUAL(formatted, reader->getFormattedErrorMessages());
26862686
}
26872687

26882688
std::unique_ptr<Json::Reader> reader{new Json::Reader()};
@@ -2771,8 +2771,8 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, parseWithNoErrorsTestingOffsets) {
27712771
R"( "false" : false)"
27722772
R"( })");
27732773
auto checkOffsets = [&](const Json::Value& v, int start, int limit) {
2774-
JSONTEST_ASSERT_EQUAL(v.getOffsetStart(), start);
2775-
JSONTEST_ASSERT_EQUAL(v.getOffsetLimit(), limit);
2774+
JSONTEST_ASSERT_EQUAL(start, v.getOffsetStart());
2775+
JSONTEST_ASSERT_EQUAL(limit, v.getOffsetLimit());
27762776
};
27772777
checkOffsets(root, 0, 115);
27782778
checkOffsets(root["property"], 15, 34);
@@ -2817,9 +2817,8 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, strictModeParseNumber) {
28172817
}
28182818

28192819
JSONTEST_FIXTURE_LOCAL(ReaderTest, parseChineseWithOneError) {
2820-
// \u4f50\u85e4 佐藤
28212820
checkParse(R"({ "pr)"
2822-
"佐藤"
2821+
u8"\u4f50\u85e4" // 佐藤
28232822
R"(erty" :: "value" })",
28242823
{{18, 19, "Syntax error: value, object or array expected."}},
28252824
"* Line 1, Column 19\n Syntax error: value, object or array "
@@ -2921,7 +2920,7 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseString) {
29212920
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
29222921
JSONTEST_ASSERT(ok);
29232922
JSONTEST_ASSERT(errs.empty());
2924-
JSONTEST_ASSERT_EQUAL("", root[0].asString()); // "\u8A2a"
2923+
JSONTEST_ASSERT_EQUAL(u8"\u8A2a", root[0].asString()); // ""
29252924
}
29262925
{
29272926
char const doc[] = "[ \"\\uD801\" ]";
@@ -3633,8 +3632,8 @@ JSONTEST_FIXTURE_LOCAL(IteratorTest, distance) {
36333632
}
36343633
{
36353634
Json::Value empty;
3636-
JSONTEST_ASSERT_EQUAL(empty.end() - empty.end(), 0);
3637-
JSONTEST_ASSERT_EQUAL(empty.end() - empty.begin(), 0);
3635+
JSONTEST_ASSERT_EQUAL(0, empty.end() - empty.end());
3636+
JSONTEST_ASSERT_EQUAL(0, empty.end() - empty.begin());
36383637
}
36393638
}
36403639

0 commit comments

Comments
 (0)