| 1444 | } |
| 1445 | |
| 1446 | std::string ConvertMacroCallsToString( |
| 1447 | const cel::expr::SourceInfo& source_info) { |
| 1448 | KindAndIdAdorner macro_calls_adorner(source_info); |
| 1449 | ExprPrinter w(macro_calls_adorner); |
| 1450 | // Use a list so we can sort the macro calls ensuring order for appending |
| 1451 | std::vector<std::pair<int64_t, cel::expr::Expr>> macro_calls; |
| 1452 | for (auto pair : source_info.macro_calls()) { |
| 1453 | // Set ID to the map key for the adorner |
| 1454 | pair.second.set_id(pair.first); |
| 1455 | macro_calls.push_back(pair); |
| 1456 | } |
| 1457 | // Sort in reverse because the first macro will have the highest id |
| 1458 | absl::c_sort(macro_calls, |
| 1459 | [](const std::pair<int64_t, cel::expr::Expr>& p1, |
| 1460 | const std::pair<int64_t, cel::expr::Expr>& p2) { |
| 1461 | return p1.first > p2.first; |
| 1462 | }); |
| 1463 | std::string result = ""; |
| 1464 | for (const auto& pair : macro_calls) { |
| 1465 | result += w.PrintProto(pair.second) += ",\n"; |
| 1466 | } |
| 1467 | // substring last ",\n" |
| 1468 | return result.substr(0, result.size() - 3); |
| 1469 | } |
| 1470 | |
| 1471 | class ExpressionTest : public testing::TestWithParam<TestInfo> {}; |
| 1472 |
no test coverage detected