| 36 | static auto Parse(const std::string& in) { return sql::ParseToIR(peg::string_input(in, "test")); } |
| 37 | |
| 38 | TEST(DotDumperTest, Simple) { |
| 39 | auto ir = *Parse("select a from b where c = 1 or d hastag \"x\" and 2 <= e order by e asc limit 0, 10"); |
| 40 | |
| 41 | std::stringstream ss; |
| 42 | DotDumper dumper{ss}; |
| 43 | |
| 44 | dumper.Dump(ir.get()); |
| 45 | |
| 46 | std::string dot = ss.str(); |
| 47 | std::smatch matches; |
| 48 | |
| 49 | std::regex_search(dot, matches, std::regex(R"((\w+) \[ label = "SearchStmt)")); |
| 50 | auto search_stmt = matches[1].str(); |
| 51 | |
| 52 | std::regex_search(dot, matches, std::regex(R"((\w+) \[ label = "OrExpr)")); |
| 53 | auto or_expr = matches[1].str(); |
| 54 | |
| 55 | std::regex_search(dot, matches, std::regex(R"((\w+) \[ label = "AndExpr)")); |
| 56 | auto and_expr = matches[1].str(); |
| 57 | |
| 58 | ASSERT_NE(dot.find(fmt::format("{} -> {}", search_stmt, or_expr)), std::string::npos); |
| 59 | ASSERT_NE(dot.find(fmt::format("{} -> {}", or_expr, and_expr)), std::string::npos); |
| 60 | } |
| 61 | |
| 62 | static auto ParseS(SemaChecker& sc, const std::string& in) { |
| 63 | auto ir = *Parse(in); |
nothing calls this directly
no test coverage detected