• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2012 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #include "PreprocessorTest.h"
8 #include "compiler/preprocessor/Token.h"
9 
10 namespace angle
11 {
12 
13 struct OperatorTestParam
14 {
15     const char *str;
16     int op;
17 };
18 
19 class OperatorTest : public SimplePreprocessorTest,
20                      public testing::WithParamInterface<OperatorTestParam>
21 {};
22 
TEST_P(OperatorTest,Identified)23 TEST_P(OperatorTest, Identified)
24 {
25     OperatorTestParam param = GetParam();
26 
27     pp::Token token;
28     lexSingleToken(param.str, &token);
29     EXPECT_EQ(param.op, token.type);
30     EXPECT_EQ(param.str, token.text);
31 }
32 
33 static const OperatorTestParam kOperators[] = {{"(", '('},
34                                                {")", ')'},
35                                                {"[", '['},
36                                                {"]", ']'},
37                                                {".", '.'},
38                                                {"+", '+'},
39                                                {"-", '-'},
40                                                {"~", '~'},
41                                                {"!", '!'},
42                                                {"*", '*'},
43                                                {"/", '/'},
44                                                {"%", '%'},
45                                                {"<", '<'},
46                                                {">", '>'},
47                                                {"&", '&'},
48                                                {"^", '^'},
49                                                {"|", '|'},
50                                                {"?", '?'},
51                                                {":", ':'},
52                                                {"=", '='},
53                                                {",", ','},
54                                                {"++", pp::Token::OP_INC},
55                                                {"--", pp::Token::OP_DEC},
56                                                {"<<", pp::Token::OP_LEFT},
57                                                {">>", pp::Token::OP_RIGHT},
58                                                {"<=", pp::Token::OP_LE},
59                                                {">=", pp::Token::OP_GE},
60                                                {"==", pp::Token::OP_EQ},
61                                                {"!=", pp::Token::OP_NE},
62                                                {"&&", pp::Token::OP_AND},
63                                                {"^^", pp::Token::OP_XOR},
64                                                {"||", pp::Token::OP_OR},
65                                                {"+=", pp::Token::OP_ADD_ASSIGN},
66                                                {"-=", pp::Token::OP_SUB_ASSIGN},
67                                                {"*=", pp::Token::OP_MUL_ASSIGN},
68                                                {"/=", pp::Token::OP_DIV_ASSIGN},
69                                                {"%=", pp::Token::OP_MOD_ASSIGN},
70                                                {"<<=", pp::Token::OP_LEFT_ASSIGN},
71                                                {">>=", pp::Token::OP_RIGHT_ASSIGN},
72                                                {"&=", pp::Token::OP_AND_ASSIGN},
73                                                {"^=", pp::Token::OP_XOR_ASSIGN},
74                                                {"|=", pp::Token::OP_OR_ASSIGN}};
75 
76 INSTANTIATE_TEST_SUITE_P(All, OperatorTest, testing::ValuesIn(kOperators));
77 
78 }  // namespace angle
79