OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/env python |
2 # | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Copyright 2009, Google Inc. | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # All rights reserved. | 4 # found in the LICENSE file. |
5 # | |
6 # Redistribution and use in source and binary forms, with or without | |
7 # modification, are permitted provided that the following conditions are | |
8 # met: | |
9 # | |
10 # * Redistributions of source code must retain the above copyright | |
11 # notice, this list of conditions and the following disclaimer. | |
12 # * Redistributions in binary form must reproduce the above | |
13 # copyright notice, this list of conditions and the following disclaimer | |
14 # in the documentation and/or other materials provided with the | |
15 # distribution. | |
16 # * Neither the name of Google Inc. nor the names of its | |
17 # contributors may be used to endorse or promote products derived from | |
18 # this software without specific prior written permission. | |
19 # | |
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 | 5 |
32 """Unit tests for croc_scan.py.""" | 6 """Unit tests for croc_scan.py.""" |
33 | 7 |
34 #import os | |
35 import re | 8 import re |
36 #import sys | |
37 #import StringIO | |
38 import unittest | 9 import unittest |
39 import croc_scan | 10 import croc_scan |
40 | 11 |
41 #------------------------------------------------------------------------------ | |
42 | |
43 | 12 |
44 class TestScanner(unittest.TestCase): | 13 class TestScanner(unittest.TestCase): |
45 """Tests for croc_scan.Scanner.""" | 14 """Tests for croc_scan.Scanner.""" |
46 | 15 |
47 def testInit(self): | 16 def testInit(self): |
48 """Test __init()__.""" | 17 """Test __init()__.""" |
49 s = croc_scan.Scanner() | 18 s = croc_scan.Scanner() |
50 | 19 |
51 self.assertEqual(s.re_token.pattern, '#') | 20 self.assertEqual(s.re_token.pattern, '#') |
52 self.assertEqual(s.comment_to_eol, ['#']) | 21 self.assertEqual(s.comment_to_eol, ['#']) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 175 |
207 def testScanFile(self): | 176 def testScanFile(self): |
208 """Test ScanFile().""" | 177 """Test ScanFile().""" |
209 self.assertEqual(croc_scan.ScanFile('foo', 'python'), 'scan py foo') | 178 self.assertEqual(croc_scan.ScanFile('foo', 'python'), 'scan py foo') |
210 self.assertEqual(croc_scan.ScanFile('bar1', 'C'), 'scan cpp bar1') | 179 self.assertEqual(croc_scan.ScanFile('bar1', 'C'), 'scan cpp bar1') |
211 self.assertEqual(croc_scan.ScanFile('bar2', 'C++'), 'scan cpp bar2') | 180 self.assertEqual(croc_scan.ScanFile('bar2', 'C++'), 'scan cpp bar2') |
212 self.assertEqual(croc_scan.ScanFile('bar3', 'ObjC'), 'scan cpp bar3') | 181 self.assertEqual(croc_scan.ScanFile('bar3', 'ObjC'), 'scan cpp bar3') |
213 self.assertEqual(croc_scan.ScanFile('bar4', 'ObjC++'), 'scan cpp bar4') | 182 self.assertEqual(croc_scan.ScanFile('bar4', 'ObjC++'), 'scan cpp bar4') |
214 self.assertEqual(croc_scan.ScanFile('bar', 'fortran'), []) | 183 self.assertEqual(croc_scan.ScanFile('bar', 'fortran'), []) |
215 | 184 |
216 #------------------------------------------------------------------------------ | |
217 | 185 |
218 if __name__ == '__main__': | 186 if __name__ == '__main__': |
219 unittest.main() | 187 unittest.main() |
OLD | NEW |