| 58 | } |
| 59 | |
| 60 | TEST(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 | |
| 94 | TEST(FieldBackedMapImplTest, Int32KeyTest) { |
| 95 | TestMessage message; |
nothing calls this directly
no test coverage detected