| 526 | } |
| 527 | |
| 528 | TEST(TestRunnerStandaloneTest, RunTestFailsWhenNoExpressionSourceIsProvided) { |
| 529 | const std::string expected_error = |
| 530 | "INVALID_ARGUMENT: No expression source provided."; |
| 531 | |
| 532 | EXPECT_FATAL_FAILURE( |
| 533 | { |
| 534 | // Create a runtime. |
| 535 | ASSERT_OK_AND_ASSIGN(std::unique_ptr<const cel::Runtime> runtime, |
| 536 | CreateTestRuntime()); |
| 537 | TestCase test_case = ParseTextProtoOrDie<TestCase>(R"pb( |
| 538 | input { |
| 539 | key: "x" |
| 540 | value { value { int64_value: 10 } } |
| 541 | } |
| 542 | input { |
| 543 | key: "y" |
| 544 | value { value { int64_value: 3 } } |
| 545 | } |
| 546 | output { result_value { int64_value: 123 } } |
| 547 | )pb"); |
| 548 | ASSERT_OK_AND_ASSIGN(std::unique_ptr<cel::Compiler> compiler, |
| 549 | CreateBasicCompiler()); |
| 550 | |
| 551 | // Create a TestRunner but without an expression source. |
| 552 | std::unique_ptr<CelTestContext> context = |
| 553 | CelTestContext::CreateFromRuntime(std::move(runtime)); |
| 554 | context->SetCompiler(std::move(compiler)); |
| 555 | TestRunner test_runner(std::move(context)); |
| 556 | test_runner.RunTest(test_case); |
| 557 | }, |
| 558 | expected_error); |
| 559 | } |
| 560 | |
| 561 | TEST(TestRunnerStandaloneTest, BasicTestWithErrorAssertion) { |
| 562 | // Compile the expression. |
no test coverage detected