MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / FlatBuffersTest

Class FlatBuffersTest

tools/flatbuffers_backed_impl_test.cc:54–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52const int64_t kNumFields = 27;
53
54class FlatBuffersTest : public testing::Test {
55 public:
56 FlatBuffersTest() {
57 EXPECT_TRUE(
58 flatbuffers::LoadFile(kReflectionBufferPath, true, &schema_file_));
59 flatbuffers::Verifier verifier(
60 reinterpret_cast<const uint8_t*>(schema_file_.data()),
61 schema_file_.size());
62 EXPECT_TRUE(reflection::VerifySchemaBuffer(verifier));
63 EXPECT_TRUE(parser_.Deserialize(
64 reinterpret_cast<const uint8_t*>(schema_file_.data()),
65 schema_file_.size()));
66 schema_ = reflection::GetSchema(schema_file_.data());
67 }
68 const CelMap& loadJson(std::string data) {
69 EXPECT_TRUE(parser_.Parse(data.data()));
70 const CelMap* value = CreateFlatBuffersBackedObject(
71 parser_.builder_.GetBufferPointer(), *schema_, &arena_);
72 EXPECT_NE(nullptr, value);
73 EXPECT_EQ(kNumFields, value->size());
74 const CelList* keys = value->ListKeys().value();
75 EXPECT_NE(nullptr, keys);
76 EXPECT_EQ(kNumFields, keys->size());
77 EXPECT_TRUE((*keys)[2].IsString());
78 return *value;
79 }
80
81 protected:
82 std::string schema_file_;
83 flatbuffers::Parser parser_;
84 const reflection::Schema* schema_;
85 google::protobuf::Arena arena_;
86};
87
88TEST_F(FlatBuffersTest, PrimitiveFields) {
89 const CelMap& value = loadJson(R"({

Callers

nothing calls this directly

Calls 6

ParseMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45
ListKeysMethod · 0.45
IsStringMethod · 0.45

Tested by

no test coverage detected