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

Function TEST_P

eval/tests/memory_safety_test.cc:131–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131TEST_P(EvaluatorMemorySafetyTest, Basic) {
132 const auto& test_case = GetTestCase();
133 InterpreterOptions options = GetOptions();
134
135 std::unique_ptr<CelExpressionBuilder> builder =
136 CreateCelExpressionBuilder(options);
137 builder->set_container("google.rpc.context");
138 ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry(), options));
139
140 absl::string_view function_name = "IsPrivate";
141 if (test_case.reference_resolver_enabled) {
142 function_name = "net.IsPrivate";
143 }
144 ASSERT_OK((FunctionAdapter<bool, CelValue::StringHolder>::CreateAndRegister(
145 function_name, false, &IsPrivateIpv4Impl, builder->GetRegistry())));
146
147 ASSERT_OK_AND_ASSIGN(ParsedExpr expr, parser::Parse(test_case.expression));
148
149 ASSERT_OK_AND_ASSIGN(
150 auto plan, builder->CreateExpression(&expr.expr(), &expr.source_info()));
151
152 Activation activation;
153 for (const auto& [key, value] : test_case.activation) {
154 activation.InsertValue(key, value);
155 }
156
157 absl::StatusOr<CelValue> got = plan->Evaluate(activation, &arena_);
158
159 EXPECT_THAT(got, IsOkAndHolds(test_case.expected_matcher));
160}
161
162// Check no use after free errors if evaluated after AST is freed.
163TEST_P(EvaluatorMemorySafetyTest, NoAstDependency) {

Callers

nothing calls this directly

Calls 14

GetOptionsFunction · 0.85
RegisterBuiltinFunctionsFunction · 0.85
GetRegistryMethod · 0.80
InsertValueMethod · 0.80
source_infoMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.70
ParseFunction · 0.50
set_containerMethod · 0.45
EvaluateMethod · 0.45
valueMethod · 0.45
CreateExpressionMethod · 0.45

Tested by

no test coverage detected