add makeCharReader test, fix spelling

This commit is contained in:
Assaf Passal 2022-08-22 10:38:08 +03:00
parent a5ef87288e
commit e90c3c3303
2 changed files with 14 additions and 4 deletions

View File

@ -272,10 +272,7 @@ public:
*/
virtual CharReader* newCharReader() const = 0;
/** \brief Allocate a CharReader via newCharReader().
* wrap the object in std::unique_ptr<CharReader> to esnure deletion.
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
/** Wrap newCharReader's result in a std::unique_ptr. Throws if newCharReader throws. */
std::unique_ptr<CharReader> makeCharReader() const;
}; // Factory
}; // CharReader

View File

@ -2990,6 +2990,19 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, allowNumericKeysTest) {
checkParse(R"({ 123 : "abc" })");
}
struct UniqueReaderTest : JsonTest::TestCase {};
JSONTEST_FIXTURE_LOCAL(UniqueReaderTest, parseWithNoErrors) {
Json::CharReaderBuilder b;
CharReaderPtr reader = b.makeCharReader();
Json::String errs;
Json::Value root;
char const doc[] = R"({ "property" : "value" })";
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
JSONTEST_ASSERT(ok);
JSONTEST_ASSERT(errs.empty());
}
struct CharReaderTest : JsonTest::TestCase {};
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithNoErrors) {