Create and initialize a registry with some default functions.
| 170 | |
| 171 | // Create and initialize a registry with some default functions. |
| 172 | void 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 | |
| 202 | std::vector<CelValue::Type> ArgumentMatcher(int argument_count) { |
| 203 | std::vector<CelValue::Type> argument_matcher(argument_count); |