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

Function TEST_P

eval/eval/create_struct_step_test.cc:198–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196};
197
198TEST_P(CreateCreateStructStepTest, TestEmptyMessageCreation) {
199 ExecutionPath path;
200
201 auto adapter = env_->legacy_type_registry.FindTypeAdapter(
202 "google.api.expr.runtime.TestMessage");
203 ASSERT_TRUE(adapter.has_value() && adapter->mutation_apis() != nullptr);
204
205 ASSERT_OK_AND_ASSIGN(auto maybe_type,
206 env_->type_registry.GetComposedTypeProvider().FindType(
207 "google.api.expr.runtime.TestMessage"));
208 ASSERT_TRUE(maybe_type.has_value());
209 if (enable_recursive_planning()) {
210 auto step =
211 CreateDirectCreateStructStep("google.api.expr.runtime.TestMessage",
212 /*fields=*/{},
213 /*deps=*/{},
214 /*optional_indices=*/{},
215 /*id=*/-1);
216 path.push_back(
217 std::make_unique<WrappedDirectStep>(std::move(step), /*id=*/-1));
218 } else {
219 auto step = CreateCreateStructStep("google.api.expr.runtime.TestMessage",
220 /*fields=*/{},
221 /*optional_indices=*/{},
222 /*id=*/-1);
223 path.push_back(std::move(step));
224 }
225
226 cel::RuntimeOptions options;
227 if (enable_unknowns(), enable_recursive_planning()) {
228 options.unknown_processing = cel::UnknownProcessingOptions::kAttributeOnly;
229 }
230 CelExpressionFlatImpl cel_expr(
231 env_,
232 FlatExpression(std::move(path), /*comprehension_slot_count=*/0,
233 env_->type_registry.GetComposedTypeProvider(), options));
234 Activation activation;
235
236 ASSERT_OK_AND_ASSIGN(CelValue result, cel_expr.Evaluate(activation, &arena_));
237 ASSERT_TRUE(result.IsMessage()) << result.DebugString();
238 const Message* msg = result.MessageOrDie();
239 ASSERT_THAT(msg, Not(IsNull()));
240
241 ASSERT_EQ(msg->GetDescriptor()->full_name(),
242 "google.api.expr.runtime.TestMessage");
243}
244
245TEST(CreateCreateStructStepTest, TestMessageCreateError) {
246 absl_nonnull std::shared_ptr<const RuntimeEnv> env = NewTestingRuntimeEnv();

Callers

nothing calls this directly

Calls 15

CreateCreateStructStepFunction · 0.85
FlatExpressionClass · 0.85
EqualsProtoFunction · 0.85
CreateContainerBackedMapFunction · 0.85
FindTypeAdapterMethod · 0.80
mutation_apisMethod · 0.80
MessageOrDieMethod · 0.80
atMethod · 0.80
CreateMapFunction · 0.50
has_valueMethod · 0.45

Tested by

no test coverage detected