Skip to content
Snippets Groups Projects
Commit 99bd5479 authored by Augie Fackler's avatar Augie Fackler
Browse files

tests: fix test-bdiff to handle variance between pure and c bdiff code

Obviously we'd rather patch pure to have the same algorithmic win as
the C code, but this is a quick fix for the pure build since pure
isn't wrong, just not as fast as it could be.
parent ea648e8f
No related branches found
No related tags found
No related merge requests found
......@@ -82,15 +82,7 @@
'x\n\n',
diffreplace(9, 9, '', 'y\n\n'),
'x\n\nz\n']),
# we should pick up abbbc. rather than bc.de as the longest match
("a\nb\nb\nb\nc\n.\nd\ne\n.\nf\n",
"a\nb\nb\na\nb\nb\nb\nc\n.\nb\nc\n.\nd\ne\nf\n",
['a\nb\nb\n',
diffreplace(6, 6, '', 'a\nb\nb\nb\nc\n.\n'),
'b\nc\n.\nd\ne\n',
diffreplace(16, 18, '.\n', ''),
'f\n']),
]
for old, new, want in cases:
self.assertEqual(self.showdiff(old, new), want)
......@@ -93,7 +85,25 @@
]
for old, new, want in cases:
self.assertEqual(self.showdiff(old, new), want)
def test_issue1295_varies_on_pure(self):
# we should pick up abbbc. rather than bc.de as the longest match
got = self.showdiff("a\nb\nb\nb\nc\n.\nd\ne\n.\nf\n",
"a\nb\nb\na\nb\nb\nb\nc\n.\nb\nc\n.\nd\ne\nf\n")
want_c = ['a\nb\nb\n',
diffreplace(6, 6, '', 'a\nb\nb\nb\nc\n.\n'),
'b\nc\n.\nd\ne\n',
diffreplace(16, 18, '.\n', ''),
'f\n']
want_pure = [diffreplace(0, 0, '', 'a\nb\nb\n'),
'a\nb\nb\nb\nc\n.\n',
diffreplace(12, 12, '', 'b\nc\n.\n'),
'd\ne\n',
diffreplace(16, 18, '.\n', ''), 'f\n']
self.assert_(got in (want_c, want_pure),
'got: %r, wanted either %r or %r' % (
got, want_c, want_pure))
def test_fixws(self):
cases = [
(" \ta\r b\t\n", "ab\n", 1),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment