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

Function TEST_P

runtime/regex_precompilation_test.cc:79–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77class RegexPrecompilationTest : public testing::TestWithParam<TestCase> {};
78
79TEST_P(RegexPrecompilationTest, Basic) {
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 = RegisterHelper<BinaryFunctionAdapter<
87 absl::StatusOr<Value>, const StringValue&, 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(EnableRegexPrecompilation(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 auto program_or =
104 ProtobufRuntimeAdapter::CreateProgram(*runtime, parsed_expr);
105 if (!test_case.create_status.ok()) {
106 ASSERT_THAT(program_or.status(),
107 StatusIs(test_case.create_status.code(),
108 HasSubstr(test_case.create_status.message())));
109 return;
110 }
111
112 ASSERT_OK_AND_ASSIGN(auto program, std::move(program_or));
113
114 google::protobuf::Arena arena;
115 Activation activation;
116 activation.InsertOrAssignValue("string_var",
117 StringValue(&arena, "string_var"));
118
119 ASSERT_OK_AND_ASSIGN(Value value, program->Evaluate(&arena, activation));
120 EXPECT_THAT(value, test_case.result_matcher);
121}
122
123TEST_P(RegexPrecompilationTest, WithConstantFolding) {
124 RuntimeOptions options;

Callers

nothing calls this directly

Calls 9

CreateProgramFunction · 0.85
EnableConstantFoldingFunction · 0.85
codeMethod · 0.80
messageMethod · 0.80
InsertOrAssignValueMethod · 0.80
StringValueClass · 0.50
ToStringMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected