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

Function AddDefaults

eval/eval/function_step_test.cc:172–200  ·  view source on GitHub ↗

Create and initialize a registry with some default functions.

Source from the content-addressed store, hash-verified

170
171// Create and initialize a registry with some default functions.
172void AddDefaults(CelFunctionRegistry& registry) {
173 static UnknownSet* unknown_set = new UnknownSet();
174 EXPECT_TRUE(registry
175 .Register(std::make_unique<ConstFunction>(
176 CelValue::CreateInt64(3), "Const3"))
177 .ok());
178 EXPECT_TRUE(registry
179 .Register(std::make_unique<ConstFunction>(
180 CelValue::CreateInt64(2), "Const2"))
181 .ok());
182 EXPECT_TRUE(registry
183 .Register(std::make_unique<ConstFunction>(
184 CelValue::CreateUnknownSet(unknown_set), "ConstUnknown"))
185 .ok());
186 EXPECT_TRUE(registry.Register(std::make_unique<AddFunction>()).ok());
187
188 EXPECT_TRUE(
189 registry.Register(std::make_unique<SinkFunction>(CelValue::Type::kList))
190 .ok());
191
192 EXPECT_TRUE(
193 registry.Register(std::make_unique<SinkFunction>(CelValue::Type::kMap))
194 .ok());
195
196 EXPECT_TRUE(
197 registry
198 .Register(std::make_unique<SinkFunction>(CelValue::Type::kMessage))
199 .ok());
200}
201
202std::vector<CelValue::Type> ArgumentMatcher(int argument_count) {
203 std::vector<CelValue::Type> argument_matcher(argument_count);

Callers 1

TEST_PFunction · 0.85

Calls 2

okMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected