##// END OF EJS Templates
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler -
r30593:42860152 default
parent child Browse files
Show More
@@ -94,6 +94,18 b' class BdiffTests(unittest.TestCase):'
94 for old, new, want in cases:
94 for old, new, want in cases:
95 self.assertEqual(self.showdiff(old, new), want)
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 def showdiff(a, b):
109 def showdiff(a, b):
98 print('showdiff(\n %r,\n %r):' % (a, b))
110 print('showdiff(\n %r,\n %r):' % (a, b))
99 bin = bdiff.bdiff(a, b)
111 bin = bdiff.bdiff(a, b)
@@ -110,20 +122,6 b' def showdiff(a, b):'
110 if q < len(a):
122 if q < len(a):
111 print('', repr(a[q:]))
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 print("Nice diff for a trivial change:")
125 print("Nice diff for a trivial change:")
128 showdiff(
126 showdiff(
129 ''.join('<%s\n-\n' % i for i in range(5)),
127 ''.join('<%s\n-\n' % i for i in range(5)),
@@ -1,4 +1,3 b''
1 done
2 Nice diff for a trivial change:
1 Nice diff for a trivial change:
3 showdiff(
2 showdiff(
4 '<0\n-\n<1\n-\n<2\n-\n<3\n-\n<4\n-\n',
3 '<0\n-\n<1\n-\n<2\n-\n<3\n-\n<4\n-\n',
General Comments 0
You need to be logged in to leave comments. Login now