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

Function TEST

extensions/bindings_ext_test.cc:272–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270 })pb";
271
272TEST(BindingsExtTest, TraceSupport) {
273 ParsedExpr expr;
274 ASSERT_TRUE(TextFormat::ParseFromString(kTraceExpr, &expr));
275 InterpreterOptions options;
276 options.enable_heterogeneous_equality = true;
277 options.enable_empty_wrapper_null_unboxing = true;
278 std::unique_ptr<CelExpressionBuilder> builder =
279 CreateCelExpressionBuilder(options);
280 ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry()));
281
282 ASSERT_OK_AND_ASSIGN(
283 auto plan, builder->CreateExpression(&expr.expr(), &expr.source_info()));
284 Activation activation;
285 google::protobuf::Arena arena;
286 absl::flat_hash_map<int64_t, CelValue> ids;
287 ASSERT_OK_AND_ASSIGN(
288 auto result,
289 plan->Trace(activation, &arena,
290 [&](int64_t id, const CelValue& value, google::protobuf::Arena* arena) {
291 ids[id] = value;
292 return absl::OkStatus();
293 }));
294
295 EXPECT_TRUE(result.IsInt64() && result.Int64OrDie() == 400)
296 << result.DebugString();
297
298 EXPECT_THAT(ids, Contains(Pair(4, IsCelInt64(20))));
299 EXPECT_THAT(ids, Contains(Pair(7, IsCelInt64(20))));
300}
301
302// Test bind expression with nested field selection.
303//

Callers

nothing calls this directly

Calls 7

RegisterBuiltinFunctionsFunction · 0.85
IsCelInt64Function · 0.85
GetRegistryMethod · 0.80
IsInt64Method · 0.80
Int64OrDieMethod · 0.80
DebugStringMethod · 0.45

Tested by

no test coverage detected