示例#1
0
 def test_is_empty(self):
     cb = CircularBuffer(2)
     assert cb.is_empty()
     cb.enqueue('test')
     assert not cb.is_empty()
     cb.dequeue()
     assert cb.is_empty()
示例#2
0
 def test_is_empty(self):
     c = CircularBuffer(3)
     assert c.is_empty() is True
     c.enqueue('A')
     assert c.is_empty() is False
     c.dequeue()
     assert c.is_empty() is True
示例#3
0
 def test_init(self):
     c = CircularBuffer(3)
     assert c.max_size == 3
     assert c.size == 0
     assert c.start == 0
     assert c.end == 0
     assert c.is_empty() is True
     assert c.is_full() is False
示例#4
0
 def test_dequeue(self):
     cb = CircularBuffer(['A', 'B', 'C'])
     assert cb.dequeue() == 'A'
     assert cb.size == 2
     assert cb.dequeue() == 'B'
     assert cb.size == 1
     assert cb.dequeue() == 'C'
     assert cb.size == 0
     assert cb.is_empty() is True
     with self.assertRaises(ValueError):
         cb.dequeue()
示例#5
0
 def test_dequeue(self):
     q = CircularBuffer(['A', 'B', 'C'])
     assert q.dequeue() == 'A'
     assert q.length() == 2
     assert q.dequeue() == 'B'
     assert q.length() == 1
     assert q.dequeue() == 'C'
     assert q.length() == 0
     assert q.is_empty() is True
     with self.assertRaises(ValueError):
         q.dequeue()
示例#6
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
示例#7
0
 def test_enqueue(self):
     q = CircularBuffer()
     q.enqueue('A')
     assert q.front() == 'A'
     assert q.length() == 1
     q.enqueue('B')
     assert q.front() == 'A'
     assert q.length() == 2
     q.enqueue('C')
     assert q.front() == 'A'
     assert q.length() == 3
     assert q.is_empty() is False
示例#8
0
 def test_enqueue(self):
     cb = CircularBuffer(5)
     cb.enqueue('A')
     assert cb.front() == 'A'
     assert cb.length() == 1
     cb.enqueue('B')
     assert cb.front() == 'A'
     assert cb.length() == 2
     cb.enqueue('C')
     assert cb.front() == 'A'
     assert cb.length() == 3
     assert cb.is_empty() is False
示例#9
0
 def test_enqueue(self):
     cb = CircularBuffer(4)
     cb.enqueue(3)
     assert cb.size == 1
     assert len(cb) == 4
     assert cb.is_empty() == False
     cb.enqueue(1)
     assert cb.size == 2
     cb.enqueue(4)
     assert cb.size == 3
     cb.enqueue(1)
     assert cb.size == 4
     assert cb.is_full() == True
     cb.enqueue(5)
     assert cb.size == 4
示例#10
0
 def test_init(self):
     cb = CircularBuffer()
     assert cb.head is None
     assert cb.length == 10
     assert cb.is_empty() is True
示例#11
0
 def test_init(self):
     q = CircularBuffer()
     assert q.front() is None
     assert q.length() == 0
     assert q.is_empty() is True
示例#12
0
 def test_init_with_list(self):
     q = CircularBuffer(['A', 'B', 'C'])
     assert q.front() == 'A'
     assert q.length() == 3
     assert q.is_empty() is False
示例#13
0
 def test_init(self):
     cb = CircularBuffer(8)
     assert cb.size == 0
     assert len(cb) == 8
     assert cb.is_empty() == True
示例#14
0
 def test_init(self):
     cb = CircularBuffer(5)
     assert cb.front() is None
     assert cb.length() == 0
     assert cb.is_empty() is True