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

Function MakeCelMap

eval/tests/unknowns_end_to_end_test.cc:56–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54using ::testing::UnorderedElementsAre;
55
56absl::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
78enum class FunctionResponse { kUnknown, kTrue, kFalse };
79

Callers

nothing calls this directly

Calls 5

releaseMethod · 0.45
EvaluateMethod · 0.45
okMethod · 0.45
IsMapMethod · 0.45

Tested by

no test coverage detected