示例#1
0
 def test_copy(self):
     qs = QueueSet([1,3,5,7])
     qs2 = qs.copy()
     assert len(qs) == 4
     assert len(qs2) == 4
     qs.enqueue(9)
     assert len(qs) == 5
     assert len(qs2) == 4
示例#2
0
 def test_enqueue_one_thing_twice(self):
     qs = QueueSet()
     qs.enqueue('home')
     qs.enqueue('home')
     assert len(qs) == 1
     assert qs.front() == 'home'
     k = qs.poll()
     assert k == 'home'
     assert len(qs) == 0
     assert qs.front() is None
示例#3
0
 def test_clear(self):
     qs = QueueSet()
     self.fill_queue(qs, 100)
     qs.clear()
     assert len(qs) == 0
     qs.enqueue('a')
     qs.enqueue('b')
     qs.clear()
     assert len(qs) == 0
     assert not 'a' in qs
     assert not 'b' in qs
示例#4
0
 def test_enqueue_two(self):
     qs = QueueSet()
     qs.enqueue('a')
     qs.enqueue('b')
     assert len(qs) == 2
     assert qs.front() == 'a'
     k = qs.poll()
     assert k == 'a'
     assert len(qs) == 1
     assert qs.front() == 'b'
     k = qs.poll()
     assert k == 'b'
     assert len(qs) == 0
     assert qs.front() is None
示例#5
0
 def test_enqueue_multiple_replace_one(self):
     qs = QueueSet()
     qs.enqueue('a')
     qs.enqueue('b')
     qs.enqueue('c')
     qs.enqueue('d')
     qs.enqueue('b')
     assert len(qs) == 4
     assert qs.front() == 'a'
     qs.poll()
     k = qs.poll()
     assert k == 'b'
     assert len(qs) == 2
示例#6
0
 def test_enq_multi_replace_multi(self):
     qs = QueueSet()
     self.fill_queue(qs, 100)
     qs.enqueue(23)
     qs.enqueue(47)
     qs.enqueue(34)
     qs.enqueue(194)
     assert 23 in qs
     assert 47 in qs
     assert 34 in qs
     assert 194 in qs
     assert len(qs) == 101
     assert qs.front() == 0