32 lines
658 B
C++
32 lines
658 B
C++
#include <catch2/catch.hpp>
|
|
#include "../src/Parser.hpp"
|
|
#include "../src/Lexer.hpp"
|
|
|
|
class ParserTest
|
|
{
|
|
public:
|
|
explicit ParserTest() {}
|
|
virtual ~ParserTest() {}
|
|
|
|
void test_parse(std::string const& oracle, std::string const& source)
|
|
{
|
|
auto root = m_parser.parse(source);
|
|
REQUIRE(oracle == root->string());
|
|
}
|
|
|
|
protected:
|
|
grino::Logger m_logger;
|
|
grino::Lexer m_lexer {m_logger, "tests/parser"};
|
|
grino::Parser m_parser {m_logger, m_lexer};
|
|
};
|
|
|
|
TEST_CASE_METHOD(ParserTest, "Parser_empty")
|
|
{
|
|
test_parse("MODULE", "");
|
|
}
|
|
|
|
TEST_CASE_METHOD(ParserTest, "Parser_booleans")
|
|
{
|
|
test_parse("MODULE(BOOL[true],BOOL[false])", "true false");
|
|
}
|