u8 literal returns a char8_t in C++20

We now use reintepret_cast to cast char8_t's to a const char*, this can be done because char8_t's have the same size and alignment
This commit is contained in:
Troels Dalsgaard Hoffmeyer 2020-09-14 16:46:27 +02:00
parent bd16ebaee8
commit e9b24028d3

View File

@ -1817,7 +1817,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, StaticString) {
JSONTEST_FIXTURE_LOCAL(ValueTest, WideString) { JSONTEST_FIXTURE_LOCAL(ValueTest, WideString) {
// https://github.com/open-source-parsers/jsoncpp/issues/756 // https://github.com/open-source-parsers/jsoncpp/issues/756
const std::string uni = u8"\u5f0f\uff0c\u8fdb"; // "式,进" const std::string uni = reinterpret_cast<const char*>(u8"\u5f0f\uff0c\u8fdb"); // "式,进"
std::string styled; std::string styled;
{ {
Json::Value v; Json::Value v;
@ -2905,8 +2905,8 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, strictModeParseNumber) {
} }
JSONTEST_FIXTURE_LOCAL(ReaderTest, parseChineseWithOneError) { JSONTEST_FIXTURE_LOCAL(ReaderTest, parseChineseWithOneError) {
checkParse(R"({ "pr)" checkParse(R"({ "pr)" +
u8"\u4f50\u85e4" // 佐藤 std::string(reinterpret_cast<const char*>(u8"\u4f50\u85e4")) + // 佐藤
R"(erty" :: "value" })", R"(erty" :: "value" })",
{{18, 19, "Syntax error: value, object or array expected."}}, {{18, 19, "Syntax error: value, object or array expected."}},
"* Line 1, Column 19\n Syntax error: value, object or array " "* Line 1, Column 19\n Syntax error: value, object or array "
@ -3008,7 +3008,7 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseString) {
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs); bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
JSONTEST_ASSERT(ok); JSONTEST_ASSERT(ok);
JSONTEST_ASSERT(errs.empty()); JSONTEST_ASSERT(errs.empty());
JSONTEST_ASSERT_EQUAL(u8"\u8A2a", root[0].asString()); // "訪" JSONTEST_ASSERT_EQUAL((const char*)u8"\u8A2a", root[0].asString()); // "訪"
} }
{ {
char const doc[] = R"([ "\uD801" ])"; char const doc[] = R"([ "\uD801" ])";