| 76 | class ConstantFoldingExtTest : public testing::TestWithParam<TestCase> {}; |
| 77 | |
| 78 | TEST_P(ConstantFoldingExtTest, Runner) { |
| 79 | google::protobuf::Arena arena; |
| 80 | RuntimeOptions options; |
| 81 | const TestCase& test_case = GetParam(); |
| 82 | ASSERT_OK_AND_ASSIGN(cel::RuntimeBuilder builder, |
| 83 | CreateStandardRuntimeBuilder( |
| 84 | internal::GetTestingDescriptorPool(), options)); |
| 85 | |
| 86 | auto status = BinaryFunctionAdapter<absl::StatusOr<Value>, const StringValue&, |
| 87 | const StringValue&>:: |
| 88 | RegisterGlobalOverload( |
| 89 | "prepend", |
| 90 | [](const StringValue& value, const StringValue& prefix) { |
| 91 | return StringValue( |
| 92 | absl::StrCat(prefix.ToString(), value.ToString())); |
| 93 | }, |
| 94 | builder.function_registry()); |
| 95 | ASSERT_THAT(status, IsOk()); |
| 96 | |
| 97 | ASSERT_THAT(EnableConstantFolding(builder), IsOk()); |
| 98 | |
| 99 | ASSERT_OK_AND_ASSIGN(auto runtime, std::move(builder).Build()); |
| 100 | |
| 101 | ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, Parse(test_case.expression)); |
| 102 | |
| 103 | ASSERT_OK_AND_ASSIGN(auto program, ProtobufRuntimeAdapter::CreateProgram( |
| 104 | *runtime, parsed_expr)); |
| 105 | Activation activation; |
| 106 | |
| 107 | auto result = program->Evaluate(&arena, activation); |
| 108 | if (test_case.status.ok()) { |
| 109 | ASSERT_OK_AND_ASSIGN(Value value, std::move(result)); |
| 110 | |
| 111 | EXPECT_THAT(value, test_case.result_matcher); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | EXPECT_THAT(result.status(), StatusIs(test_case.status.code(), |
| 116 | HasSubstr(test_case.status.message()))); |
| 117 | } |
| 118 | |
| 119 | INSTANTIATE_TEST_SUITE_P( |
| 120 | Cases, ConstantFoldingExtTest, |
nothing calls this directly
no test coverage detected