OLD | NEW |
1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 23 matching lines...) Expand all Loading... |
34 from webkitpy.common.checkout.diff_test_data import DIFF_TEST_DATA | 34 from webkitpy.common.checkout.diff_test_data import DIFF_TEST_DATA |
35 | 35 |
36 class DiffParserTest(unittest.TestCase): | 36 class DiffParserTest(unittest.TestCase): |
37 maxDiff = None | 37 maxDiff = None |
38 | 38 |
39 def test_diff_parser(self, parser = None): | 39 def test_diff_parser(self, parser = None): |
40 if not parser: | 40 if not parser: |
41 parser = diff_parser.DiffParser(DIFF_TEST_DATA.splitlines()) | 41 parser = diff_parser.DiffParser(DIFF_TEST_DATA.splitlines()) |
42 self.assertEqual(3, len(parser.files)) | 42 self.assertEqual(3, len(parser.files)) |
43 | 43 |
44 self.assertTrue('WebCore/layout/style/StyleFlexibleBoxData.h' in parser.
files) | 44 self.assertTrue('WebCore/style/StyleFlexibleBoxData.h' in parser.files) |
45 diff = parser.files['WebCore/layout/style/StyleFlexibleBoxData.h'] | 45 diff = parser.files['WebCore/style/StyleFlexibleBoxData.h'] |
46 self.assertEqual(7, len(diff.lines)) | 46 self.assertEqual(7, len(diff.lines)) |
47 # The first two unchaged lines. | 47 # The first two unchaged lines. |
48 self.assertEqual((47, 47), diff.lines[0][0:2]) | 48 self.assertEqual((47, 47), diff.lines[0][0:2]) |
49 self.assertEqual('', diff.lines[0][2]) | 49 self.assertEqual('', diff.lines[0][2]) |
50 self.assertEqual((48, 48), diff.lines[1][0:2]) | 50 self.assertEqual((48, 48), diff.lines[1][0:2]) |
51 self.assertEqual(' unsigned align : 3; // EBoxAlignment', diff.lines[
1][2]) | 51 self.assertEqual(' unsigned align : 3; // EBoxAlignment', diff.lines[
1][2]) |
52 # The deleted line | 52 # The deleted line |
53 self.assertEqual((50, 0), diff.lines[3][0:2]) | 53 self.assertEqual((50, 0), diff.lines[3][0:2]) |
54 self.assertEqual(' unsigned orient: 1; // EBoxOrient', diff.lines[3][
2]) | 54 self.assertEqual(' unsigned orient: 1; // EBoxOrient', diff.lines[3][
2]) |
55 | 55 |
56 # The first file looks OK. Let's check the next, more complicated file. | 56 # The first file looks OK. Let's check the next, more complicated file. |
57 self.assertTrue('WebCore/layout/style/StyleRareInheritedData.cpp' in par
ser.files) | 57 self.assertTrue('WebCore/style/StyleRareInheritedData.cpp' in parser.fil
es) |
58 diff = parser.files['WebCore/layout/style/StyleRareInheritedData.cpp'] | 58 diff = parser.files['WebCore/style/StyleRareInheritedData.cpp'] |
59 # There are 3 chunks. | 59 # There are 3 chunks. |
60 self.assertEqual(7 + 7 + 9, len(diff.lines)) | 60 self.assertEqual(7 + 7 + 9, len(diff.lines)) |
61 # Around an added line. | 61 # Around an added line. |
62 self.assertEqual((60, 61), diff.lines[9][0:2]) | 62 self.assertEqual((60, 61), diff.lines[9][0:2]) |
63 self.assertEqual((0, 62), diff.lines[10][0:2]) | 63 self.assertEqual((0, 62), diff.lines[10][0:2]) |
64 self.assertEqual((61, 63), diff.lines[11][0:2]) | 64 self.assertEqual((61, 63), diff.lines[11][0:2]) |
65 # Look through the last chunk, which contains both add's and delete's. | 65 # Look through the last chunk, which contains both add's and delete's. |
66 self.assertEqual((81, 83), diff.lines[14][0:2]) | 66 self.assertEqual((81, 83), diff.lines[14][0:2]) |
67 self.assertEqual((82, 84), diff.lines[15][0:2]) | 67 self.assertEqual((82, 84), diff.lines[15][0:2]) |
68 self.assertEqual((83, 85), diff.lines[16][0:2]) | 68 self.assertEqual((83, 85), diff.lines[16][0:2]) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 A | 166 A |
167 B | 167 B |
168 C | 168 C |
169 +D | 169 +D |
170 E | 170 E |
171 F | 171 F |
172 """) | 172 """) |
173 | 173 |
174 self.assertMultiLineEqual(output, ''.join(diff_parser.git_diff_to_svn_di
ff(x) for x in shortfmt.readlines())) | 174 self.assertMultiLineEqual(output, ''.join(diff_parser.git_diff_to_svn_di
ff(x) for x in shortfmt.readlines())) |
175 self.assertMultiLineEqual(output, ''.join(diff_parser.git_diff_to_svn_di
ff(x) for x in inputfmt.readlines())) | 175 self.assertMultiLineEqual(output, ''.join(diff_parser.git_diff_to_svn_di
ff(x) for x in inputfmt.readlines())) |
OLD | NEW |