Mercurial > hg-stable
comparison tests/test-bdiff.py @ 8449:807f3f5c60e9
tests: renamed Python tests to .py
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sun, 17 May 2009 01:39:31 +0200 |
parents | tests/test-bdiff@94ecd4922a23 |
children | 284fda4cd093 |
comparison
equal
deleted
inserted
replaced
8448:0eb8c4df61bd | 8449:807f3f5c60e9 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import sys, struct | |
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 "***", repr(a), repr(b) | |
13 print "bad:" | |
14 print repr(c)[:200] | |
15 print repr(d) | |
16 | |
17 def test(a, b): | |
18 print "***", repr(a), repr(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 #issue1295 | |
43 def showdiff(a, b): | |
44 bin = bdiff.bdiff(a, b) | |
45 pos = 0 | |
46 while pos < len(bin): | |
47 p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12]) | |
48 pos += 12 | |
49 print p1, p2, repr(bin[pos:pos + l]) | |
50 pos += l | |
51 showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\nx\n\nz\n") | |
52 showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n") | |
53 | |
54 print "done" |