mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-06 00:31:10 +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;
|
Value numberName;
|
||||||
if (!decodeNumber(tokenName, numberName))
|
if (!decodeNumber(tokenName, numberName))
|
||||||
return recoverFromError(tokenObjectEnd);
|
return recoverFromError(tokenObjectEnd);
|
||||||
name = String(numberName.asCString());
|
name = numberName.asString();
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2648,6 +2648,10 @@ struct ReaderTest : JsonTest::TestCase {
|
|||||||
new Json::Reader(Json::Features{}.strictMode()));
|
new Json::Reader(Json::Features{}.strictMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFeatures(Json::Features& features) {
|
||||||
|
reader = std::unique_ptr<Json::Reader>(new Json::Reader(features));
|
||||||
|
}
|
||||||
|
|
||||||
void checkStructuredErrors(
|
void checkStructuredErrors(
|
||||||
const std::vector<Json::Reader::StructuredError>& actual,
|
const std::vector<Json::Reader::StructuredError>& actual,
|
||||||
const std::vector<Json::Reader::StructuredError>& expected) {
|
const std::vector<Json::Reader::StructuredError>& expected) {
|
||||||
@ -2851,6 +2855,13 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, pushErrorTest) {
|
|||||||
"See Line 1, Column 14 for detail.\n");
|
"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 {};
|
struct CharReaderTest : JsonTest::TestCase {};
|
||||||
|
|
||||||
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithNoErrors) {
|
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithNoErrors) {
|
||||||
|
Loading…
Reference in New Issue
Block a user