mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-10 15:16:28 +00:00
Added way to test two schemas for safe evolution.
Change-Id: I1dfc867e6df5932ab61dad431eb3cb02f15d04df Tested: on Linux. Bug: 30202327
This commit is contained in:
@@ -1060,6 +1060,24 @@ void ParseUnionTest() {
|
||||
"{ X:{ A:1 }, X_type: T }"), true);
|
||||
}
|
||||
|
||||
void ConformTest() {
|
||||
flatbuffers::Parser parser;
|
||||
TEST_EQ(parser.Parse("table T { A:int; } enum E:byte { A }"), true);
|
||||
|
||||
auto test_conform = [&](const char *test, const char *expected_err) {
|
||||
flatbuffers::Parser parser2;
|
||||
TEST_EQ(parser2.Parse(test), true);
|
||||
auto err = parser2.ConformTo(parser);
|
||||
TEST_NOTNULL(strstr(err.c_str(), expected_err));
|
||||
};
|
||||
|
||||
test_conform("table T { A:byte; }", "types differ for field");
|
||||
test_conform("table T { B:int; A:int; }", "offsets differ for field");
|
||||
test_conform("table T { A:int = 1; }", "defaults differ for field");
|
||||
test_conform("table T { B:float; }", "field renamed to different type");
|
||||
test_conform("enum E:byte { B, A }", "values differ for enum");
|
||||
}
|
||||
|
||||
int main(int /*argc*/, const char * /*argv*/[]) {
|
||||
// Run our various test suites:
|
||||
|
||||
@@ -1091,6 +1109,7 @@ int main(int /*argc*/, const char * /*argv*/[]) {
|
||||
UnicodeInvalidSurrogatesTest();
|
||||
UnknownFieldsTest();
|
||||
ParseUnionTest();
|
||||
ConformTest();
|
||||
|
||||
if (!testing_fails) {
|
||||
TEST_OUTPUT_LINE("ALL TESTS PASSED");
|
||||
|
||||
Reference in New Issue
Block a user