From e90c3c3303bb69f3b51c48d3dd81033828246fa9 Mon Sep 17 00:00:00 2001 From: Assaf Passal Date: Mon, 22 Aug 2022 10:38:08 +0300 Subject: [PATCH] add makeCharReader test, fix spelling --- include/json/reader.h | 5 +---- src/test_lib_json/main.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/json/reader.h b/include/json/reader.h index 2a134405d..dd86d64eb 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -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 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 makeCharReader() const; }; // Factory }; // CharReader diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index d0f5364ac..cafca3223 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -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) {