mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 10:03:51 +01:00
fix Reader bug and add testcase (#1122)
This commit is contained in:
parent
d6c4a8fb2d
commit
92d90250f2
@ -467,7 +467,7 @@ bool Reader::readObject(Token& token) {
|
||||
Value numberName;
|
||||
if (!decodeNumber(tokenName, numberName))
|
||||
return recoverFromError(tokenObjectEnd);
|
||||
name = String(numberName.asCString());
|
||||
name = numberName.asString();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -2648,6 +2648,10 @@ struct ReaderTest : JsonTest::TestCase {
|
||||
new Json::Reader(Json::Features{}.strictMode()));
|
||||
}
|
||||
|
||||
void setFeatures(Json::Features& features) {
|
||||
reader = std::unique_ptr<Json::Reader>(new Json::Reader(features));
|
||||
}
|
||||
|
||||
void checkStructuredErrors(
|
||||
const std::vector<Json::Reader::StructuredError>& actual,
|
||||
const std::vector<Json::Reader::StructuredError>& expected) {
|
||||
@ -2851,6 +2855,13 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, pushErrorTest) {
|
||||
"See Line 1, Column 14 for detail.\n");
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(ReaderTest, allowNumericKeysTest) {
|
||||
Json::Features features;
|
||||
features.allowNumericKeys_ = true;
|
||||
setFeatures(features);
|
||||
checkParse(R"({ 123 : "abc" })");
|
||||
}
|
||||
|
||||
struct CharReaderTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithNoErrors) {
|
||||
|
Loading…
Reference in New Issue
Block a user