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')
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')