Skip to content

Commit

Permalink
add makeCharReader test, fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
AssafPassalCG committed Aug 22, 2022
1 parent a5ef872 commit e90c3c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 1 addition & 4 deletions include/json/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ class JSON_API CharReader {
*/
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
Expand Down
13 changes: 13 additions & 0 deletions src/test_lib_json/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e90c3c3

Please sign in to comment.