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

Function TEST_P

runtime/constant_folding_test.cc:78–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76class ConstantFoldingExtTest : public testing::TestWithParam<TestCase> {};
77
78TEST_P(ConstantFoldingExtTest, Runner) {
79 google::protobuf::Arena arena;
80 RuntimeOptions options;
81 const TestCase& test_case = GetParam();
82 ASSERT_OK_AND_ASSIGN(cel::RuntimeBuilder builder,
83 CreateStandardRuntimeBuilder(
84 internal::GetTestingDescriptorPool(), options));
85
86 auto status = BinaryFunctionAdapter<absl::StatusOr<Value>, const StringValue&,
87 const StringValue&>::
88 RegisterGlobalOverload(
89 "prepend",
90 [](const StringValue& value, const StringValue& prefix) {
91 return StringValue(
92 absl::StrCat(prefix.ToString(), value.ToString()));
93 },
94 builder.function_registry());
95 ASSERT_THAT(status, IsOk());
96
97 ASSERT_THAT(EnableConstantFolding(builder), IsOk());
98
99 ASSERT_OK_AND_ASSIGN(auto runtime, std::move(builder).Build());
100
101 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, Parse(test_case.expression));
102
103 ASSERT_OK_AND_ASSIGN(auto program, ProtobufRuntimeAdapter::CreateProgram(
104 *runtime, parsed_expr));
105 Activation activation;
106
107 auto result = program->Evaluate(&arena, activation);
108 if (test_case.status.ok()) {
109 ASSERT_OK_AND_ASSIGN(Value value, std::move(result));
110
111 EXPECT_THAT(value, test_case.result_matcher);
112 return;
113 }
114
115 EXPECT_THAT(result.status(), StatusIs(test_case.status.code(),
116 HasSubstr(test_case.status.message())));
117}
118
119INSTANTIATE_TEST_SUITE_P(
120 Cases, ConstantFoldingExtTest,

Callers

nothing calls this directly

Calls 7

EnableConstantFoldingFunction · 0.85
codeMethod · 0.80
messageMethod · 0.80
StringValueClass · 0.50
ToStringMethod · 0.45
EvaluateMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected