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 os | 6 import os |
7 import re | 7 import re |
8 import unittest | 8 import unittest |
9 | 9 |
10 import PRESUBMIT | 10 import PRESUBMIT |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 def testConflictAdded2(self): | 148 def testConflictAdded2(self): |
149 scope = [(1, '#include "c.h"'), | 149 scope = [(1, '#include "c.h"'), |
150 (2, '#include "b.h"'), | 150 (2, '#include "b.h"'), |
151 (3, '#include "d.h"')] | 151 (3, '#include "d.h"')] |
152 mock_input_api = MockInputApi() | 152 mock_input_api = MockInputApi() |
153 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, | 153 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
154 '', [2]) | 154 '', [2]) |
155 self.assertEqual(1, len(warnings)) | 155 self.assertEqual(1, len(warnings)) |
156 self.assertTrue('2' in warnings[0]) | 156 self.assertTrue('2' in warnings[0]) |
157 | 157 |
| 158 def testIfElifElseEndif(self): |
| 159 mock_input_api = MockInputApi() |
| 160 contents = ['#include "e.h"', |
| 161 '#if foo', |
| 162 '#include "d.h"', |
| 163 '#elif bar', |
| 164 '#include "c.h"', |
| 165 '#else', |
| 166 '#include "b.h"', |
| 167 '#endif', |
| 168 '#include "a.h"'] |
| 169 mock_file = MockFile('', contents) |
| 170 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 171 mock_input_api, mock_file, True, range(1, len(contents) + 1)) |
| 172 self.assertEqual(0, len(warnings)) |
| 173 |
158 | 174 |
159 if __name__ == '__main__': | 175 if __name__ == '__main__': |
160 unittest.main() | 176 unittest.main() |
OLD | NEW |