| 54 | using ::testing::UnorderedElementsAre; |
| 55 | |
| 56 | absl::StatusOr<CelValue> MakeCelMap(absl::string_view expr, |
| 57 | google::protobuf::Arena* arena) { |
| 58 | static CelExpressionBuilder* builder = []() { |
| 59 | return CreateCelExpressionBuilder(InterpreterOptions()).release(); |
| 60 | }(); |
| 61 | static absl::NoDestructor<Activation> activation; |
| 62 | |
| 63 | CEL_ASSIGN_OR_RETURN(ParsedExpr parsed_expr, Parse(expr)); |
| 64 | |
| 65 | CEL_ASSIGN_OR_RETURN(auto plan, |
| 66 | builder->CreateExpression(&parsed_expr.expr(), nullptr)); |
| 67 | absl::StatusOr<CelValue> result = plan->Evaluate(*activation, arena); |
| 68 | if (!result.ok()) { |
| 69 | return result.status(); |
| 70 | } |
| 71 | if (!result->IsMap()) { |
| 72 | return absl::FailedPreconditionError( |
| 73 | absl::StrCat("expression did not evaluate to a map: ", expr)); |
| 74 | } |
| 75 | return result; |
| 76 | } |
| 77 | |
| 78 | enum class FunctionResponse { kUnknown, kTrue, kFalse }; |
| 79 |
nothing calls this directly
no test coverage detected