~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mdiff.py

  • Committer: Martin Pool
  • Date: 2005-08-11 17:56:27 UTC
  • Revision ID: mbp@sourcefrog.net-20050811175627-0bb70e4f236e1d26
- add some test cases for mdiff

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
# TODO: maybe work on files not strings?
27
27
 
 
28
# FIXME: doesn't work properly on files without trailing newlines
28
29
 
 
30
import unittest
29
31
import difflib, sys, struct
30
32
from cStringIO import StringIO
31
33
 
117
119
 
118
120
 
119
121
 
 
122
class TestDiffPatch(unittest.TestCase):
 
123
    def doDiffPatch(self, old, new):
 
124
        diff = bdiff(old, new)
 
125
        result = bpatch(old, diff)
 
126
        self.assertEquals(new, result)
 
127
 
 
128
 
 
129
    def testSimpleDiff(self):
 
130
        """Simply add a line at the end"""
 
131
        self.doDiffPatch('a\nb\n', 'a\nb\nc\n')
 
132
        
 
133
 
 
134
        
 
135
    def testTrailingLine(self):
 
136
        """Test diff that adds an unterminated line.
 
137
 
 
138
        (Old versions didn't do this properly.)"""
 
139
        self.doDiffPatch('a\nb\nc\n',
 
140
                         'a\nb\nc\nd')
 
141
 
 
142
 
 
143
if __name__ == '__main__':
 
144
    unittest.main()