diff options
Diffstat (limited to 'tests/test-lexer.cpp')
-rw-r--r-- | tests/test-lexer.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test-lexer.cpp b/tests/test-lexer.cpp new file mode 100644 index 0000000..23983f1 --- /dev/null +++ b/tests/test-lexer.cpp @@ -0,0 +1,39 @@ +#include "bnf.h" +#include "cpp.h" +#include "cppbnf.h" +#include "lexer.h" +#include "grammer.h" +#include "minicc.h" +#include "debug.h" + +#include <boost/algorithm/string.hpp> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include <algorithm> +#include <cctype> +#include <deque> +#include <map> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +class LexerTest: public ::testing::Test { +protected: + LexerTest(){ + debug = false; + } + ~LexerTest() override {} +}; + +TEST_F(LexerTest, Lex) { + auto bnf{SubBNF(CPPBNF::GetCppBNFLex(), "preprocessing-token")}; + + Lex::Lexer lexer(bnf, "preprocessing-token"); + + std::vector<Token> tokens{lexer.Lex("int main() { return 1; }")}; + + ASSERT_EQ(tokens.size(), 9); +} |