| Index: PRESUBMIT_test.py
|
| diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
|
| index 00997b43e8a170ecb8b3e1f30b1a14051424d013..7de0c3b61f5da2e8ec7d46c2f532477223a6d3ef 100755
|
| --- a/PRESUBMIT_test.py
|
| +++ b/PRESUBMIT_test.py
|
| @@ -384,6 +384,33 @@ class BadExtensionsTest(unittest.TestCase):
|
| self.assertEqual({}, results)
|
|
|
|
|
| +class CheckSingletonInHeadersTest(unittest.TestCase):
|
| + def testSingletonInArbitraryHeader(self):
|
| + diff_singleton_h = ['base::subtle::AtomicWord '
|
| + 'Singleton<Type, Traits, DifferentiatingType>::']
|
| + diff_foo_h = ['// Singleton<Foo> in comment.',
|
| + 'friend class Singleton<Foo>']
|
| + diff_bad_h = ['Foo* foo = Singleton<Foo>::get();']
|
| + mock_input_api = MockInputApi()
|
| + mock_input_api.files = [MockFile('base/memory/singleton.h',
|
| + diff_singleton_h),
|
| + MockFile('foo.h', diff_foo_h),
|
| + MockFile('bad.h', diff_bad_h)]
|
| + warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api,
|
| + MockOutputApi())
|
| + self.assertEqual(1, len(warnings))
|
| + self.assertEqual('error', warnings[0].type)
|
| + self.assertTrue('Found Singleton<T>' in warnings[0].message)
|
| +
|
| + def testSingletonInCC(self):
|
| + diff_cc = ['Foo* foo = Singleton<Foo>::get();']
|
| + mock_input_api = MockInputApi()
|
| + mock_input_api.files = [MockFile('some/path/foo.cc', diff_cc)]
|
| + warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api,
|
| + MockOutputApi())
|
| + self.assertEqual(0, len(warnings))
|
| +
|
| +
|
| class InvalidOSMacroNamesTest(unittest.TestCase):
|
| def testInvalidOSMacroNames(self):
|
| lines = ['#if defined(OS_WINDOWS)',
|
|
|