| 418 | } |
| 419 | |
| 420 | void TestRunner::RunTest(const TestCase& test_case) { |
| 421 | // The arena has to be declared in RunTest because cel::Value returned by |
| 422 | // EvalWithRuntime or EvalWithCelExpressionBuilder might contain pointers to |
| 423 | // the arena. The arena has to be alive during the assertion. |
| 424 | google::protobuf::Arena arena; |
| 425 | ASSERT_THAT(EnableCoverage(), absl_testing::IsOk()); |
| 426 | ASSERT_OK_AND_ASSIGN(CheckedExpr checked_expr, GetCheckedExpr()); |
| 427 | |
| 428 | if (coverage_index_) { |
| 429 | coverage_index_->Init(checked_expr); |
| 430 | } |
| 431 | |
| 432 | if (test_context_->runtime() != nullptr) { |
| 433 | ASSERT_OK_AND_ASSIGN(cel::Value result, |
| 434 | EvalWithRuntime(checked_expr, test_case, &arena)); |
| 435 | ASSERT_NO_FATAL_FAILURE(Assert(result, test_case, &arena)); |
| 436 | } else if (test_context_->cel_expression_builder() != nullptr) { |
| 437 | ASSERT_OK_AND_ASSIGN( |
| 438 | cel::Value result, |
| 439 | EvalWithCelExpressionBuilder(checked_expr, test_case, &arena)); |
| 440 | ASSERT_NO_FATAL_FAILURE(Assert(result, test_case, &arena)); |
| 441 | } |
| 442 | } |
| 443 | } // namespace cel::test |