diff options
author | mohan.reddy <mohan.reddy@samsung.com> | 2014-10-16 05:26:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-16 12:27:09 +0000 |
commit | f21db965b70b61dea512fc6e98aad6e919274610 (patch) | |
tree | ff34d051158f62a850ca9006253b732a054ebc45 /PRESUBMIT_test.py | |
parent | 88e23180127784b736fa6b1d105d324add1d8151 (diff) | |
download | chromium_src-f21db965b70b61dea512fc6e98aad6e919274610.zip chromium_src-f21db965b70b61dea512fc6e98aad6e919274610.tar.gz chromium_src-f21db965b70b61dea512fc6e98aad6e919274610.tar.bz2 |
Adding Presubmit error when OVERRIDE and FINAL is not used as C++11 standard
Alerting the error for use to use c++11 constructs |override| and |final|
instead of OVERRIDE and FINAL respctively
BUG=417463
Review URL: https://codereview.chromium.org/653883002
Cr-Commit-Position: refs/heads/master@{#299880}
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-x | PRESUBMIT_test.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 2aed5df..d401d34 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)', |