37 lines
641 B
C++
37 lines
641 B
C++
#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);
|
|
}
|