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

Function TestDispatchToFunction

runtime/standard/logical_functions_test.cc:64–84  ·  view source on GitHub ↗

TODO(uncreated-issue/48): replace this with a parsed expr when the non-protobuf parser is available.

Source from the content-addressed store, hash-verified

62// TODO(uncreated-issue/48): replace this with a parsed expr when the non-protobuf
63// parser is available.
64absl::StatusOr<Value> TestDispatchToFunction(
65 const FunctionRegistry& registry, absl::string_view simple_name,
66 absl::Span<const Value> args,
67 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
68 google::protobuf::MessageFactory* absl_nonnull message_factory,
69 google::protobuf::Arena* absl_nonnull arena) {
70 std::vector<Kind> arg_matcher_;
71 arg_matcher_.reserve(args.size());
72 for (const auto& value : args) {
73 arg_matcher_.push_back(ValueKindToKind(value->kind()));
74 }
75 std::vector<FunctionOverloadReference> refs = registry.FindStaticOverloads(
76 simple_name, /*receiver_style=*/false, arg_matcher_);
77
78 if (refs.size() != 1) {
79 return absl::InvalidArgumentError("ambiguous overloads");
80 }
81
82 return refs[0].implementation.Invoke(args, descriptor_pool, message_factory,
83 arena);
84}
85
86TEST(RegisterLogicalFunctions, NotStrictlyFalseRegistered) {
87 FunctionRegistry registry;

Callers 1

TEST_PFunction · 0.85

Calls 5

ValueKindToKindFunction · 0.85
sizeMethod · 0.45
kindMethod · 0.45
FindStaticOverloadsMethod · 0.45
InvokeMethod · 0.45

Tested by

no test coverage detected