Skip to content
Snippets Groups Projects
Select Git revision
  • 0ebdb2d9de5df5fe1bf1cbf0a753d89d40a72bec
  • develop default protected
  • feature/advection
  • feature/composite-scheme-other-fluxes
  • origin/stage/bouguettaia
  • save_clemence
  • feature/local-dt-fsi
  • feature/variational-hydro
  • feature/gmsh-reader
  • feature/reconstruction
  • feature/kinetic-schemes
  • feature/composite-scheme-sources
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

test_ASTDotPrinter.cpp

Blame
  • test_ASTDotPrinter.cpp 1.83 KiB
    #include <catch2/catch.hpp>
    
    #include <ASTBuilder.hpp>
    #include <ASTDotPrinter.hpp>
    #include <sstream>
    
    #define CHECK_DOT(data, expected_output)                                                      \
      {                                                                                           \
        static_assert(std::is_same_v<std::decay_t<decltype(data)>, std::string_view>);            \
        static_assert(std::is_same_v<std::decay_t<decltype(expected_output)>, std::string_view>); \
                                                                                                  \
        string_input input{data, "test.pgs"};                                                     \
        auto ast = ASTBuilder::build(input);                                                      \
                                                                                                  \
        std::stringstream ast_output;                                                             \
        ast_output << '\n' << ASTDotPrinter{*ast};                                                \
                                                                                                  \
        REQUIRE(ast_output.str() == expected_output);                                             \
      }
    
    TEST_CASE("ASTDotPrinter", "[language]")
    {
      rang::setControlMode(rang::control::Off);
    
      std::string_view data = R"(
    N n = 2 + 3;
    )";
    
      std::string_view result = R"(
    digraph parse_tree
    {
      x0 [ label="root \nundefined" ]
      x0 -> { x1 }
      x1 [ label="language::declaration\nN n = 2 + 3\nundefined" ]
      x1 -> { x2, x3, x4 }
      x2 [ label="language::N_set\nN\nundefined" ]
      x3 [ label="language::name\nn\nundefined" ]
      x4 [ label="language::plus_op\nundefined" ]
      x4 -> { x5, x6 }
      x5 [ label="language::integer\n2\nundefined" ]
      x6 [ label="language::integer\n3\nundefined" ]
    }
    )";
      CHECK_DOT(data, result);
    }