76
76
test_one(['a', 'c', 'b', 'a', 'c'], ['a', 'b', 'c'],
77
77
[(0, 0), (2, 1), (4, 2)])
79
# FIXME: recurse_matches won't match non-unique lines,
80
# surrounded by bogus text
81
# This is what it should be
79
# recurse_matches doesn't match non-unique
80
# lines surrounded by bogus text.
81
# The update has been done in cdvdifflib.SequenceMatcher instead
83
# This is what it could be
82
84
#test_one('aBccDe', 'abccde', [(0,0), (2,2), (3,3), (5,5)])
83
86
# This is what it currently gives:
84
87
test_one('aBccDe', 'abccde', [(0,0), (5,5)])
198
201
, ('equal', 8,9, 8,9)
204
def test_cdv_unified_diff(self):
205
from bzrlib.cdv.cdvdifflib import unified_diff
206
from bzrlib.cdv.cdvdifflib import SequenceMatcher
208
txt_a = [ 'hello there\n'
210
, 'how are you today?\n']
211
txt_b = [ 'hello there\n'
212
, 'how are you today?\n']
214
self.assertEquals([ '--- \n'
216
, '@@ -1,3 +1,2 @@\n'
219
, ' how are you today?\n'
221
, list(unified_diff(txt_a, txt_b
222
, sequencematcher=SequenceMatcher)))
224
txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
225
txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
227
# This is the result with LongestCommonSubstring matching
228
self.assertEquals([ '--- \n'
230
, '@@ -1,6 +1,11 @@\n'
242
, list(unified_diff(txt_a, txt_b)))
245
self.assertEquals([ '--- \n'
247
, '@@ -4,6 +4,11 @@\n'
260
, list(unified_diff(txt_a, txt_b
261
, sequencematcher=SequenceMatcher)))
263
class TestCDVDiffLibFiles(TestCase):
265
def test_cdv_unified_diff_files(self):
266
from bzrlib.cdv.cdvdifflib import unified_diff_files
267
from bzrlib.cdv.cdvdifflib import SequenceMatcher
269
txt_a = [ 'hello there\n'
271
, 'how are you today?\n']
272
txt_b = [ 'hello there\n'
273
, 'how are you today?\n']
274
open('a1', 'wb').writelines(txt_a)
275
open('b1', 'wb').writelines(txt_b)
277
self.assertEquals([ '--- a1 \n'
279
, '@@ -1,3 +1,2 @@\n'
282
, ' how are you today?\n'
284
, list(unified_diff_files('a1', 'b1'
285
, sequencematcher=SequenceMatcher)))
287
txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
288
txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
289
open('a2', 'wb').writelines(txt_a)
290
open('b2', 'wb').writelines(txt_b)
292
# This is the result with LongestCommonSubstring matching
293
self.assertEquals([ '--- a2 \n'
295
, '@@ -1,6 +1,11 @@\n'
307
, list(unified_diff_files('a2', 'b2')))
310
self.assertEquals([ '--- a2 \n'
312
, '@@ -4,6 +4,11 @@\n'
325
, list(unified_diff_files('a2', 'b2'
326
, sequencematcher=SequenceMatcher)))