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

@@ -37,7 +37,7 @@ void JsonDefaultTest(const std::string& tests_data_path) {
FinishMonsterBuffer(builder, color_monster.Finish());
std::string jsongen;
auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
TEST_EQ(result, true);
TEST_NULL(result);
// default value of the "color" field is Blue
TEST_EQ(std::string::npos != jsongen.find("color: \"Blue\""), true);
// default value of the "testf" field is 3.14159
@@ -66,7 +66,7 @@ void JsonEnumsTest(const std::string& tests_data_path) {
FinishMonsterBuffer(builder, color_monster.Finish());
std::string jsongen;
auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
TEST_EQ(result, true);
TEST_NULL(result);
TEST_EQ(std::string::npos != jsongen.find("color: \"Red Blue\""), true);
// Test forward compatibility with 'output_enum_identifiers = true'.
// Current Color doesn't have '(1u << 2)' field, let's add it.
@@ -79,7 +79,7 @@ void JsonEnumsTest(const std::string& tests_data_path) {
static_cast<Color>((1u << 2) | Color_Blue | Color_Red));
FinishMonsterBuffer(builder, future_color.Finish());
result = GenerateText(parser, builder.GetBufferPointer(), &future_json);
TEST_EQ(result, true);
TEST_NULL(result);
TEST_EQ(std::string::npos != future_json.find("color: 13"), true);
}
@@ -120,7 +120,7 @@ void JsonOptionalTest(const std::string& tests_data_path, bool default_scalars)
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());
}
@@ -199,7 +199,7 @@ root_type JsonUnionStructTest;
std::string json_generated;
auto generate_result =
GenerateText(parser, parser.builder_.GetBufferPointer(), &json_generated);
TEST_EQ(true, generate_result);
TEST_NULL(generate_result);
TEST_EQ_STR(json_source, json_generated.c_str());
}