Checks to make sure current schema in current code does not cause an incompatibility.
| 58 | // Checks to make sure current schema in current code does not cause an |
| 59 | // incompatibility. |
| 60 | TEST(SchemaTest, TestCompatibility) { |
| 61 | // Read file contents of schemas into strings |
| 62 | // TODO(aselle): Need a reliable way to load files. |
| 63 | std::string base_contents, current_contents; |
| 64 | const char *base_filename = |
| 65 | TFLITE_TF_PREFIX "lite/schema/schema_v3.fbs"; |
| 66 | const char *current_filename = |
| 67 | TFLITE_TF_PREFIX "lite/schema/schema.fbs"; |
| 68 | |
| 69 | ASSERT_TRUE(LoadFileRaw(base_filename, &base_contents)); |
| 70 | ASSERT_TRUE(LoadFileRaw(current_filename, ¤t_contents)); |
| 71 | // Parse the schemas |
| 72 | flatbuffers::Parser base_parser, current_parser; |
| 73 | std::vector<const char *> include_directories; |
| 74 | ASSERT_TRUE(ParseFile(&base_parser, base_filename, base_contents)); |
| 75 | ASSERT_TRUE(ParseFile(¤t_parser, current_filename, current_contents)); |
| 76 | // Check that the schemas conform and fail if they don't |
| 77 | auto err = current_parser.ConformTo(base_parser); |
| 78 | if (!err.empty()) { |
| 79 | fprintf(stderr, |
| 80 | "Schemas don't conform:\n%s\n" |
| 81 | "In other words some change you made means that new parsers can't" |
| 82 | "parse old files.\n", |
| 83 | err.c_str()); |
| 84 | FAIL(); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | int main(int argc, char **argv) { |
| 89 | ::testing::InitGoogleTest(&argc, argv); |
nothing calls this directly
no test coverage detected