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

Function TEST

eval/eval/function_step_test.cc:746–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744 &TestNameFn);
745
746TEST(FunctionStepTestUnknownFunctionResults, CaptureArgs) {
747 ExecutionPath path;
748 CelFunctionRegistry registry;
749
750 ASSERT_OK(registry.Register(
751 std::make_unique<ConstFunction>(CelValue::CreateInt64(2), "Const2")));
752 ASSERT_OK(registry.Register(
753 std::make_unique<ConstFunction>(CelValue::CreateInt64(3), "Const3")));
754 ASSERT_OK(registry.Register(
755 std::make_unique<AddFunction>(ShouldReturnUnknown::kYes)));
756
757 CallExpr call1 = ConstFunction::MakeCall("Const2");
758 CallExpr call2 = ConstFunction::MakeCall("Const3");
759 CallExpr add_call = AddFunction::MakeCall();
760
761 ASSERT_OK_AND_ASSIGN(auto step0, MakeTestFunctionStep(call1, registry));
762 ASSERT_OK_AND_ASSIGN(auto step1, MakeTestFunctionStep(call2, registry));
763 ASSERT_OK_AND_ASSIGN(auto step2, MakeTestFunctionStep(add_call, registry));
764
765 path.push_back(std::move(step0));
766 path.push_back(std::move(step1));
767 path.push_back(std::move(step2));
768 cel::RuntimeOptions options;
769 options.unknown_processing =
770 cel::UnknownProcessingOptions::kAttributeAndFunction;
771 auto env = NewTestingRuntimeEnv();
772 CelExpressionFlatImpl impl(
773 env,
774 FlatExpression(std::move(path),
775 /*comprehension_slot_count=*/0,
776 env->type_registry.GetComposedTypeProvider(), options));
777
778 Activation activation;
779 google::protobuf::Arena arena;
780
781 ASSERT_OK_AND_ASSIGN(CelValue value, impl.Evaluate(activation, &arena));
782 ASSERT_TRUE(value.IsUnknownSet());
783}
784
785TEST(FunctionStepTestUnknownFunctionResults, MergeDownCaptureArgs) {
786 ExecutionPath path;

Callers

nothing calls this directly

Calls 9

FlatExpressionClass · 0.85
MakeTestFunctionStepFunction · 0.85
IsCelInt64Function · 0.85
IsUnknownSetMethod · 0.80
ErrorOrDieMethod · 0.80
CreateErrorFunction · 0.50
ASSERT_OK_AND_ASSIGNFunction · 0.50
RegisterMethod · 0.45
IsErrorMethod · 0.45

Tested by

no test coverage detected