tensorflow/lite/schema/flatbuffer_compatibility_test.cc
// Checks to make sure current schema in current code does not cause an
// incompatibility.
Checks to make sure current schema in current code does not cause an
incompatibility.
Checks to make sure current schema in current code does not cause an incompatibility .
TEST(SchemaTest, TestCompatibility) {
  std::string base_contents, current_contents;
  const char *base_filename = TFLITE_TF_PREFIX "lite/schema/schema_v3b.fbs";
  const char *current_filename =
      TFLITE_TF_PREFIX "lite/schema/schema.fbs";
  ASSERT_TRUE(LoadFileRaw(base_filename, &base_contents));
  ASSERT_TRUE(LoadFileRaw(current_filename, &current_contents));
  flatbuffers::Parser base_parser, current_parser;
  std::vector<const char *> include_directories;
  ASSERT_TRUE(ParseFile(&base_parser, base_filename, base_contents));
  ASSERT_TRUE(ParseFile(&current_parser, current_filename, current_contents));
  auto err = current_parser.ConformTo(base_parser);
  if (!err.empty()) {
    fprintf(stderr,
            "Schemas don't conform:\n%s\n"
            "In other words some change you made means that new parsers can't"
            "parse old files.\n",
            err.c_str());
    FAIL();
  }
}
TEST ( SchemaTest , TestCompatibility ) { std :: string base_contents , current_contents ; const char * base_filename = TFLITE_TF_PREFIX " " ; const char * current_filename = TFLITE_TF_PREFIX " " ; ASSERT_TRUE ( LoadFileRaw ( base_filename , & base_contents ) ) ; ASSERT_TRUE ( LoadFileRaw ( current_filename , & current_contents ) ) ; flatbuffers :: Parser base_parser , current_parser ; std :: vector < const char * > include_directories ; ASSERT_TRUE ( ParseFile ( & base_parser , base_filename , base_contents ) ) ; ASSERT_TRUE ( ParseFile ( & current_parser , current_filename , current_contents ) ) ; auto err = current_parser . ConformTo ( base_parser ) ; if ( ! err . empty ( ) ) { fprintf ( stderr , " \n \n " " " " \n " , err . c_str ( ) ) ; FAIL ( ) ; } }
Checks to make sure current schema in current code does not cause an
incompatibility.
Checks to make sure current schema in current code does not cause an incompatibility .
// Read file contents of schemas into strings // TODO(aselle): Need a reliable way to load files. // Parse the schemas // Check that the schemas conform and fail if they don't