def test_buffer(self):
        sb = StringBuffer(128)
        sb.write('hello world')
        sb.seek(0)
        self.assertEquals(sb.read(), 'hello world')

        self.assertEquals(sb.offset(), 0)
        sb.write('jello')
        self.assertEquals(sb.offset(), 5)
        sb.seek(0)
        self.assertEquals(sb.read(), 'jello world')

        sb.set('hi')
        self.assertEquals(sb.offset(), 0)
        self.assertEquals(sb.read(), 'hi')

        sb = StringBuffer("Hello World")
        self.assertEquals(sb.read(), 'Hello World')

        sb = StringBuffer(sb)
        self.assertEquals(sb.read(), 'Hello World')
    def test_read_uint(self):
        sb = StringBuffer(16)
        sb.pack('<H', 16)

        sb.seek(0)
        i = sb.read_uint(2)
        self.assertEquals(i, 16)

        self.assertEquals(sb.offset(), 2)
        sb.pack('<Q', 1024)
        sb.seek(2)
        i = sb.read_uint(8)
        self.assertEquals(1024, i)