MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / TEST_P

Function TEST_P

extensions/strings_test.cc:134–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132using StringsExtFunctionsTest = testing::TestWithParam<std::string>;
133
134TEST_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
173INSTANTIATE_TEST_SUITE_P(
174 StringsExtMacrosParamsTest, StringsExtFunctionsTest,

Callers

nothing calls this directly

Calls 15

StandardCompilerLibraryFunction · 0.85
StringsCompilerLibraryFunction · 0.85
RegisterStringsFunctionsFunction · 0.85
CreateProgramFunction · 0.85
CompilerOptionsClass · 0.85
IsValidMethod · 0.80
codeMethod · 0.80
GetIssuesMethod · 0.80
FormatErrorMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.50
NewCompilerBuilderFunction · 0.50
AddLibraryMethod · 0.45

Tested by

no test coverage detected