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

Function TEST

eval/public/containers/container_backed_map_impl_test.cc:20–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using ::testing::Not;
19
20TEST(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
55TEST(ContainerBackedMapImplTest, TestMapUint64) {
56 std::vector<std::pair<CelValue, CelValue>> args = {

Callers

nothing calls this directly

Calls 6

CreateContainerBackedMapFunction · 0.85
IsInt64Method · 0.80
Int64OrDieMethod · 0.80
valueMethod · 0.45
sizeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected