From 9f69b006dde3c3fbe19ed3e0275d3b7348f2aa87 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 15 Mar 2020 18:19:49 +0100 Subject: New lexer --- test-lexer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test-lexer.cpp') diff --git a/test-lexer.cpp b/test-lexer.cpp index a94e550..9f1cb77 100644 --- a/test-lexer.cpp +++ b/test-lexer.cpp @@ -1,5 +1,6 @@ #include "bnf.h" #include "cpp.h" +#include "cppbnf.h" #include "lexer.h" #include "grammer.h" #include "minicc.h" @@ -19,14 +20,20 @@ #include #include -class Test: public ::testing::Test { +class LexerTest: public ::testing::Test { protected: - Test(){ + LexerTest(){ debug = false; } - ~Test() override {} + ~LexerTest() override {} }; -TEST_F(Test, BNF) { -} +TEST_F(LexerTest, Lex) { + auto bnf{SubBNF(GetCppBNFLex(), "preprocessing-token")}; + + Lex::Lexer lexer(bnf, "preprocessing-token"); + std::vector tokens{lexer.Lex("int main() { return 1; }")}; + + ASSERT_EQ(tokens.size(), 9); +} -- cgit v1.2.3