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/Lexer.cpp

37 lines
641 B
C++
Raw Normal View History

#include <catch2/catch.hpp>
#include "../lib/Lexer.hpp"
class LexerTest
{
public:
explicit LexerTest() {}
virtual ~LexerTest() {}
void test_next(wg::Lexer& lexer, std::string const& oracle)
{
auto n = lexer.next();
REQUIRE(nullptr != n);
REQUIRE(oracle == n->string());
}
void test_end(wg::Lexer& lexer)
{
auto n = lexer.next();
REQUIRE(nullptr == n);
}
protected:
};
TEST_CASE_METHOD(LexerTest, "Lexer_")
{
wg::Lexer lex;
lex.scan(" # canard #canard");
test_next(lex, "HASH");
test_next(lex, "IDENT[canard]");
test_next(lex, "HASH");
test_next(lex, "IDENT[canard]");
test_end(lex);
}