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

Function TEST

runtime/standard/string_functions_test.cc:47–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47TEST(RegisterStringFunctions, FunctionsRegistered) {
48 FunctionRegistry registry;
49 RuntimeOptions options;
50
51 ASSERT_OK(RegisterStringFunctions(registry, options));
52 auto overloads = registry.ListFunctions();
53
54 EXPECT_THAT(
55 overloads[builtin::kAdd],
56 UnorderedElementsAre(
57 MatchesDescriptor(builtin::kAdd, CallStyle::kFree,
58 std::vector<Kind>{Kind::kString, Kind::kString}),
59 MatchesDescriptor(builtin::kAdd, CallStyle::kFree,
60 std::vector<Kind>{Kind::kBytes, Kind::kBytes})));
61
62 EXPECT_THAT(overloads[builtin::kSize],
63 UnorderedElementsAre(
64 MatchesDescriptor(builtin::kSize, CallStyle::kFree,
65 std::vector<Kind>{Kind::kString}),
66 MatchesDescriptor(builtin::kSize, CallStyle::kFree,
67 std::vector<Kind>{Kind::kBytes}),
68 MatchesDescriptor(builtin::kSize, CallStyle::kReceiver,
69 std::vector<Kind>{Kind::kString}),
70 MatchesDescriptor(builtin::kSize, CallStyle::kReceiver,
71 std::vector<Kind>{Kind::kBytes})));
72
73 EXPECT_THAT(
74 overloads[builtin::kStringContains],
75 UnorderedElementsAre(
76 MatchesDescriptor(builtin::kStringContains, CallStyle::kFree,
77 std::vector<Kind>{Kind::kString, Kind::kString}),
78
79 MatchesDescriptor(builtin::kStringContains, CallStyle::kReceiver,
80 std::vector<Kind>{Kind::kString, Kind::kString})));
81 EXPECT_THAT(
82 overloads[builtin::kStringStartsWith],
83 UnorderedElementsAre(
84 MatchesDescriptor(builtin::kStringStartsWith, CallStyle::kFree,
85 std::vector<Kind>{Kind::kString, Kind::kString}),
86
87 MatchesDescriptor(builtin::kStringStartsWith, CallStyle::kReceiver,
88 std::vector<Kind>{Kind::kString, Kind::kString})));
89 EXPECT_THAT(
90 overloads[builtin::kStringEndsWith],
91 UnorderedElementsAre(
92 MatchesDescriptor(builtin::kStringEndsWith, CallStyle::kFree,
93 std::vector<Kind>{Kind::kString, Kind::kString}),
94
95 MatchesDescriptor(builtin::kStringEndsWith, CallStyle::kReceiver,
96 std::vector<Kind>{Kind::kString, Kind::kString})));
97}
98
99TEST(RegisterStringFunctions, ConcatSkippedWhenDisabled) {
100 FunctionRegistry registry;

Callers

nothing calls this directly

Calls 2

RegisterStringFunctionsFunction · 0.85
ListFunctionsMethod · 0.45

Tested by

no test coverage detected