| 30 | } |
| 31 | |
| 32 | TEST(FieldBackedMapImplTest, BadKeyTypeTest) { |
| 33 | TestMessage message; |
| 34 | google::protobuf::Arena arena; |
| 35 | constexpr std::array<absl::string_view, 6> map_types = { |
| 36 | "int64_int32_map", "uint64_int32_map", "string_int32_map", |
| 37 | "bool_int32_map", "int32_int32_map", "uint32_uint32_map", |
| 38 | }; |
| 39 | |
| 40 | for (auto map_type : map_types) { |
| 41 | auto cel_map = CreateMap(&message, std::string(map_type), &arena); |
| 42 | // Look up a boolean key. This should result in an error for both the |
| 43 | // presence test and the value lookup. |
| 44 | auto result = cel_map->Has(CelValue::CreateNull()); |
| 45 | EXPECT_FALSE(result.ok()); |
| 46 | EXPECT_THAT(result.status().code(), Eq(absl::StatusCode::kInvalidArgument)); |
| 47 | |
| 48 | EXPECT_FALSE(result.ok()); |
| 49 | EXPECT_THAT(result.status().code(), Eq(absl::StatusCode::kInvalidArgument)); |
| 50 | |
| 51 | auto lookup = (*cel_map)[CelValue::CreateNull()]; |
| 52 | EXPECT_TRUE(lookup.has_value()); |
| 53 | EXPECT_TRUE(lookup->IsError()); |
| 54 | EXPECT_THAT(lookup->ErrorOrDie()->code(), |
| 55 | Eq(absl::StatusCode::kInvalidArgument)); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | TEST(FieldBackedMapImplTest, Int32KeyTest) { |
| 60 | TestMessage message; |
nothing calls this directly
no test coverage detected