#include #include "../src/fol/Lexer.hpp" using namespace sp::fol; class LexerTest { public: explicit LexerTest() {} virtual ~LexerTest() {} void test_next(Lexer& lexer, std::string const& oracle) { auto token = lexer.next(); REQUIRE(nullptr != token); REQUIRE(oracle == token->string()); } void test_end(Lexer& lexer) { auto token = lexer.next(); REQUIRE(nullptr == token); } protected: }; TEST_CASE_METHOD(LexerTest, "Lexer_var") { Lexer lexer; lexer.scan("hello"); test_next(lexer, "VAR[hello]"); test_end(lexer); } TEST_CASE_METHOD(LexerTest, "Lexer_operators") { Lexer lexer; lexer.scan("&!salut|(monde)->hello"); test_next(lexer, "AND"); test_next(lexer, "NOT"); test_next(lexer, "VAR[salut]"); test_next(lexer, "OR"); test_next(lexer, "OPAR"); test_next(lexer, "VAR[monde]"); test_next(lexer, "CPAR"); test_next(lexer, "IMP"); test_next(lexer, "VAR[hello]"); test_end(lexer); } TEST_CASE_METHOD(LexerTest, "Lexer_pred") { Lexer lexer; lexer.scan("Hello"); test_next(lexer, "PRED[Hello]"); test_end(lexer); } TEST_CASE_METHOD(LexerTest, "Lexer_const") { Lexer lexer; lexer.scan("HELLO"); test_next(lexer, "CONST[HELLO]"); test_end(lexer); }