| Index: PRESUBMIT_test.py
|
| diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
|
| index 4d40d8f9712239289a44046608b0f4c8d04e9cf8..f5a21ca2ca1170e7c5ca33c9d83db04451a833fb 100755
|
| --- a/PRESUBMIT_test.py
|
| +++ b/PRESUBMIT_test.py
|
| @@ -413,6 +413,43 @@ class CheckSingletonInHeadersTest(unittest.TestCase):
|
| self.assertEqual(0, len(warnings))
|
|
|
|
|
| +class CheckBaseMacrosInHeadersTest(unittest.TestCase):
|
| + def _make_h(self, macro, header):
|
| + return ("""
|
| +#include "base/%s.h"
|
| +
|
| +class Thing {
|
| + private:
|
| + DISALLOW_%s(Thing);
|
| +};
|
| +""" % (macro, header)).splitlines()
|
| +
|
| + def testBaseMacrosInHeadersBad(self):
|
| + mock_input_api = MockInputApi()
|
| + mock_input_api.files = [
|
| + MockAffectedFile('foo.h', self._make_h('not_macros', 'ASSIGN')),
|
| + MockAffectedFile('bar.h', self._make_h('not_macros', 'COPY')),
|
| + MockAffectedFile('baz.h', self._make_h('not_macros', 'COPY_AND_ASSIGN')),
|
| + MockAffectedFile('qux.h', self._make_h('not_macros', 'EVIL')),
|
| + ]
|
| + warnings = PRESUBMIT._CheckBaseMacrosInHeaders(mock_input_api,
|
| + MockOutputApi())
|
| + self.assertEqual(1, len(warnings))
|
| + self.assertEqual(4, len(warnings[0].items))
|
| +
|
| + def testBaseMacrosInHeadersGood(self):
|
| + mock_input_api = MockInputApi()
|
| + mock_input_api.files = [
|
| + MockAffectedFile('foo.h', self._make_h('macros', 'ASSIGN')),
|
| + MockAffectedFile('bar.h', self._make_h('macros', 'COPY')),
|
| + MockAffectedFile('baz.h', self._make_h('macros', 'COPY_AND_ASSIGN')),
|
| + MockAffectedFile('qux.h', self._make_h('macros', 'EVIL')),
|
| + ]
|
| + warnings = PRESUBMIT._CheckBaseMacrosInHeaders(mock_input_api,
|
| + MockOutputApi())
|
| + self.assertEqual(0, len(warnings))
|
| +
|
| +
|
| class InvalidOSMacroNamesTest(unittest.TestCase):
|
| def testInvalidOSMacroNames(self):
|
| lines = ['#if defined(OS_WINDOWS)',
|
|
|