33 lines
582 B
C++
33 lines
582 B
C++
#include <catch2/catch.hpp>
|
|
#include "../lib/Lexer.hpp"
|
|
#include "../lib/Parser.hpp"
|
|
|
|
class ParserTest
|
|
{
|
|
public:
|
|
explicit ParserTest() {}
|
|
virtual ~ParserTest() {}
|
|
|
|
void test_parse(std::string const& oracle,
|
|
std::string const& source)
|
|
{
|
|
wg::Lexer lex;
|
|
lex.scan(source);
|
|
auto tokens = lex.all();
|
|
|
|
wg::Parser parser;
|
|
|
|
auto node = parser.parse(tokens);
|
|
|
|
REQUIRE(oracle == node->string());
|
|
}
|
|
|
|
protected:
|
|
};
|
|
|
|
TEST_CASE_METHOD(ParserTest, "Parser_")
|
|
{
|
|
test_parse("PROG(DIR(IDENT[hello],IDENT[world]))",
|
|
"#hello world");
|
|
}
|