/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-04 15:24:39 UTC
  • mto: This revision was merged to the branch mainline in revision 3131.
  • Revision ID: john@arbash-meinel.com-20071204152439-hlj4y6a8a2fb6nkz
Change the C PatienceDiff implementation to support arbitrary objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
800
800
        chk_blocks('abbabbbb', 'cabbabbc', [])
801
801
        chk_blocks('bbbbbbbb', 'cbbbbbbc', [])
802
802
 
 
803
    def test_matching_blocks_tuples(self):
 
804
        def chk_blocks(a, b, expected_blocks):
 
805
            # difflib always adds a signature of the total
 
806
            # length, with no matching entries at the end
 
807
            s = self._PatienceSequenceMatcher(None, a, b)
 
808
            blocks = s.get_matching_blocks()
 
809
            self.assertEquals((len(a), len(b), 0), blocks[-1])
 
810
            self.assertEquals(expected_blocks, blocks[:-1])
 
811
 
 
812
        # Some basic matching tests
 
813
        chk_blocks([], [], [])
 
814
        chk_blocks([('a',), ('b',), ('c,')], [], [])
 
815
        chk_blocks([], [('a',), ('b',), ('c,')], [])
 
816
        chk_blocks([('a',), ('b',), ('c,')],
 
817
                   [('a',), ('b',), ('c,')],
 
818
                   [(0, 0, 3)])
 
819
        chk_blocks([('a',), ('b',), ('c,')],
 
820
                   [('a',), ('b',), ('d,')],
 
821
                   [(0, 0, 2)])
 
822
        chk_blocks([('d',), ('b',), ('c,')],
 
823
                   [('a',), ('b',), ('c,')],
 
824
                   [(1, 1, 2)])
 
825
        chk_blocks([('d',), ('a',), ('b',), ('c,')],
 
826
                   [('a',), ('b',), ('c,')],
 
827
                   [(1, 0, 3)])
 
828
        chk_blocks([('a', 'b'), ('c', 'd'), ('e', 'f')],
 
829
                   [('a', 'b'), ('c', 'X'), ('e', 'f')],
 
830
                   [(0, 0, 1), (2, 2, 1)])
 
831
        chk_blocks([('a', 'b'), ('c', 'd'), ('e', 'f')],
 
832
                   [('a', 'b'), ('c', 'dX'), ('e', 'f')],
 
833
                   [(0, 0, 1), (2, 2, 1)])
 
834
 
803
835
    def test_opcodes(self):
804
836
        def chk_ops(a, b, expected_codes):
805
837
            s = self._PatienceSequenceMatcher(None, a, b)