mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-14 01:47:54 +08:00
Add WideString test for Issue #756
This commit is contained in:
parent
101d4797db
commit
dd6921f479
@ -14,6 +14,8 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <json/config.h>
|
||||
#include <json/json.h>
|
||||
#include <limits>
|
||||
@ -1644,6 +1646,28 @@ JSONTEST_FIXTURE(ValueTest, StaticString) {
|
||||
}
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, WideString) {
|
||||
// https://github.com/open-source-parsers/jsoncpp/issues/756
|
||||
const std::string uni = u8"式,进"; // "\u5f0f\uff0c\u8fdb"
|
||||
std::string styled;
|
||||
{
|
||||
Json::Value v;
|
||||
v["abc"] = uni;
|
||||
styled = v.toStyledString();
|
||||
}
|
||||
Json::Value root;
|
||||
{
|
||||
JSONCPP_STRING errs;
|
||||
std::istringstream iss(styled);
|
||||
bool ok = parseFromStream(Json::CharReaderBuilder(), iss, &root, &errs);
|
||||
JSONTEST_ASSERT(ok);
|
||||
if (!ok) {
|
||||
std::cerr << "errs: " << errs << std::endl;
|
||||
}
|
||||
}
|
||||
JSONTEST_ASSERT_STRING_EQUAL(root["abc"].asString(), uni);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
Json::Value val; // fill val
|
||||
val.setComment(Json::String("// this comment should appear before"),
|
||||
@ -2556,6 +2580,7 @@ int main(int argc, const char* argv[]) {
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, StaticString);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, WideString);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, CommentBefore);
|
||||
// JSONTEST_REGISTER_FIXTURE(runner, ValueTest, nulls);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user