Helper method. Creates simple pipeline containing Select step and runs it.
| 107 | |
| 108 | // Helper method. Creates simple pipeline containing Select step and runs it. |
| 109 | absl::StatusOr<CelValue> RunExpressionWithCelValues( |
| 110 | const absl_nonnull std::shared_ptr<const RuntimeEnv>& env, |
| 111 | const std::vector<CelValue>& values, google::protobuf::Arena* arena, |
| 112 | bool enable_unknowns) { |
| 113 | ExecutionPath path; |
| 114 | Expr dummy_expr; |
| 115 | |
| 116 | Activation activation; |
| 117 | auto& create_list = dummy_expr.mutable_list_expr(); |
| 118 | int ind = 0; |
| 119 | for (auto value : values) { |
| 120 | std::string var_name = absl::StrCat("name_", ind++); |
| 121 | auto& expr0 = create_list.mutable_elements().emplace_back().mutable_expr(); |
| 122 | expr0.set_id(ind); |
| 123 | expr0.mutable_ident_expr().set_name(var_name); |
| 124 | |
| 125 | CEL_ASSIGN_OR_RETURN(auto ident_step, |
| 126 | CreateIdentStep(var_name, /*expr_id=*/-1)); |
| 127 | path.push_back(std::move(ident_step)); |
| 128 | activation.InsertValue(var_name, value); |
| 129 | } |
| 130 | |
| 131 | CEL_ASSIGN_OR_RETURN(auto step0, |
| 132 | CreateCreateListStep(create_list, dummy_expr.id())); |
| 133 | path.push_back(std::move(step0)); |
| 134 | |
| 135 | cel::RuntimeOptions options; |
| 136 | if (enable_unknowns) { |
| 137 | options.unknown_processing = cel::UnknownProcessingOptions::kAttributeOnly; |
| 138 | } |
| 139 | |
| 140 | CelExpressionFlatImpl cel_expr( |
| 141 | env, |
| 142 | FlatExpression(std::move(path), /*comprehension_slot_count=*/0, |
| 143 | env->type_registry.GetComposedTypeProvider(), options)); |
| 144 | |
| 145 | return cel_expr.Evaluate(activation, arena); |
| 146 | } |
| 147 | |
| 148 | class CreateListStepTest : public testing::TestWithParam<bool> { |
| 149 | public: |
nothing calls this directly
no test coverage detected