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

Function TEST_P

parser/parser_test.cc:1473–1522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1471class ExpressionTest : public testing::TestWithParam<TestInfo> {};
1472
1473TEST_P(ExpressionTest, Parse) {
1474 const TestInfo& test_info = GetParam();
1475 ParserOptions options;
1476 options.enable_hidden_accumulator_var = true;
1477 if (!test_info.M.empty()) {
1478 options.add_macro_calls = true;
1479 }
1480 options.enable_optional_syntax = true;
1481 options.enable_quoted_identifiers = true;
1482
1483 std::vector<Macro> macros = Macro::AllMacros();
1484 macros.push_back(cel::OptMapMacro());
1485 macros.push_back(cel::OptFlatMapMacro());
1486 auto result = EnrichedParse(test_info.I, macros, "<input>", options);
1487 if (test_info.E.empty()) {
1488 ASSERT_THAT(result, IsOk());
1489 } else {
1490 EXPECT_THAT(result, Not(IsOk()));
1491 EXPECT_EQ(test_info.E, result.status().message());
1492 }
1493
1494 if (!test_info.P.empty()) {
1495 KindAndIdAdorner kind_and_id_adorner;
1496 ExprPrinter w(kind_and_id_adorner);
1497 std::string adorned_string = w.PrintProto(result->parsed_expr().expr());
1498 EXPECT_EQ(test_info.P, adorned_string)
1499 << result->parsed_expr().ShortDebugString();
1500 }
1501
1502 if (!test_info.L.empty()) {
1503 LocationAdorner location_adorner(result->parsed_expr().source_info());
1504 ExprPrinter w(location_adorner);
1505 std::string adorned_string = w.PrintProto(result->parsed_expr().expr());
1506 EXPECT_EQ(test_info.L, adorned_string)
1507 << result->parsed_expr().ShortDebugString();
1508 ;
1509 }
1510
1511 if (!test_info.R.empty()) {
1512 EXPECT_EQ(test_info.R, ConvertEnrichedSourceInfoToString(
1513 result->enriched_source_info()));
1514 }
1515
1516 if (!test_info.M.empty()) {
1517 EXPECT_EQ(test_info.M, ConvertMacroCallsToString(
1518 result.value().parsed_expr().source_info()))
1519 << result->parsed_expr().ShortDebugString();
1520 ;
1521 }
1522}
1523
1524TEST(ExpressionTest, TsanOom) {
1525 Parse(

Callers

nothing calls this directly

Calls 11

AllMacrosFunction · 0.85
EnrichedParseFunction · 0.85
messageMethod · 0.80
PrintProtoMethod · 0.80
source_infoMethod · 0.80
enriched_source_infoMethod · 0.80
emptyMethod · 0.45
exprMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected