コード例 #1
0
def test_count():
    buf = CircularBuffer(32)
    buf.write(b'asdf\r\njkl;\r\n1234\r\n')
    assert buf.count(b'\r\n') == 3
    buf.clear()
    buf.write(b'asdf\r\njkl;\r\n1234\r\na')
    assert buf.count(b'\r\n') == 3
コード例 #2
0
ファイル: test_find.py プロジェクト: dozymoe/PyCircularBuffer
def test_find():
    buf = CircularBuffer(32)
    buf.write(b'asdf\r\njkl;\r\n1234\r\n')
    assert buf.find(b'\r\n') == 4
    assert buf.find(b'x') == -1
    assert buf.find(b'\r\n', 5) == 10

    buf.clear()
    buf.write(b'asdf\r\njkl;\r\n1234\r\na')
    assert buf.find(b'\r\n') == 4
    assert buf.find(b'x') == -1
    assert buf.find(b'\r\n', 5) == 10

    with raises(ValueError):
        buf.find(b'')
コード例 #3
0
ファイル: test_find.py プロジェクト: dozymoe/PyCircularBuffer
def test_find():
    buf = CircularBuffer(32)
    buf.write(b'asdf\r\njkl;\r\n1234\r\n')
    assert buf.find(b'\r\n') == 4
    assert buf.find(b'x') == -1
    assert buf.find(b'\r\n', 5) == 10

    buf.clear()
    buf.write(b'asdf\r\njkl;\r\n1234\r\na')
    assert buf.find(b'\r\n') == 4
    assert buf.find(b'x') == -1
    assert buf.find(b'\r\n', 5) == 10

    with raises(ValueError):
        buf.find(b'')
コード例 #4
0
ファイル: test.py プロジェクト: brmmm3/circularbuffer
b = CircularBuffer(48)
print(b)
print(b.write(b"Hello"))
print(b)
print(b.peek(3))
print(b.drop(2))
print(b)
print(b.peek(4))
print(b)
print(b.read(4))
print(b)
print(b.read(4))
print(b)
print(b.write(b"Hello"))
print(b)
print(b.clear())
print(b)
print("writemsg", b.writemsg(b"Hello"))
print(b)
print(b.peek(10))
print("peekmsg", b.peekmsg())
print(b)
print("readmsg", b.readmsg())
print(b)
print("readmsg", b.readmsg())
print(b)
print(b.writemsg(b"Hello"))
print(b)
print(b.readmsg_into(ba))
print(ba)
print(b)