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

Commit f1236ed5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

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

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1858602

Change-Id: I377f598a4d07381befb967411d45582cac2e80fe
parents 9d629130 e041c671
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));