~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testdiff.py

  • Committer: John Arbash Meinel
  • Date: 2005-11-10 03:59:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1727.
  • Revision ID: john@arbash-meinel.com-20051110035926-e391fd93199f0537
Added some more test cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
class TestCDVDiffLib(TestCase):
52
52
 
53
53
    def test_unique_lcs(self):
54
 
        from bzrlib.nofrillsprecisemerge import unique_lcs
 
54
        from bzrlib.cdv.nofrillsprecisemerge import unique_lcs
55
55
 
56
56
        self.assertEquals(unique_lcs('', ''), [])
57
57
        self.assertEquals(unique_lcs('a', 'a'), [(0,0)])
64
64
        self.assertEquals(unique_lcs('acbac', 'abc'), [(2,1)])
65
65
 
66
66
    def test_recurse_matches(self):
67
 
        from bzrlib.nofrillsprecisemerge import recurse_matches
 
67
        from bzrlib.cdv.nofrillsprecisemerge import recurse_matches
68
68
 
69
69
        def test_one(a, b, matches):
70
70
            test_matches = []
84
84
        test_one('aBccDe', 'abccde', [(0,0), (5,5)])
85
85
 
86
86
    def test_matching_blocks(self):
87
 
        from bzrlib.cdv.difflib import SequenceMatcher
 
87
        from bzrlib.cdv.cdvdifflib import SequenceMatcher
88
88
 
89
89
        def chk_blocks(a, b, matching):
90
90
            # difflib always adds a signature of the total
122
122
 
123
123
        chk_blocks('aBccDe', 'abccde', [(0,0,1), (2,2,2), (5,5,1)])
124
124
 
 
125
        chk_blocks('aBcdEcdFg', 'abcdecdfg', [(0,0,1), (2,2,2),
 
126
                                              (5,5,2), (8,8,1)])
 
127
 
125
128
    def test_opcodes(self):
126
 
        from bzrlib.cdv.difflib import SequenceMatcher
 
129
        from bzrlib.cdv.cdvdifflib import SequenceMatcher
127
130
 
128
131
        def chk_ops(a, b, codes):
129
132
            s = SequenceMatcher(None, a, b)
178
181
                , ('replace', 4,5, 4,5)
179
182
                , ('equal',   5,6, 5,6)
180
183
                ])
 
184
 
 
185
        chk_ops('aBcdEcdFg', 'abcdecdfg', 
 
186
                [ ('equal',   0,1, 0,1)
 
187
                , ('replace', 1,2, 1,2)
 
188
                , ('equal',   2,4, 2,4)
 
189
                , ('replace', 4,5, 4,5)
 
190
                , ('equal',   5,7, 5,7)
 
191
                , ('replace', 7,8, 7,8)
 
192
                , ('equal',   8,9, 8,9)
 
193
                ])
 
194