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

Function TEST

eval/public/containers/internal_field_backed_map_impl_test.cc:60–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60TEST(FieldBackedMapImplTest, BadKeyTypeTest) {
61 TestMessage message;
62 google::protobuf::Arena arena;
63 constexpr std::array<absl::string_view, 6> map_types = {
64 "int64_int32_map", "uint64_int32_map", "string_int32_map",
65 "bool_int32_map", "int32_int32_map", "uint32_uint32_map",
66 };
67
68 for (auto map_type : map_types) {
69 auto cel_map = CreateMap(&message, std::string(map_type), &arena);
70 // Look up a boolean key. This should result in an error for both the
71 // presence test and the value lookup.
72 auto result = cel_map->Has(CelValue::CreateNull());
73 EXPECT_FALSE(result.ok());
74 EXPECT_THAT(result.status().code(), Eq(absl::StatusCode::kInvalidArgument));
75
76 result = cel_map->LegacyHasMapValue(CelValue::CreateNull());
77 EXPECT_FALSE(result.ok());
78 EXPECT_THAT(result.status().code(), Eq(absl::StatusCode::kInvalidArgument));
79
80 auto lookup = (*cel_map)[CelValue::CreateNull()];
81 EXPECT_TRUE(lookup.has_value());
82 EXPECT_TRUE(lookup->IsError());
83 EXPECT_THAT(lookup->ErrorOrDie()->code(),
84 Eq(absl::StatusCode::kInvalidArgument));
85
86 lookup = cel_map->LegacyLookupMapValue(CelValue::CreateNull());
87 EXPECT_TRUE(lookup.has_value());
88 EXPECT_TRUE(lookup->IsError());
89 EXPECT_THAT(lookup->ErrorOrDie()->code(),
90 Eq(absl::StatusCode::kInvalidArgument));
91 }
92}
93
94TEST(FieldBackedMapImplTest, Int32KeyTest) {
95 TestMessage message;

Callers

nothing calls this directly

Calls 15

codeMethod · 0.80
LegacyHasMapValueMethod · 0.80
ErrorOrDieMethod · 0.80
LegacyLookupMapValueMethod · 0.80
Int64OrDieMethod · 0.80
Uint64OrDieMethod · 0.80
StringOrDieMethod · 0.80
CreateMapFunction · 0.70
HasMethod · 0.45
okMethod · 0.45
has_valueMethod · 0.45
IsErrorMethod · 0.45

Tested by

no test coverage detected