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

Function TEST

extensions/math_ext_test.cc:281–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279 }));
280
281TEST(MathExtTest, MinMaxList) {
282 ContainerBackedListImpl single_item_list({CelValue::CreateInt64(1)});
283 ExpectResult(MinCase(CelValue::CreateList(&single_item_list),
284 CelValue::CreateInt64(1)));
285 ExpectResult(MaxCase(CelValue::CreateList(&single_item_list),
286 CelValue::CreateInt64(1)));
287
288 ContainerBackedListImpl list({CelValue::CreateInt64(1),
289 CelValue::CreateUint64(2u),
290 CelValue::CreateDouble(-1.1)});
291 ExpectResult(
292 MinCase(CelValue::CreateList(&list), CelValue::CreateDouble(-1.1)));
293 ExpectResult(
294 MaxCase(CelValue::CreateList(&list), CelValue::CreateUint64(2u)));
295
296 absl::Status empty_list_err =
297 absl::InvalidArgumentError("argument must not be empty");
298 CelValue err_value = CelValue::CreateError(&empty_list_err);
299 ContainerBackedListImpl empty_list({});
300 ExpectResult(MinCase(CelValue::CreateList(&empty_list), err_value));
301 ExpectResult(MaxCase(CelValue::CreateList(&empty_list), err_value));
302
303 absl::Status bad_arg_err =
304 absl::InvalidArgumentError("arguments must be numeric");
305 err_value = CelValue::CreateError(&bad_arg_err);
306
307 ContainerBackedListImpl bad_single_item({CelValue::CreateBool(true)});
308 ExpectResult(MinCase(CelValue::CreateList(&bad_single_item), err_value));
309 ExpectResult(MaxCase(CelValue::CreateList(&bad_single_item), err_value));
310
311 ContainerBackedListImpl bad_middle_item({CelValue::CreateInt64(1),
312 CelValue::CreateBool(false),
313 CelValue::CreateDouble(-1.1)});
314 ExpectResult(MinCase(CelValue::CreateList(&bad_middle_item), err_value));
315 ExpectResult(MaxCase(CelValue::CreateList(&bad_middle_item), err_value));
316}
317
318using MathExtMacroParamsTest = testing::TestWithParam<MacroTestCase>;
319TEST_P(MathExtMacroParamsTest, ParserTests) {

Callers

nothing calls this directly

Calls 5

MinCaseFunction · 0.85
MaxCaseFunction · 0.85
ExpectResultFunction · 0.70
CreateListFunction · 0.50
CreateErrorFunction · 0.50

Tested by

no test coverage detected