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

Function TEST

eval/compiler/flat_expr_builder_test.cc:147–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145};
146
147TEST(FlatExprBuilderTest, SimpleEndToEnd) {
148 Expr expr;
149 SourceInfo source_info;
150 auto call_expr = expr.mutable_call_expr();
151 call_expr->set_function("concat");
152
153 auto arg1 = call_expr->add_args();
154 arg1->mutable_const_expr()->set_string_value("prefix");
155
156 auto arg2 = call_expr->add_args();
157 arg2->mutable_ident_expr()->set_name("value");
158
159 CelExpressionBuilderFlatImpl builder(NewTestingRuntimeEnv());
160
161 ASSERT_THAT(
162 builder.GetRegistry()->Register(std::make_unique<ConcatFunction>()),
163 IsOk());
164 ASSERT_OK_AND_ASSIGN(auto cel_expr,
165 builder.CreateExpression(&expr, &source_info));
166
167 std::string variable = "test";
168
169 Activation activation;
170 activation.InsertValue("value", CelValue::CreateString(&variable));
171
172 google::protobuf::Arena arena;
173
174 ASSERT_OK_AND_ASSIGN(CelValue result, cel_expr->Evaluate(activation, &arena));
175 ASSERT_TRUE(result.IsString());
176 EXPECT_THAT(result.StringOrDie().value(), Eq("prefixtest"));
177}
178
179TEST(FlatExprBuilderTest, ExprUnset) {
180 Expr expr;

Callers 1

ASSERT_OK_AND_ASSIGNFunction · 0.70

Calls 15

RegisterBuiltinFunctionsFunction · 0.85
IsCelBoolFunction · 0.85
CreateContainerBackedMapFunction · 0.85
RunTernaryExpressionFunction · 0.85
CreateErrorValueFunction · 0.85
IsCelInt64Function · 0.85
IsCelStringFunction · 0.85
IsCelErrorFunction · 0.85
set_functionMethod · 0.80

Tested by

no test coverage detected