Ejemplo n.º 1
0
 def test_front(self):
     cb = CircularBuffer()
     assert cb.peek() is None
     cb.enqueue('A')
     assert cb.peek() == 'A'
     cb.enqueue('B')
     assert cb.peek() == 'A'
     cb.dequeue()
     assert cb.peek() == 'B'
     cb.dequeue()
     assert cb.peek() is None
Ejemplo n.º 2
0
 def test_enqueue(self):
     cb = CircularBuffer()
     cb.enqueue('A')
     assert cb.peek() == 'A'
     assert cb.size == 1
     cb.enqueue('B')
     assert cb.peek() == 'A'
     assert cb.size == 2
     cb.enqueue('C')
     assert cb.peek() == 'A'
     assert cb.size == 3
     assert cb.is_empty() is False
Ejemplo n.º 3
0
import sys
sys.path.append("../build/lib.linux-x86_64-3.6")
import time

from circularbuffer import CircularBuffer

ba = bytearray(10)

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