changeset 30595:99bd5479d58b

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.
author Augie Fackler <augie@google.com>
date Thu, 15 Dec 2016 11:14:00 -0500
parents ea648e8f8a34
children be520fe3a3e9
files tests/test-bdiff.py
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-bdiff.py	Thu Dec 15 11:04:09 2016 -0500
+++ b/tests/test-bdiff.py	Thu Dec 15 11:14:00 2016 -0500
@@ -82,18 +82,28 @@
               '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)
 
+    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),