Пример #1
0
def test_reader_reads_data_and_moves_offset(buffer):
    read_buff = RingBuffer(name=buffer.name, size=0, create=False)

    messages = _messages(3)
    expected = [_decode_message(m) for m in messages]
    for m in messages:
        buffer.put(m)

    got = [_decode_message(read_buff.get()) for _ in range(3)]
    assert got == expected

    assert read_buff.reader_pos() == 48
Пример #2
0
def test_reader_reads_data_and_moves_offset_when_writer_wraps_around(buffer):
    read_buff = RingBuffer(name=buffer.name, size=0, create=False)

    messages = _messages(8)
    for m in messages[:6]:
        buffer.put(m)

    [read_buff.get() for _ in range(6)]

    for m in messages[6:]:
        buffer.put(m)

    got = [_decode_message(read_buff.get()) for _ in range(2)]
    expected = [_decode_message(m) for m in messages[6:]]
    assert got == expected

    assert read_buff.reader_pos() == 32