Show More
@@ -94,6 +94,18 b' class BdiffTests(unittest.TestCase):' | |||
|
94 | 94 | for old, new, want in cases: |
|
95 | 95 | self.assertEqual(self.showdiff(old, new), want) |
|
96 | 96 | |
|
97 | def test_fixws(self): | |
|
98 | cases = [ | |
|
99 | (" \ta\r b\t\n", "ab\n", 1), | |
|
100 | (" \ta\r b\t\n", " a b\n", 0), | |
|
101 | ("", "", 1), | |
|
102 | ("", "", 0), | |
|
103 | ] | |
|
104 | for a, b, allws in cases: | |
|
105 | c = bdiff.fixws(a, allws) | |
|
106 | self.assertEqual( | |
|
107 | c, b, 'fixws(%r) want %r got %r (allws=%r)' % (a, b, c, allws)) | |
|
108 | ||
|
97 | 109 | def showdiff(a, b): |
|
98 | 110 | print('showdiff(\n %r,\n %r):' % (a, b)) |
|
99 | 111 | bin = bdiff.bdiff(a, b) |
@@ -110,20 +122,6 b' def showdiff(a, b):' | |||
|
110 | 122 | if q < len(a): |
|
111 | 123 | print('', repr(a[q:])) |
|
112 | 124 | |
|
113 | def testfixws(a, b, allws): | |
|
114 | c = bdiff.fixws(a, allws) | |
|
115 | if c != b: | |
|
116 | print("*** fixws", repr(a), repr(b), allws) | |
|
117 | print("got:") | |
|
118 | print(repr(c)) | |
|
119 | ||
|
120 | testfixws(" \ta\r b\t\n", "ab\n", 1) | |
|
121 | testfixws(" \ta\r b\t\n", " a b\n", 0) | |
|
122 | testfixws("", "", 1) | |
|
123 | testfixws("", "", 0) | |
|
124 | ||
|
125 | print("done") | |
|
126 | ||
|
127 | 125 | print("Nice diff for a trivial change:") |
|
128 | 126 | showdiff( |
|
129 | 127 | ''.join('<%s\n-\n' % i for i in range(5)), |
General Comments 0
You need to be logged in to leave comments.
Login now