コード例 #1
0
    def test_write_sb(self):
        container = StringBuffer(24)
        el = StringBuffer(16)
        el.set('hello world')

        container.write(el)

        container.seek(0)
        self.assertEquals(container.read(), 'hello world')
コード例 #2
0
    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')