| 270 | })pb"; |
| 271 | |
| 272 | TEST(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 | // |
nothing calls this directly
no test coverage detected