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

Function TEST_P

extensions/bindings_ext_test.cc:108–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106};
107
108TEST_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
151TEST_P(BindingsExtTest, Tracing) {
152 const TestInfo& test_info = GetTestInfo();

Callers

nothing calls this directly

Calls 15

AllMacrosFunction · 0.85
bindings_macrosFunction · 0.85
ParseWithMacrosFunction · 0.85
CreateBindFunctionFunction · 0.85
RegisterBuiltinFunctionsFunction · 0.85
AttributePatternClass · 0.85
AttributeClass · 0.85
source_infoMethod · 0.80
GetRegistryMethod · 0.80
BoolOrDieMethod · 0.80
InsertValueMethod · 0.80
IsInt64Method · 0.80

Tested by

no test coverage detected