annotate tests/test-bdiff.py @ 30704:0499da0d5a06

config: add docs for ignoring all text below in the editor This is an example of how to use the new skip-from-there string for ignoring the diff in a commit message.
author Sean Farley <sean@farley.io>
date Wed, 04 Jan 2017 22:32:42 -0600
parents 99bd5479d58b
children f2ad0d804700
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28734
4e51f9d1683e py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28733
diff changeset
1 from __future__ import absolute_import, print_function
30592
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
2 import collections
8656
284fda4cd093 removed unused imports
Martin Geisler <mg@lazybytes.net>
parents: 8449
diff changeset
3 import struct
30591
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
4 import unittest
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
5
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
6 import silenttestrunner
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
7
28733
2e54aaa65afc py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 15530
diff changeset
8 from mercurial import (
2e54aaa65afc py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 15530
diff changeset
9 bdiff,
2e54aaa65afc py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 15530
diff changeset
10 mpatch,
2e54aaa65afc py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 15530
diff changeset
11 )
400
8b067bde6679 Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff changeset
12
30592
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
13 class diffreplace(
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
14 collections.namedtuple('diffreplace', 'start end from_ to')):
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
15 def __repr__(self):
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
16 return 'diffreplace(%r, %r, %r, %r)' % self
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
17
30591
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
18 class BdiffTests(unittest.TestCase):
400
8b067bde6679 Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff changeset
19
30591
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
20 def assert_bdiff_applies(self, a, b):
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
21 d = bdiff.bdiff(a, b)
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
22 c = a
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
23 if d:
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
24 c = mpatch.patches(a, [d])
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
25 self.assertEqual(
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
26 c, b, ("bad diff+patch result from\n %r to\n "
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
27 "%r: \nbdiff: %r\npatched: %r" % (a, b, d, c[:200])))
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
28
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
29 def assert_bdiff(self, a, b):
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
30 self.assert_bdiff_applies(a, b)
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
31 self.assert_bdiff_applies(b, a)
400
8b067bde6679 Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff changeset
32
30591
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
33 def test_bdiff_basic(self):
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
34 cases = [
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
35 ("a\nc\n\n\n\n", "a\nb\n\n\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
36 ("a\nb\nc\n", "a\nc\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
37 ("", ""),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
38 ("a\nb\nc", "a\nb\nc"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
39 ("a\nb\nc\nd\n", "a\nd\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
40 ("a\nb\nc\nd\n", "a\nc\ne\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
41 ("a\nb\nc\n", "a\nc\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
42 ("a\n", "c\na\nb\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
43 ("a\n", ""),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
44 ("a\n", "b\nc\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
45 ("a\n", "c\na\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
46 ("", "adjfkjdjksdhfksj"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
47 ("", "ab"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
48 ("", "abc"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
49 ("a", "a"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
50 ("ab", "ab"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
51 ("abc", "abc"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
52 ("a\n", "a\n"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
53 ("a\nb", "a\nb"),
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
54 ]
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
55 for a, b in cases:
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
56 self.assert_bdiff(a, b)
400
8b067bde6679 Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff changeset
57
30592
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
58 def showdiff(self, a, b):
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
59 bin = bdiff.bdiff(a, b)
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
60 pos = 0
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
61 q = 0
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
62 actions = []
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
63 while pos < len(bin):
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
64 p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12])
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
65 pos += 12
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
66 if p1:
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
67 actions.append(a[q:p1])
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
68 actions.append(diffreplace(p1, p2, a[p1:p2], bin[pos:pos + l]))
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
69 pos += l
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
70 q = p2
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
71 if q < len(a):
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
72 actions.append(a[q:])
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
73 return actions
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
74
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
75 def test_issue1295(self):
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
76 cases = [
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
77 ("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\nx\n\nz\n",
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
78 ['x\n\nx\n\n', diffreplace(6, 6, '', 'y\n\n'), 'x\n\nx\n\nz\n']),
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
79 ("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n",
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
80 ['x\n\nx\n\n',
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
81 diffreplace(6, 6, '', 'y\n\n'),
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
82 'x\n\n',
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
83 diffreplace(9, 9, '', 'y\n\n'),
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
84 'x\n\nz\n']),
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
85 ]
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
86 for old, new, want in cases:
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
87 self.assertEqual(self.showdiff(old, new), want)
0d8cada9998d tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents: 30591
diff changeset
88
30595
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
89 def test_issue1295_varies_on_pure(self):
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
90 # we should pick up abbbc. rather than bc.de as the longest match
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
91 got = self.showdiff("a\nb\nb\nb\nc\n.\nd\ne\n.\nf\n",
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
92 "a\nb\nb\na\nb\nb\nb\nc\n.\nb\nc\n.\nd\ne\nf\n")
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
93 want_c = ['a\nb\nb\n',
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
94 diffreplace(6, 6, '', 'a\nb\nb\nb\nc\n.\n'),
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
95 'b\nc\n.\nd\ne\n',
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
96 diffreplace(16, 18, '.\n', ''),
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
97 'f\n']
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
98 want_pure = [diffreplace(0, 0, '', 'a\nb\nb\n'),
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
99 'a\nb\nb\nb\nc\n.\n',
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
100 diffreplace(12, 12, '', 'b\nc\n.\n'),
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
101 'd\ne\n',
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
102 diffreplace(16, 18, '.\n', ''), 'f\n']
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
103 self.assert_(got in (want_c, want_pure),
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
104 'got: %r, wanted either %r or %r' % (
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
105 got, want_c, want_pure))
99bd5479d58b tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents: 30594
diff changeset
106
30593
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
107 def test_fixws(self):
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
108 cases = [
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
109 (" \ta\r b\t\n", "ab\n", 1),
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
110 (" \ta\r b\t\n", " a b\n", 0),
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
111 ("", "", 1),
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
112 ("", "", 0),
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
113 ]
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
114 for a, b, allws in cases:
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
115 c = bdiff.fixws(a, allws)
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
116 self.assertEqual(
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
117 c, b, 'fixws(%r) want %r got %r (allws=%r)' % (a, b, c, allws))
4286015285ec tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents: 30592
diff changeset
118
30594
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
119 def test_nice_diff_for_trivial_change(self):
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
120 self.assertEqual(self.showdiff(
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
121 ''.join('<%s\n-\n' % i for i in range(5)),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
122 ''.join('>%s\n-\n' % i for i in range(5))),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
123 [diffreplace(0, 3, '<0\n', '>0\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
124 '-\n',
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
125 diffreplace(5, 8, '<1\n', '>1\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
126 '-\n',
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
127 diffreplace(10, 13, '<2\n', '>2\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
128 '-\n',
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
129 diffreplace(15, 18, '<3\n', '>3\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
130 '-\n',
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
131 diffreplace(20, 23, '<4\n', '>4\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
132 '-\n'])
30427
ede7bc45bf0a tests: make test-bdiff.py easier to maintain
Mads Kiilerich <madski@unity3d.com>
parents: 29013
diff changeset
133
30594
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
134 def test_prefer_appending(self):
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
135 # 1 line to 3 lines
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
136 self.assertEqual(self.showdiff('a\n', 'a\n' * 3),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
137 ['a\n', diffreplace(2, 2, '', 'a\na\n')])
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
138 # 1 line to 5 lines
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
139 self.assertEqual(self.showdiff('a\n', 'a\n' * 5),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
140 ['a\n', diffreplace(2, 2, '', 'a\na\na\na\n')])
30428
3743e5dbb824 tests: explore some bdiff cases
Mads Kiilerich <madski@unity3d.com>
parents: 30427
diff changeset
141
30594
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
142 def test_prefer_removing_trailing(self):
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
143 # 3 lines to 1 line
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
144 self.assertEqual(self.showdiff('a\n' * 3, 'a\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
145 ['a\n', diffreplace(2, 6, 'a\na\n', '')])
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
146 # 5 lines to 1 line
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
147 self.assertEqual(self.showdiff('a\n' * 5, 'a\n'),
ea648e8f8a34 tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents: 30593
diff changeset
148 ['a\n', diffreplace(2, 10, 'a\na\na\na\n', '')])
30591
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
149
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
150 if __name__ == '__main__':
1b393a93a7df tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents: 30433
diff changeset
151 silenttestrunner.main(__name__)