summaryrefslogtreecommitdiffhomepage
path: root/tests/test-lexer.cpp
blob: 23983f116bae4228f0d9aa78377f48ffc4ebb056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
}