Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: tools/gn/tokenizer_unittest.cc

Issue 207233003: Add "." accessors to GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/tokenizer.cc ('k') | tools/gn/value.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/input_file.h" 6 #include "tools/gn/input_file.h"
7 #include "tools/gn/token.h" 7 #include "tools/gn/token.h"
8 #include "tools/gn/tokenizer.h" 8 #include "tools/gn/tokenizer.h"
9 9
10 namespace { 10 namespace {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 { Token::MINUS_EQUALS, "-=" }, 92 { Token::MINUS_EQUALS, "-=" },
93 { Token::NOT_EQUAL, "!=" }, 93 { Token::NOT_EQUAL, "!=" },
94 { Token::EQUAL_EQUAL, "==" }, 94 { Token::EQUAL_EQUAL, "==" },
95 { Token::LESS_THAN, "<" }, 95 { Token::LESS_THAN, "<" },
96 { Token::GREATER_THAN, ">" }, 96 { Token::GREATER_THAN, ">" },
97 { Token::LESS_EQUAL, "<=" }, 97 { Token::LESS_EQUAL, "<=" },
98 { Token::GREATER_EQUAL, ">=" }, 98 { Token::GREATER_EQUAL, ">=" },
99 { Token::BANG, "!" }, 99 { Token::BANG, "!" },
100 { Token::BOOLEAN_OR, "||" }, 100 { Token::BOOLEAN_OR, "||" },
101 { Token::BOOLEAN_AND, "&&" }, 101 { Token::BOOLEAN_AND, "&&" },
102 { Token::DOT, "." },
103 { Token::COMMA, "," },
102 }; 104 };
103 EXPECT_TRUE(CheckTokenizer("- + = += -= != == < > <= >= ! || &&", 105 EXPECT_TRUE(CheckTokenizer("- + = += -= != == < > <= >= ! || && . ,",
104 operators)); 106 operators));
105 } 107 }
106 108
107 TEST(Tokenizer, Scoper) { 109 TEST(Tokenizer, Scoper) {
108 TokenExpectation scopers[] = { 110 TokenExpectation scopers[] = {
109 { Token::LEFT_BRACE, "{" }, 111 { Token::LEFT_BRACE, "{" },
110 { Token::LEFT_BRACKET, "[" }, 112 { Token::LEFT_BRACKET, "[" },
111 { Token::RIGHT_BRACKET, "]" }, 113 { Token::RIGHT_BRACKET, "]" },
112 { Token::RIGHT_BRACE, "}" }, 114 { Token::RIGHT_BRACE, "}" },
113 { Token::LEFT_PAREN, "(" }, 115 { Token::LEFT_PAREN, "(" },
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 EXPECT_EQ('x', input1[Tokenizer::ByteOffsetOfNthLine(input1, 2)]); 166 EXPECT_EQ('x', input1[Tokenizer::ByteOffsetOfNthLine(input1, 2)]);
165 EXPECT_EQ('y', input1[Tokenizer::ByteOffsetOfNthLine(input1, 4)]); 167 EXPECT_EQ('y', input1[Tokenizer::ByteOffsetOfNthLine(input1, 4)]);
166 168
167 char input2[3]; 169 char input2[3];
168 input2[0] = 'a'; 170 input2[0] = 'a';
169 input2[1] = '\n'; // Manually set to avoid Windows double-byte endings. 171 input2[1] = '\n'; // Manually set to avoid Windows double-byte endings.
170 input2[2] = 0; 172 input2[2] = 0;
171 EXPECT_EQ(0u, Tokenizer::ByteOffsetOfNthLine(input2, 1)); 173 EXPECT_EQ(0u, Tokenizer::ByteOffsetOfNthLine(input2, 1));
172 EXPECT_EQ(2u, Tokenizer::ByteOffsetOfNthLine(input2, 2)); 174 EXPECT_EQ(2u, Tokenizer::ByteOffsetOfNthLine(input2, 2));
173 } 175 }
OLDNEW
« no previous file with comments | « tools/gn/tokenizer.cc ('k') | tools/gn/value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698