Example #1
0
 def test_finish(self):
     buf = MutableStringBuffer(4)
     buf.setzeros(0, 4)
     pytest.raises(ValueError, "buf.as_str()")
     s = buf.finish()
     assert s == '\x00' * 4
     pytest.raises(ValueError, "buf.finish()")
Example #2
0
 def test_setzeros(self):
     buf = MutableStringBuffer(8)
     buf.setslice(0, 'ABCDEFGH')
     buf.setzeros(2, 3)
     assert buf.finish() == 'AB\x00\x00\x00FGH'
Example #3
0
 def test_setslice(self):
     buf = MutableStringBuffer(6)
     buf.setzeros(0, 6)
     buf.setslice(2, 'ABCD')
     assert buf.finish() == '\x00\x00ABCD'