Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e041c671 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Konst-ify test data gd/dumpsys/bundler/test.cc"

parents 77e0537f 94f5a08d
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@
#include "bundler_generated.h"
#include "flatbuffers/flatbuffers.h"

// Must be run from the same directory as the test data 'test.bfbs'.
// This is how the presubmit unit test pipeline functions.
constexpr char kTestFilename[] = "test.bfbs";

bool LoadBinarySchema(const char* filename, std::string* binary_schema);
bool VerifyBinarySchema(const std::vector<uint8_t>& raw_schema);
bool CreateBinarySchemaBundle(
@@ -40,14 +44,14 @@ class BundlerTest : public ::testing::Test {
TEST_F(BundlerTest, LoadBinarySchema) {
  std::string string_schema;
  ASSERT_FALSE(LoadBinarySchema(nullptr, &string_schema));
  ASSERT_DEATH(LoadBinarySchema("test.bfbs", nullptr), "");
  ASSERT_TRUE(LoadBinarySchema("test.bfbs", &string_schema));
  ASSERT_DEATH(LoadBinarySchema(kTestFilename, nullptr), "");
  ASSERT_TRUE(LoadBinarySchema(kTestFilename, &string_schema));
  ASSERT_FALSE(LoadBinarySchema("does_not_exist.bfbs", &string_schema));
}

TEST_F(BundlerTest, VerifyBinarySchema) {
  std::string string_schema;
  ASSERT_TRUE(LoadBinarySchema("test.bfbs", &string_schema));
  ASSERT_TRUE(LoadBinarySchema(kTestFilename, &string_schema));
  std::vector<uint8_t> raw_schema(string_schema.begin(), string_schema.end());
  ASSERT_TRUE(VerifyBinarySchema(raw_schema));