MCPcopy Index your code
hub / github.com/cpplint/cpplint / testRegression

Method testRegression

cpplint_unittest.py:6161–6311  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6159 assert cpplint._DropCommonSuffixes("test.c++") == "test"
6160
6161 def testRegression(self):
6162 def Format(includes):
6163 include_list = []
6164 for item in includes:
6165 if item.startswith(('"', "<")):
6166 include_list.append("#include %s\n" % item)
6167 else:
6168 include_list.append(item + "\n")
6169 return "".join(include_list)
6170
6171 # Test singleton cases first.
6172 self.TestLanguageRulesCheck("foo/foo.cc", Format(['"foo/foo.h"']), "")
6173 self.TestLanguageRulesCheck("foo/foo.cc", Format(["<stdio.h>"]), "")
6174 self.TestLanguageRulesCheck("foo/foo.cc", Format(["<string>"]), "")
6175 self.TestLanguageRulesCheck("foo/foo.cc", Format(['"foo/foo-inl.h"']), "")
6176 self.TestLanguageRulesCheck("foo/foo.cc", Format(['"bar/bar-inl.h"']), "")
6177 self.TestLanguageRulesCheck("foo/foo.cc", Format(['"bar/bar.h"']), "")
6178
6179 # Test everything in a good and new order.
6180 self.TestLanguageRulesCheck(
6181 "foo/foo.cc",
6182 Format(
6183 [
6184 '"foo/foo.h"',
6185 '"foo/foo-inl.h"',
6186 "<stdio.h>",
6187 "<string>",
6188 "<unordered_map>",
6189 '"bar/bar-inl.h"',
6190 '"bar/bar.h"',
6191 ]
6192 ),
6193 "",
6194 )
6195
6196 # Test bad orders.
6197 self.TestLanguageRulesCheck(
6198 "foo/foo.cc",
6199 Format(["<string>", "<stdio.h>"]),
6200 "Found C system header after C++ system header."
6201 " Should be: foo.h, c system, c++ system, other."
6202 " [build/include_order] [4]",
6203 )
6204 self.TestLanguageRulesCheck(
6205 "foo/foo.cc", Format(['"foo/bar-inl.h"', '"foo/foo-inl.h"']), ""
6206 )
6207 self.TestLanguageRulesCheck(
6208 "foo/foo.cc",
6209 Format(
6210 [
6211 '"foo/e.h"',
6212 '"foo/b.h"', # warning here (e>b)
6213 '"foo/c.h"',
6214 '"foo/d.h"',
6215 '"foo/a.h"',
6216 ]
6217 ), # warning here (d>a)
6218 [

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected