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