This repository has been archived on 2024-03-07. You can view files and clone it, but cannot push or open issues/pull-requests.
wongola/tests/Parser.cpp

33 lines
582 B
C++
Raw Normal View History

#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");
}