def test_init_bug(): """ test the init function for bugs""" myArr = [1, 2, 3] q1 = OurQueue(myArr) myArr[0] = -1 res = q1.front() assert res == -1
class TestQueue1(unittest.TestCase): def setUp(self): self.q1 = OurQueue() def test_front_empty(self): """Q1: test calling front on empty queue""" res = self.q1.front() self.assertEqual(res, None, "calling front from empty Queue should return None")
class TestQueue1(unittest.TestCase): def setUp(self): self.emptyQ = OurQueue() self.q1 = OurQueue([1, 2, 3]) def test_remove1(self): """Q4: test calling remove on queue of size >1""" item = self.q1.remove() self.assertEqual(item, 1, "did not return 1st item in queue") self.assertEqual(2, len(self.q1), "queue should have 2 items")
class TestQueue3(unittest.TestCase): def setUp(self): self.q1 = OurQueue([1]) def test_remove_size1(self): """Q3: test calling remove on queue of size 1""" res = self.q1.remove() self.assertEqual(res, 1, "removing from Queue of size 1 should return 1") self.assertEqual(len(self.q1), 0, "removing from Queue of size 1 should leave len==0")
class TestQueue2(unittest.TestCase): def setUp(self): self.q1 = OurQueue() def test_remove_empty(self): """Q2: test calling remove on empty queue""" res = self.q1.remove() self.assertEqual(res, None, "removing from empty Queue should return None") self.assertEqual(len(self.q1), 0, "removing from empty Queue should leave len==0")
def test_front_empty(): """Q1: test calling front on empty queue""" q1 = OurQueue() res = q1.front() assert res == None
def test_remove_size1(): """Q3: test calling remove on queue of size 1""" q1 = OurQueue([1]) res = q1.remove() assert res == 1 assert len(q1) == 0
def test_remove_empty(): """Q2: test calling remove on empty queue""" q1 = OurQueue() res = q1.remove() assert res == None, "removing from empty Queue should return None" assert len(q1) == 0, "removing from empty Queue should leave len==0"
def setUp(self): self.emptyQ = OurQueue() self.q1 = OurQueue([1, 2, 3])
def test_add(): """Q5: test calling add on queue of size 0""" q1 = OurQueue() res = q1.add("hi") assert res == None assert len(q1) == 1
def setUp(self): self.q1 = OurQueue()
def test_front_size1(): """Q6: test front of full queue""" q1 = OurQueue([3]) assert q1.front() == 3
def test_add_empty(): """Q5: test adding item to empty queue""" q1 = OurQueue() q1.add(1) assert len(q1) == 1 assert q1.front() == 1
def test_front(): """Q6: test front()""" q1 = OurQueue() q1.add(5) assert q1.front() == 5
def test_add(): """Q5: test add()""" q1 = OurQueue() q1.add(5) assert len(q1) == 1