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

Function TEST

eval/eval/comprehension_slots_test.cc:35–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33using ::testing::Truly;
34
35TEST(ComprehensionSlots, Basic) {
36 ComprehensionSlots slots(4);
37
38 ComprehensionSlots::Slot* slot0 = slots.Get(0);
39 EXPECT_FALSE(slot0->Has());
40
41 slots.Set(0, cel::StringValue("abcd"),
42 AttributeTrail(Attribute("fake_attr")));
43
44 ASSERT_TRUE(slot0->Has());
45
46 EXPECT_THAT(slot0->value(), Truly([](const Value& v) {
47 return v.Is<StringValue>() &&
48 v.GetString().ToString() == "abcd";
49 }))
50 << "value is 'abcd'";
51
52 EXPECT_THAT(slot0->attribute().attribute().AsString(),
53 IsOkAndHolds("fake_attr"));
54
55 slots.ClearSlot(0);
56 EXPECT_FALSE(slot0->Has());
57
58 slots.Set(3, cel::StringValue("abcd"),
59 AttributeTrail(Attribute("fake_attr")));
60
61 auto* slot3 = slots.Get(3);
62
63 ASSERT_TRUE(slot3->Has());
64 EXPECT_THAT(slot3->value(), Truly([](const Value& v) {
65 return v.Is<StringValue>() &&
66 v.GetString().ToString() == "abcd";
67 }))
68 << "value is 'abcd'";
69
70 slots.Reset();
71 EXPECT_FALSE(slot0->Has());
72 EXPECT_FALSE(slot3->Has());
73}
74
75} // namespace google::api::expr::runtime

Callers

nothing calls this directly

Calls 13

AttributeTrailClass · 0.85
AttributeClass · 0.85
attributeMethod · 0.80
ClearSlotMethod · 0.80
StringValueClass · 0.50
GetMethod · 0.45
HasMethod · 0.45
SetMethod · 0.45
valueMethod · 0.45
ToStringMethod · 0.45
GetStringMethod · 0.45
AsStringMethod · 0.45

Tested by

no test coverage detected