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

Method testFileSpecificFilter

cpplint_unittest.py:5022–5074  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5020 cpplint._DEFAULT_FILTERS = default_filters
5021
5022 def testFileSpecificFilter(self):
5023 old_filters = cpplint._cpplint_state.filters
5024 try:
5025 test_code = """
5026 class Foo {
5027 Foo(int f)
5028 {
5029 }
5030 };"""
5031 cpplint._cpplint_state.SetFilters("")
5032 self.TestMultiLineLint(
5033 test_code,
5034 [
5035 "Single-parameter constructors should be marked explicit."
5036 " [runtime/explicit] [4]",
5037 "{ should almost always be at the end of the previous line"
5038 " [whitespace/braces] [4]",
5039 ],
5040 )
5041
5042 cpplint._cpplint_state.SetFilters("-runtime/explicit:foo.h")
5043 self.TestMultiLineLint(
5044 test_code,
5045 "{ should almost always be at the end of the previous line"
5046 " [whitespace/braces] [4]",
5047 )
5048
5049 cpplint._cpplint_state.SetFilters("-runtime/explicit:foo.h:2")
5050 self.TestMultiLineLint(
5051 test_code,
5052 "{ should almost always be at the end of the previous line"
5053 " [whitespace/braces] [4]",
5054 )
5055
5056 cpplint._cpplint_state.SetFilters(
5057 "-runtime/explicit:foo.h:14,-whitespace/braces:otherfile.h:3"
5058 )
5059 self.TestMultiLineLint(
5060 test_code,
5061 [
5062 "Single-parameter constructors should be marked explicit."
5063 " [runtime/explicit] [4]",
5064 "{ should almost always be at the end of the previous line"
5065 " [whitespace/braces] [4]",
5066 ],
5067 )
5068
5069 cpplint._cpplint_state.SetFilters(
5070 "-runtime/explicit:foo.h:2,-whitespace/braces:foo.h:3"
5071 )
5072 self.TestMultiLineLint(test_code, "")
5073 finally:
5074 cpplint._cpplint_state.filters = old_filters
5075
5076 def testDuplicateHeader(self):
5077 error_collector = ErrorCollector(self.assertTrue)

Callers

nothing calls this directly

Calls 2

SetFiltersMethod · 0.80
TestMultiLineLintMethod · 0.80

Tested by

no test coverage detected