예제 #1
0
    def test_write(self):
        buffer = ByteBuffer()

        buffer.write(b"abc")
        assert buffer.peek() == b"abc"
        buffer.write(b"def")
        assert buffer.peek() == b"abcdef"
예제 #2
0
    def test_peek(self):
        buffer = ByteBuffer()
        buffer.write(b"abcdefghi")

        assert buffer.peek(slice(0, 1)) == b"a"
        assert buffer.peek(slice(3, 6)) == b"def"
        assert buffer.peek(slice(-2, -1)) == b"h"

        assert buffer.read() == b"abcdefghi"
예제 #3
0
    def test_peek_all(self):
        buffer = ByteBuffer()
        buffer.write(b"abcdefghi")

        assert buffer.peek() == b"abcdefghi"
        assert buffer.read() == b"abcdefghi"