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

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

Issue 1411573002: Handle Mozilla license blocks in the GN header checker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « tools/gn/c_include_iterator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/c_include_iterator.h" 6 #include "tools/gn/c_include_iterator.h"
7 #include "tools/gn/input_file.h" 7 #include "tools/gn/input_file.h"
8 #include "tools/gn/location.h" 8 #include "tools/gn/location.h"
9 9
10 namespace { 10 namespace {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 base::StringPiece contents; 125 base::StringPiece contents;
126 LocationRange range; 126 LocationRange range;
127 127
128 CIncludeIterator iter(&file); 128 CIncludeIterator iter(&file);
129 for (size_t group = 0; group < kGroupCount; group++) { 129 for (size_t group = 0; group < kGroupCount; group++) {
130 EXPECT_TRUE(iter.GetNextIncludeString(&contents, &range)); 130 EXPECT_TRUE(iter.GetNextIncludeString(&contents, &range));
131 EXPECT_EQ(include, contents.as_string()); 131 EXPECT_EQ(include, contents.as_string());
132 } 132 }
133 EXPECT_FALSE(iter.GetNextIncludeString(&contents, &range)); 133 EXPECT_FALSE(iter.GetNextIncludeString(&contents, &range));
134 } 134 }
135
136 // Tests that comments of the form
137 // /*
138 // *
139 // */
140 // are not counted toward the non-include line count.
141 TEST(CIncludeIterator, CStyleComments) {
142 std::string buffer("/*");
143 for (size_t i = 0; i < 1000; i++)
144 buffer.append(" *\n");
145 buffer.append(" */\n\n");
146 buffer.append("#include \"foo/bar.h\"\n");
147
148 InputFile file(SourceFile("//foo.cc"));
149 file.SetContents(buffer);
150
151 base::StringPiece contents;
152 LocationRange range;
153
154 CIncludeIterator iter(&file);
155 EXPECT_TRUE(iter.GetNextIncludeString(&contents, &range));
156 EXPECT_EQ("foo/bar.h", contents);
157 }
OLDNEW
« no previous file with comments | « tools/gn/c_include_iterator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698