remove pushError in CharReader (#1055)

This commit is contained in:
dota17
2019-10-24 06:31:25 +08:00
committed by Jordan Bayles
parent 54bd178bd8
commit 6c9408d128
2 changed files with 29 additions and 39 deletions

View File

@@ -2644,6 +2644,35 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, parseWithDetailError) {
JSONTEST_ASSERT(errors.at(0).message == "Bad escape sequence in string");
}
JSONTEST_FIXTURE_LOCAL(ReaderTest, pushErrorTest) {
Json::Reader reader;
Json::Value root;
{
bool ok = reader.parse("{ \"AUTHOR\" : 123 }", root);
JSONTEST_ASSERT(ok);
if (!root["AUTHOR"].isString()) {
ok = reader.pushError(root["AUTHOR"], "AUTHOR must be a string");
}
JSONTEST_ASSERT(ok);
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
"* Line 1, Column 14\n"
" AUTHOR must be a string\n");
}
{
bool ok = reader.parse("{ \"AUTHOR\" : 123 }", root);
JSONTEST_ASSERT(ok);
if (!root["AUTHOR"].isString()) {
ok = reader.pushError(root["AUTHOR"], "AUTHOR must be a string",
root["AUTHOR"]);
}
JSONTEST_ASSERT(ok);
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
"* Line 1, Column 14\n"
" AUTHOR must be a string\n"
"See Line 1, Column 14 for detail.\n");
}
}
struct CharReaderTest : JsonTest::TestCase {};
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithNoErrors) {