| 42 | } |
| 43 | |
| 44 | TEST(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 | |
| 65 | TEST(RegexMatchStep, PrecompiledInvalidRegex) { |
| 66 | Activation activation; |
nothing calls this directly
no test coverage detected