| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import re | 6 import re |
| 7 import subprocess | 7 import subprocess |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 import PRESUBMIT | 10 import PRESUBMIT |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 input_api.files = [ | 1107 input_api.files = [ |
| 1108 MockFile('content/file.cc', | 1108 MockFile('content/file.cc', |
| 1109 ['char* host = "https://www.aol.com"; // google.com']) | 1109 ['char* host = "https://www.aol.com"; // google.com']) |
| 1110 ] | 1110 ] |
| 1111 | 1111 |
| 1112 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers( | 1112 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers( |
| 1113 input_api, MockOutputApi()) | 1113 input_api, MockOutputApi()) |
| 1114 self.assertEqual(0, len(warnings)) | 1114 self.assertEqual(0, len(warnings)) |
| 1115 | 1115 |
| 1116 | 1116 |
| 1117 class ForwardDeclarationTest(unittest.TestCase): | |
| 1118 def testCheckHeadersOnly(self): | |
| 1119 mock_input_api = MockInputApi() | |
| 1120 mock_input_api.files = [ | |
| 1121 MockAffectedFile('somewhere/file.cc', [ | |
| 1122 'class DummyClass;' | |
| 1123 ]) | |
| 1124 ] | |
| 1125 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, | |
| 1126 MockOutputApi()) | |
| 1127 self.assertEqual(0, len(warnings)) | |
| 1128 | |
| 1129 def testNoNestedDeclaration(self): | |
| 1130 mock_input_api = MockInputApi() | |
| 1131 mock_input_api.files = [ | |
| 1132 MockAffectedFile('somewhere/header.h', [ | |
| 1133 'class SomeClass {' | |
| 1134 ' protected:' | |
| 1135 ' class NotAMatch;' | |
| 1136 '};' | |
| 1137 ]) | |
| 1138 ] | |
| 1139 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, | |
| 1140 MockOutputApi()) | |
| 1141 self.assertEqual(0, len(warnings)) | |
| 1142 | |
| 1143 def testSubStrings(self): | |
| 1144 mock_input_api = MockInputApi() | |
| 1145 mock_input_api.files = [ | |
| 1146 MockAffectedFile('somewhere/header.h', [ | |
| 1147 'class NotUsefulClass;', | |
| 1148 'struct SomeStruct;', | |
| 1149 'UsefulClass *p1;', | |
| 1150 'SomeStructPtr *p2;' | |
| 1151 ]) | |
| 1152 ] | |
| 1153 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, | |
| 1154 MockOutputApi()) | |
| 1155 self.assertEqual(2, len(warnings)) | |
| 1156 | |
| 1157 def testUselessForwardDeclaration(self): | |
| 1158 mock_input_api = MockInputApi() | |
| 1159 mock_input_api.files = [ | |
| 1160 MockAffectedFile('somewhere/header.h', [ | |
| 1161 'class DummyClass;', | |
| 1162 'struct DummyStruct;', | |
| 1163 'class UsefulClass;', | |
| 1164 'std::unique_ptr<UsefulClass> p;' | |
| 1165 ]), | |
| 1166 ] | |
| 1167 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, | |
| 1168 MockOutputApi()) | |
| 1169 self.assertEqual(2, len(warnings)) | |
| 1170 | |
| 1171 | |
| 1172 if __name__ == '__main__': | 1117 if __name__ == '__main__': |
| 1173 unittest.main() | 1118 unittest.main() |
| OLD | NEW |