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

Unified Diff: PRESUBMIT_test.py

Issue 653883002: Adding Presubmit error when OVERRIDE and FINAL is not used as C++11 standard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final changes Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 2aed5dfc1b4e074b5efa131b74da0000f4c891fc..d401d347a014f16b65a5183afdd2e52f17ceda96 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -413,6 +413,66 @@ class InvalidOSMacroNamesTest(unittest.TestCase):
self.assertEqual(0, len(errors))
+class InvalidOverideAndFinalTest(unittest.TestCase):
+ def testValidOverrideConstructs(self):
+ mock_input_api = MockInputApi()
+ lines = ['foo1() override;',
+ 'foo2() final;',
+ '#DEFINE OVERRIDE_METHOD_OVERLOAD',
+ '#DEFINE FINAL_METHOD',
+ '#DEFINE OVERRIDE_OVERRIDE_SOMETHING',
+ '#DEFINE SOMETHING_OVERRIDE_SOMETHING',
+ '#DEFINE SOMETHING_SOMETHING_OVERRIDE',
+ '#DEFINE FINAL_OVERRIDE_FINAL',
+ '#DEFINE SOMETHING_OVERRIDE_FINAL',
+ '#DEFINE OVERRIDE_OVERRIDE_OVERRIDE',
+ '#endif // FINAL_METHOD',
+ '#endif // OVERRIDE_METHOD_OVERLOAD']
+ mock_file_h = MockFile('something.h', lines)
+ mock_input_api.files = [mock_file_h]
+ errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(0, len(errors))
+
+ def testInvalidOverrideConstructsInHeaders(self):
+ mock_input_api = MockInputApi()
+ lines_cpp = ['foo2() FINAL;']
+ lines_h = ['foo1() OVERRIDE;']
+ mock_file_cpp = MockFile('something.cpp', lines_cpp)
+ mock_file_h = MockFile('something.h', lines_h)
+ mock_input_api.files = [mock_file_cpp, mock_file_h]
+ errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(errors))
+
+ def testInvalidOverrideConstructsInCpp(self):
+ mock_input_api = MockInputApi()
+ lines_cpp = ['foo2() FINAL;']
+ mock_file_cpp = MockFile('something.cpp', lines_cpp)
+ mock_input_api.files = [mock_file_cpp]
+ errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(errors))
+
+ def testInvalidOverrideConstructsInCc(self):
+ mock_input_api = MockInputApi()
+ lines_cc = ['foo3() override FINAL;']
+ mock_file_cc = MockFile('something.cc', lines_cc)
+ mock_input_api.files = [mock_file_cc]
+ errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(errors))
+
+ def testInvalidOverrideConstructsInMm(self):
+ mock_input_api = MockInputApi()
+ lines_mm = ['foo4() OVERRIDE final;']
+ mock_file_mm = MockFile('something.mm', lines_mm)
+ mock_input_api.files = [mock_file_mm]
+ errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(errors))
+
+
class InvalidIfDefinedMacroNamesTest(unittest.TestCase):
def testInvalidIfDefinedMacroNames(self):
lines = ['#if defined(TARGET_IPHONE_SIMULATOR)',
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698