~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__groupcompress.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-27 22:29:55 UTC
  • mto: (3735.39.2 clean)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090327222955-utifmfm888zerixt
Implement apply_delta_to_source which doesn't have to malloc another string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
        super(TestMakeAndApplyDelta, self).setUp()
136
136
        self.make_delta = self._gc_module.make_delta
137
137
        self.apply_delta = self._gc_module.apply_delta
 
138
        self.apply_delta_to_source = self._gc_module.apply_delta_to_source
138
139
 
139
140
    def test_make_delta_is_typesafe(self):
140
141
        self.make_delta('a string', 'another string')
201
202
                    'M\x90/\x1ebe matched\nagainst other text\n')
202
203
        self.assertEqual(_text1, target)
203
204
 
 
205
    def test_apply_delta_to_source_is_safe(self):
 
206
        self.assertRaises(TypeError,
 
207
            self.apply_delta_to_source, object(), 0, 1)
 
208
        self.assertRaises(TypeError,
 
209
            self.apply_delta_to_source, u'unicode str', 0, 1)
 
210
        # end > length
 
211
        self.assertRaises(ValueError,
 
212
            self.apply_delta_to_source, 'foo', 1, 4)
 
213
        # start > length
 
214
        self.assertRaises(ValueError,
 
215
            self.apply_delta_to_source, 'foo', 5, 3)
 
216
        # start > end
 
217
        self.assertRaises(ValueError,
 
218
            self.apply_delta_to_source, 'foo', 3, 2)
 
219
 
 
220
    def test_apply_delta_to_source(self):
 
221
        source_and_delta = (_text1
 
222
                            + 'N\x90/\x1fdiffer from\nagainst other text\n')
 
223
        self.assertEqual(_text2, self.apply_delta_to_source(source_and_delta,
 
224
                                    len(_text1), len(source_and_delta)))
 
225
 
204
226
 
205
227
class TestMakeAndApplyCompatible(tests.TestCase):
206
228