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

Function TEST_P

extensions/select_optimization_test.cc:910–951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908 public testing::WithParamInterface<ProgramOptimizerTestCase> {};
909
910TEST_P(SelectOptimizationProgramOptimizerTest, Default) {
911 const ProgramOptimizerTestCase& test_case = GetParam();
912 google::protobuf::LinkMessageReflection<NestedTestAllTypes>();
913
914 RuntimeOptions options = runtime_options_;
915 options.unknown_processing = UnknownProcessingOptions::kAttributeAndFunction;
916 options.enable_missing_attribute_errors = true;
917
918 FlatExprBuilder builder(env_, options);
919
920 builder.AddAstTransform(std::make_unique<SelectOptimizationAstUpdater>());
921 builder.AddProgramOptimizer(CreateSelectOptimizationProgramOptimizer());
922
923 ASSERT_OK_AND_ASSIGN(std::unique_ptr<cel::Ast> ast,
924 CompileForTestCase(test_case.expr));
925
926 ASSERT_OK_AND_ASSIGN(FlatExpression plan,
927 builder.CreateExpressionImpl(std::move(ast), nullptr));
928
929 cel::Activation act;
930 // activation only uses a ptr to the underlying message, persist them.
931 std::vector<std::unique_ptr<NestedTestAllTypes>> vars;
932 for (const auto& entry : test_case.vars) {
933 vars.push_back(std::make_unique<NestedTestAllTypes>());
934 ASSERT_TRUE(
935 google::protobuf::TextFormat::ParseFromString(entry.second, vars.back().get()));
936 ASSERT_THAT(TestBindLegacyMessage(entry.first, *vars.back(), &arena_, act),
937 IsOk());
938 }
939
940 if (test_case.setup_activation != nullptr) {
941 ASSERT_THAT(test_case.setup_activation(&arena_, act), IsOk());
942 }
943
944 auto state = plan.MakeEvaluatorState(env_->descriptor_pool.get(),
945 env_->MutableMessageFactory(), &arena_);
946 absl::StatusOr<Value> result = plan.EvaluateWithCallback(
947 act, /*embedder_context=*/nullptr,
948 google::api::expr::runtime::EvaluationListener(), state);
949
950 ASSERT_NO_FATAL_FAILURE(test_case.expectations(result));
951}
952
953TEST_P(SelectOptimizationProgramOptimizerTest, ForceFallbackImpl) {
954 const ProgramOptimizerTestCase& test_case = GetParam();

Callers

nothing calls this directly

Calls 10

CompileForTestCaseFunction · 0.85
TestBindLegacyMessageFunction · 0.85
AddAstTransformMethod · 0.80
AddProgramOptimizerMethod · 0.80
MakeEvaluatorStateMethod · 0.80
EvaluateWithCallbackMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.50
getMethod · 0.45
MutableMessageFactoryMethod · 0.45

Tested by

no test coverage detected