Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
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")
Ejemplo n.º 3
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")
Ejemplo n.º 4
0
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
Ejemplo n.º 5
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"