| 132 | using StringsExtFunctionsTest = testing::TestWithParam<std::string>; |
| 133 | |
| 134 | TEST_P(StringsExtFunctionsTest, ParserAndCheckerTests) { |
| 135 | const std::string& expr = GetParam(); |
| 136 | |
| 137 | ASSERT_OK_AND_ASSIGN( |
| 138 | auto compiler_builder, |
| 139 | NewCompilerBuilder(internal::GetTestingDescriptorPool())); |
| 140 | |
| 141 | ASSERT_THAT(compiler_builder->AddLibrary(StandardCompilerLibrary()), IsOk()); |
| 142 | ASSERT_THAT(compiler_builder->AddLibrary(StringsCompilerLibrary()), IsOk()); |
| 143 | |
| 144 | ASSERT_OK_AND_ASSIGN(auto compiler, std::move(*compiler_builder).Build()); |
| 145 | |
| 146 | auto result = compiler->Compile(expr, "<input>"); |
| 147 | |
| 148 | ASSERT_THAT(result, IsOk()); |
| 149 | ASSERT_TRUE(result->IsValid()); |
| 150 | |
| 151 | RuntimeOptions opts; |
| 152 | ASSERT_OK_AND_ASSIGN( |
| 153 | auto runtime_builder, |
| 154 | CreateStandardRuntimeBuilder(internal::GetTestingDescriptorPool(), opts)); |
| 155 | |
| 156 | ASSERT_THAT( |
| 157 | RegisterStringsFunctions(runtime_builder.function_registry(), opts), |
| 158 | IsOk()); |
| 159 | |
| 160 | ASSERT_OK_AND_ASSIGN(auto runtime, std::move(runtime_builder).Build()); |
| 161 | |
| 162 | ASSERT_OK_AND_ASSIGN(auto program, |
| 163 | runtime->CreateProgram(*result->ReleaseAst())); |
| 164 | |
| 165 | google::protobuf::Arena arena; |
| 166 | cel::Activation activation; |
| 167 | ASSERT_OK_AND_ASSIGN(auto value, program->Evaluate(&arena, activation)); |
| 168 | |
| 169 | ASSERT_TRUE(value.Is<BoolValue>()); |
| 170 | EXPECT_TRUE(value.GetBool().NativeValue()); |
| 171 | } |
| 172 | |
| 173 | INSTANTIATE_TEST_SUITE_P( |
| 174 | StringsExtMacrosParamsTest, StringsExtFunctionsTest, |
nothing calls this directly
no test coverage detected