# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from unittest import TestCase

from subvertpy.delta import send_stream

from cStringIO import StringIO

class DeltaTests(TestCase):

    def setUp(self):
        super(DeltaTests, self).setUp()
        self.windows = []

    def storing_window_handler(self, window):
        self.windows.append(window)

    def test_send_stream(self):
        stream = StringIO("foo")
        send_stream(stream, self.storing_window_handler)
        self.assertEquals([(0, 0, 3, 0, [(2, 0, 3)], 'foo'), None], 
                          self.windows)

@@ -759,16 +759,78 @@
 d_stream
+, encode_length, decode_length, pack_svndiff0, unpack_svndiff0
 %0A%0Afrom c
@@ -1286,8 +1286,421 @@
 indows)%0A
+%0A%0Aclass MarshallTests(TestCase):%0A%0A    def test_encode_length(self):%0A        self.assertEquals(%22%5Cx81%5Cx02%22, encode_length(130))%0A%0A    def test_roundtrip_length(self):%0A        self.assertEquals((42, %22%22), decode_length(encode_length(42)))%0A%0A%0A    def test_roundtrip_window(self):%0A        mywindow = (0, 0, 3, 1, %5B(2, 0, 3)%5D, 'foo')%0A        self.assertEquals(%5Bmywindow%5D, list(unpack_svndiff0(pack_svndiff0(%5Bmywindow%5D))))%0A

Add tests for delta marshalling functions.