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

Function TEST

eval/eval/ident_step_test.cc:48–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46using ::testing::SizeIs;
47
48TEST(IdentStepTest, TestIdentStep) {
49 ASSERT_OK_AND_ASSIGN(auto step, CreateIdentStep("name0", /*id=*/-1));
50
51 ExecutionPath path;
52 path.push_back(std::move(step));
53
54 auto env = NewTestingRuntimeEnv();
55 CelExpressionFlatImpl impl(
56 env, FlatExpression(std::move(path), /*comprehension_slot_count=*/0,
57 env->type_registry.GetComposedTypeProvider(),
58 cel::RuntimeOptions{}));
59
60 Activation activation;
61 Arena arena;
62 std::string value("test");
63
64 activation.InsertValue("name0", CelValue::CreateString(&value));
65 auto status0 = impl.Evaluate(activation, &arena);
66 ASSERT_OK(status0);
67
68 CelValue result = status0.value();
69
70 ASSERT_TRUE(result.IsString());
71 EXPECT_THAT(result.StringOrDie().value(), Eq("test"));
72}
73
74TEST(IdentStepTest, TestIdentStepNameNotFound) {
75 ASSERT_OK_AND_ASSIGN(auto step, CreateIdentStep("name0", /*id=*/-1));
76
77 ExecutionPath path;
78 path.push_back(std::move(step));
79
80 auto env = NewTestingRuntimeEnv();
81 CelExpressionFlatImpl impl(
82 env, FlatExpression(std::move(path), /*comprehension_slot_count=*/0,
83 env->type_registry.GetComposedTypeProvider(),
84 cel::RuntimeOptions{}));
85
86 Activation activation;
87 Arena arena;
88 std::string value("test");
89
90 auto status0 = impl.Evaluate(activation, &arena);
91 ASSERT_OK(status0);
92
93 CelValue result = status0.value();
94 ASSERT_TRUE(result.IsError());
95}
96
97TEST(IdentStepTest, DisableMissingAttributeErrorsOK) {
98 ASSERT_OK_AND_ASSIGN(auto step, CreateIdentStep("name0", /*id=*/-1));
99
100 ExecutionPath path;
101 path.push_back(std::move(step));
102 cel::RuntimeOptions options;
103 options.unknown_processing = cel::UnknownProcessingOptions::kDisabled;
104 auto env = NewTestingRuntimeEnv();
105 CelExpressionFlatImpl impl(

Callers

nothing calls this directly

Calls 15

FlatExpressionClass · 0.85
CreateIdentStepFunction · 0.85
CreateDirectIdentStepFunction · 0.85
InsertValueMethod · 0.80
StringOrDieMethod · 0.80
codeMethod · 0.80
ErrorOrDieMethod · 0.80
messageMethod · 0.80
IsUnknownSetMethod · 0.80

Tested by

no test coverage detected