| 18 | using ::testing::Not; |
| 19 | |
| 20 | TEST(ContainerBackedMapImplTest, TestMapInt64) { |
| 21 | std::vector<std::pair<CelValue, CelValue>> args = { |
| 22 | {CelValue::CreateInt64(1), CelValue::CreateInt64(2)}, |
| 23 | {CelValue::CreateInt64(2), CelValue::CreateInt64(3)}}; |
| 24 | |
| 25 | auto cel_map = |
| 26 | CreateContainerBackedMap( |
| 27 | absl::Span<std::pair<CelValue, CelValue>>(args.data(), args.size())) |
| 28 | .value(); |
| 29 | |
| 30 | ASSERT_THAT(cel_map, Not(IsNull())); |
| 31 | |
| 32 | EXPECT_THAT(cel_map->size(), Eq(2)); |
| 33 | |
| 34 | // Test lookup with key == 1 ( should succeed ) |
| 35 | auto lookup1 = (*cel_map)[CelValue::CreateInt64(1)]; |
| 36 | |
| 37 | ASSERT_TRUE(lookup1); |
| 38 | |
| 39 | CelValue cel_value = lookup1.value(); |
| 40 | |
| 41 | ASSERT_TRUE(cel_value.IsInt64()); |
| 42 | EXPECT_THAT(cel_value.Int64OrDie(), 2); |
| 43 | |
| 44 | // Test lookup with key == 1, different type ( should fail ) |
| 45 | auto lookup2 = (*cel_map)[CelValue::CreateUint64(1)]; |
| 46 | |
| 47 | ASSERT_FALSE(lookup2); |
| 48 | |
| 49 | // Test lookup with key == 3 ( should fail ) |
| 50 | auto lookup3 = (*cel_map)[CelValue::CreateInt64(3)]; |
| 51 | |
| 52 | ASSERT_FALSE(lookup3); |
| 53 | } |
| 54 | |
| 55 | TEST(ContainerBackedMapImplTest, TestMapUint64) { |
| 56 | std::vector<std::pair<CelValue, CelValue>> args = { |
nothing calls this directly
no test coverage detected