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

Function TEST

runtime/reference_resolver_test.cc:50–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48using ::testing::HasSubstr;
49
50TEST(ReferenceResolver, ResolveQualifiedFunctions) {
51 RuntimeOptions options;
52 ASSERT_OK_AND_ASSIGN(RuntimeBuilder builder,
53 CreateStandardRuntimeBuilder(
54 internal::GetTestingDescriptorPool(), options));
55
56 ASSERT_OK(
57 EnableReferenceResolver(builder, ReferenceResolverEnabled::kAlways));
58
59 absl::Status status =
60 RegisterHelper<BinaryFunctionAdapter<int64_t, int64_t, int64_t>>::
61 RegisterGlobalOverload(
62 "com.example.Exp",
63 [](int64_t base, int64_t exp) -> int64_t {
64 int64_t result = 1;
65 for (int64_t i = 0; i < exp; ++i) {
66 result *= base;
67 }
68 return result;
69 },
70 builder.function_registry());
71 ASSERT_OK(status);
72
73 ASSERT_OK_AND_ASSIGN(auto runtime, std::move(builder).Build());
74
75 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
76 Parse("com.example.Exp(2, 3) == 8"));
77
78 ASSERT_OK_AND_ASSIGN(auto program, ProtobufRuntimeAdapter::CreateProgram(
79 *runtime, parsed_expr));
80
81 google::protobuf::Arena arena;
82 Activation activation;
83
84 ASSERT_OK_AND_ASSIGN(Value value, program->Evaluate(&arena, activation));
85 ASSERT_TRUE(value->Is<BoolValue>());
86 EXPECT_TRUE(value.GetBool().NativeValue());
87}
88
89TEST(ReferenceResolver, ResolveQualifiedFunctionsCheckedOnly) {
90 RuntimeOptions options;

Callers

nothing calls this directly

Calls 9

EnableReferenceResolverFunction · 0.85
CreateProgramFunction · 0.85
InsertOrAssignValueMethod · 0.80
IntValueClass · 0.50
NativeValueMethod · 0.45
GetBoolMethod · 0.45
GetIntMethod · 0.45
exprMethod · 0.45
GetErrorMethod · 0.45

Tested by

no test coverage detected