tests/test-bdiff
changeset 400 8b067bde6679
child 800 ec85f9e6f3b1
child 808 8f5637f0a0c0
child 814 0902ffece4b4
equal deleted inserted replaced
399:f060d728fe54 400:8b067bde6679
       
     1 #!/usr/bin/env python
       
     2 
       
     3 import sys
       
     4 from mercurial import bdiff, mpatch
       
     5 
       
     6 def test1(a, b):
       
     7     d = bdiff.bdiff(a, b)
       
     8     c = a
       
     9     if d:
       
    10         c = mpatch.patches(a, [d])
       
    11     if c != b:
       
    12         print "***", `a`, `b`
       
    13         print "bad:"
       
    14         print `c`[:200]
       
    15         print `d`
       
    16 
       
    17 def test(a, b):
       
    18     print "***", `a`, `b`
       
    19     test1(a, b)
       
    20     test1(b, a)
       
    21 
       
    22 test("a\nc\n\n\n\n", "a\nb\n\n\n")
       
    23 test("a\nb\nc\n", "a\nc\n")
       
    24 test("", "")
       
    25 test("a\nb\nc", "a\nb\nc")
       
    26 test("a\nb\nc\nd\n", "a\nd\n")
       
    27 test("a\nb\nc\nd\n", "a\nc\ne\n")
       
    28 test("a\nb\nc\n", "a\nc\n")
       
    29 test("a\n", "c\na\nb\n")
       
    30 test("a\n", "")
       
    31 test("a\n", "b\nc\n")
       
    32 test("a\n", "c\na\n")
       
    33 test("", "adjfkjdjksdhfksj")
       
    34 test("", "ab")
       
    35 test("", "abc")
       
    36 test("a", "a")
       
    37 test("ab", "ab")
       
    38 test("abc", "abc")
       
    39 test("a\n", "a\n")
       
    40 test("a\nb", "a\nb")
       
    41 
       
    42 print "done"