GenerateText gives text error on failure

This commit is contained in:
Wouter van Oortmerssen
2023-05-03 13:03:00 -07:00
parent c1e7aee489
commit ed11b08fc9
14 changed files with 122 additions and 112 deletions

View File

@@ -626,7 +626,7 @@ void TestMonsterExtraFloats(const std::string &tests_data_path) {
TEST_EQ(def_extra->d3(), -infinity_d);
std::string jsongen;
auto result = GenerateText(parser, def_obj, &jsongen);
TEST_EQ(result, true);
TEST_NULL(result);
// Check expected default values.
TEST_EQ(std::string::npos != jsongen.find("f0: nan"), true);
TEST_EQ(std::string::npos != jsongen.find("f1: nan"), true);
@@ -777,7 +777,7 @@ void ParseAndGenerateTextTest(const std::string &tests_data_path, bool binary) {
std::string jsongen;
auto result =
GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
TEST_EQ(result, true);
TEST_NULL(result);
TEST_EQ_STR(jsongen.c_str(), jsonfile.c_str());
// We can also do the above using the convenient Registry that knows about
@@ -815,9 +815,8 @@ void ParseAndGenerateTextTest(const std::string &tests_data_path, bool binary) {
// request natural printing for utf-8 strings
parser.opts.natural_utf8 = true;
parser.opts.strict_json = true;
TEST_EQ(
GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen_utf8),
true);
TEST_NULL(
GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen_utf8));
TEST_EQ_STR(jsongen_utf8.c_str(), jsonfile_utf8.c_str());
}