| 106 | }; |
| 107 | |
| 108 | TEST_P(BindingsExtTest, Default) { |
| 109 | const TestInfo& test_info = GetTestInfo(); |
| 110 | Arena arena; |
| 111 | std::vector<Macro> all_macros = Macro::AllMacros(); |
| 112 | std::vector<Macro> bindings_macros = cel::extensions::bindings_macros(); |
| 113 | all_macros.insert(all_macros.end(), bindings_macros.begin(), |
| 114 | bindings_macros.end()); |
| 115 | auto result = ParseWithMacros(test_info.expr, all_macros, "<input>"); |
| 116 | if (!test_info.err.empty()) { |
| 117 | EXPECT_THAT(result.status(), StatusIs(absl::StatusCode::kInvalidArgument, |
| 118 | HasSubstr(test_info.err))); |
| 119 | return; |
| 120 | } |
| 121 | EXPECT_THAT(result, IsOk()); |
| 122 | |
| 123 | ParsedExpr parsed_expr = *result; |
| 124 | Expr expr = parsed_expr.expr(); |
| 125 | SourceInfo source_info = parsed_expr.source_info(); |
| 126 | |
| 127 | // Obtain CEL Expression builder. |
| 128 | InterpreterOptions options; |
| 129 | options.enable_heterogeneous_equality = true; |
| 130 | options.enable_empty_wrapper_null_unboxing = true; |
| 131 | options.constant_folding = GetEnableConstantFolding(); |
| 132 | options.constant_arena = &arena; |
| 133 | options.max_recursion_depth = GetEnableRecursivePlan() ? -1 : 0; |
| 134 | std::unique_ptr<CelExpressionBuilder> builder = |
| 135 | CreateCelExpressionBuilder(options); |
| 136 | ASSERT_OK(builder->GetRegistry()->Register(CreateBindFunction())); |
| 137 | |
| 138 | // Register builtins and configure the execution environment. |
| 139 | ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry())); |
| 140 | |
| 141 | // Create CelExpression from AST (Expr object). |
| 142 | ASSERT_OK_AND_ASSIGN(auto cel_expr, |
| 143 | builder->CreateExpression(&expr, &source_info)); |
| 144 | Activation activation; |
| 145 | // Run evaluation. |
| 146 | ASSERT_OK_AND_ASSIGN(CelValue out, cel_expr->Evaluate(activation, &arena)); |
| 147 | ASSERT_TRUE(out.IsBool()) << out.DebugString(); |
| 148 | EXPECT_EQ(out.BoolOrDie(), true); |
| 149 | } |
| 150 | |
| 151 | TEST_P(BindingsExtTest, Tracing) { |
| 152 | const TestInfo& test_info = GetTestInfo(); |
nothing calls this directly
no test coverage detected