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

Function TEST

eval/eval/regex_match_step_test.cc:44–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44TEST(RegexMatchStep, Precompiled) {
45 google::protobuf::Arena arena;
46 Activation activation;
47 ASSERT_OK_AND_ASSIGN(auto parsed_expr, parser::Parse("foo.matches('hello')"));
48 CheckedExpr checked_expr;
49 *checked_expr.mutable_expr() = parsed_expr.expr();
50 *checked_expr.mutable_source_info() = parsed_expr.source_info();
51 checked_expr.mutable_reference_map()->insert(
52 {checked_expr.expr().id(), MakeMatchesStringOverload()});
53 InterpreterOptions options;
54 options.enable_regex_precompilation = true;
55 auto expr_builder = CreateCelExpressionBuilder(options);
56 ASSERT_OK(RegisterBuiltinFunctions(expr_builder->GetRegistry(), options));
57 ASSERT_OK_AND_ASSIGN(auto expr,
58 expr_builder->CreateExpression(&checked_expr));
59 activation.InsertValue("foo", CelValue::CreateStringView("hello world!"));
60 ASSERT_OK_AND_ASSIGN(auto result, expr->Evaluate(activation, &arena));
61 EXPECT_TRUE(result.IsBool());
62 EXPECT_TRUE(result.BoolOrDie());
63}
64
65TEST(RegexMatchStep, PrecompiledInvalidRegex) {
66 Activation activation;

Callers

nothing calls this directly

Calls 11

RegisterBuiltinFunctionsFunction · 0.85
source_infoMethod · 0.80
GetRegistryMethod · 0.80
InsertValueMethod · 0.80
BoolOrDieMethod · 0.80
exprMethod · 0.45
idMethod · 0.45
IsBoolMethod · 0.45
CreateExpressionMethod · 0.45

Tested by

no test coverage detected