def test_pop_add(self): lifo = LIFOQueue() lifo.add(1) lifo.add(2) lifo.add(3) self.assertEqual(3, lifo.length()) self.assertEqual(3, lifo.pop()) self.assertEqual(2, lifo.pop()) self.assertEqual(1, lifo.pop())
def test_is_empty(self): lifo = LIFOQueue() self.assertTrue(lifo.is_empty(), "New queue should be empty") lifo.add(1) self.assertFalse(lifo.is_empty(), "Queue with added element shouldn't be empty") lifo.pop() self.assertTrue( lifo.is_empty(), "When all elements removed from a queue it should be empty")
def test_remove(self): lifo = LIFOQueue() lifo.add(1) lifo.add(2) lifo.add(3) self.assertFalse(lifo.remove(5)) self.assertTrue(lifo.remove(2)) self.assertEqual(2, lifo.length()) self.assertEqual(3, lifo.pop()) self.assertEqual(1, lifo.pop())
def search(self, problem): return self._search.search(problem, LIFOQueue())