Mercurial > hg
annotate tests/test-bdiff.py @ 39163:26f3d075f36e
debugcommands: use a revset instead of dagutil
All this code was doing was finding the nodes that are heads
from the ancestors of an input set. This can easily be expressed
with a revset without having to go through dagutil.
This was the last use of ancestorset() outside of dagutil itself.
Differential Revision: https://phab.mercurial-scm.org/D4308
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 16 Aug 2018 19:55:55 +0000 |
parents | 0c73634d0570 |
children | e05d7c71f209 |
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 | 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 |
28733
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
6 from mercurial import ( |
32202
ded48ad55146
bdiff: proxy through mdiff module
Yuya Nishihara <yuya@tcha.org>
parents:
30931
diff
changeset
|
7 mdiff, |
28733
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
8 ) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
9 |
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
|
10 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
|
11 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
|
12 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
|
13 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
|
14 |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
15 class BdiffTests(unittest.TestCase): |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
16 |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
17 def assert_bdiff_applies(self, a, b): |
32202
ded48ad55146
bdiff: proxy through mdiff module
Yuya Nishihara <yuya@tcha.org>
parents:
30931
diff
changeset
|
18 d = mdiff.textdiff(a, b) |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
19 c = a |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
20 if d: |
32203
0c73634d0570
mpatch: proxy through mdiff module
Yuya Nishihara <yuya@tcha.org>
parents:
32202
diff
changeset
|
21 c = mdiff.patches(a, [d]) |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
22 self.assertEqual( |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
23 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
|
24 "%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
|
25 |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
26 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
|
27 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
|
28 self.assert_bdiff_applies(b, a) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
29 |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
30 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
|
31 cases = [ |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
32 ("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
|
33 ("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
|
34 ("", ""), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
35 ("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
|
36 ("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
|
37 ("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
|
38 ("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
|
39 ("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
|
40 ("a\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\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
|
42 ("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
|
43 ("", "adjfkjdjksdhfksj"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
44 ("", "ab"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
45 ("", "abc"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
46 ("a", "a"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
47 ("ab", "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", "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\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
|
50 ("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
|
51 ] |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
52 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
|
53 self.assert_bdiff(a, b) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
54 |
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
|
55 def showdiff(self, a, b): |
32202
ded48ad55146
bdiff: proxy through mdiff module
Yuya Nishihara <yuya@tcha.org>
parents:
30931
diff
changeset
|
56 bin = mdiff.textdiff(a, b) |
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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 |
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 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
|
73 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
|
74 ("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
|
75 ['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
|
76 ("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
|
77 ['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
|
78 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
|
79 '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
|
80 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
|
81 '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
|
82 ] |
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 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
|
84 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
|
85 |
30595
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
86 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
|
87 # 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
|
88 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
|
89 "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
|
90 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
|
91 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
|
92 '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
|
93 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
|
94 '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
|
95 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
|
96 '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
|
97 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
|
98 '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
|
99 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
|
100 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
|
101 '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
|
102 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
|
103 |
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
|
104 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
|
105 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
|
106 (" \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
|
107 (" \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
|
108 ("", "", 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
|
109 ("", "", 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
|
110 ] |
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 for a, b, allws in cases: |
32202
ded48ad55146
bdiff: proxy through mdiff module
Yuya Nishihara <yuya@tcha.org>
parents:
30931
diff
changeset
|
112 c = mdiff.fixws(a, allws) |
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
|
113 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
|
114 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
|
115 |
30594
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
116 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
|
117 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
|
118 ''.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
|
119 ''.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
|
120 [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
|
121 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
122 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
|
123 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
124 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
|
125 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
126 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
|
127 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
128 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
|
129 '-\n']) |
30427
ede7bc45bf0a
tests: make test-bdiff.py easier to maintain
Mads Kiilerich <madski@unity3d.com>
parents:
29013
diff
changeset
|
130 |
30594
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
131 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
|
132 # 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
|
133 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
|
134 ['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
|
135 # 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
|
136 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
|
137 ['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
|
138 |
30594
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
139 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
|
140 # 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
|
141 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
|
142 ['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
|
143 # 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
|
144 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
|
145 ['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
|
146 |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
147 if __name__ == '__main__': |
30931
f2ad0d804700
test-bdiff: move import inside the function to avoid test failure
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30595
diff
changeset
|
148 import silenttestrunner |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
149 silenttestrunner.main(__name__) |