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

Function TEST_P

extensions/sets_functions_test.cc:57–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55class CelSetsFunctionsTest : public testing::TestWithParam<TestInfo> {};
56
57TEST_P(CelSetsFunctionsTest, EndToEnd) {
58 const TestInfo& test_info = GetParam();
59 ASSERT_OK_AND_ASSIGN(auto compiler_builder,
60 NewCompilerBuilder(cel::GetMinimalDescriptorPool()));
61
62 ASSERT_THAT(compiler_builder->AddLibrary(StandardCheckerLibrary()), IsOk());
63 ASSERT_THAT(compiler_builder->AddLibrary(SetsCompilerLibrary()), IsOk());
64 ASSERT_OK_AND_ASSIGN(auto compiler, compiler_builder->Build());
65
66 ASSERT_OK_AND_ASSIGN(ValidationResult compiled,
67 compiler->Compile(test_info.expr));
68
69 ASSERT_TRUE(compiled.IsValid()) << compiled.FormatError();
70
71 cel::expr::CheckedExpr checked_expr;
72 ASSERT_THAT(AstToCheckedExpr(*compiled.GetAst(), &checked_expr), IsOk());
73
74 // Obtain CEL Expression builder.
75 InterpreterOptions options;
76 options.enable_heterogeneous_equality = true;
77 options.enable_empty_wrapper_null_unboxing = true;
78 options.enable_qualified_identifier_rewrites = true;
79 std::unique_ptr<CelExpressionBuilder> builder =
80 CreateCelExpressionBuilder(options);
81 ASSERT_THAT(RegisterSetsFunctions(builder->GetRegistry(), options), IsOk());
82 ASSERT_THAT(google::api::expr::runtime::RegisterBuiltinFunctions(
83 builder->GetRegistry(), options),
84 IsOk());
85
86 // Create CelExpression from AST (Expr object).
87 ASSERT_OK_AND_ASSIGN(auto cel_expr, builder->CreateExpression(&checked_expr));
88 Arena arena;
89 Activation activation;
90 // Run evaluation.
91 ASSERT_OK_AND_ASSIGN(CelValue out, cel_expr->Evaluate(activation, &arena));
92 ASSERT_TRUE(out.IsBool()) << test_info.expr << " -> " << out.DebugString();
93 EXPECT_TRUE(out.BoolOrDie()) << test_info.expr << " -> " << out.DebugString();
94}
95
96INSTANTIATE_TEST_SUITE_P(
97 CelSetsFunctionsTest, CelSetsFunctionsTest,

Callers

nothing calls this directly

Calls 14

StandardCheckerLibraryFunction · 0.85
SetsCompilerLibraryFunction · 0.85
AstToCheckedExprFunction · 0.85
RegisterSetsFunctionsFunction · 0.85
RegisterBuiltinFunctionsFunction · 0.85
IsValidMethod · 0.80
FormatErrorMethod · 0.80
GetAstMethod · 0.80
GetRegistryMethod · 0.80
BoolOrDieMethod · 0.80
AddLibraryMethod · 0.45

Tested by

no test coverage detected