def test_first_1(self):
     """get first elt from empty list -> None"""
     expected = "a"
     pl = PositionalList()
     pl.add_first('a')
     res = pl.first()
     self.assertIsInstance(res, PositionalList.Position)
     actual = res.payload()
     self.assertEqual(actual, expected)
 def test_first_3(self):
     expected = "c"
     pl = PositionalList()
     pl.add_first('a')
     pl.add_first('b')
     pl.add_first('c')
     res = pl.first()
     self.assertIsInstance(res, PositionalList.Position)
     actual = res.payload()
     self.assertEqual(actual, expected)
 def test_delete_len(self):
     pl = PositionalList()
     a = pl.add_first('a')
     b = pl.add_after(a, 'b')
     c = pl.add_last('c')
     d = pl.add_after(c, 'd')
     self.assertEqual(len(pl), 4)
     pl.delete(a)
     self.assertEqual(len(pl), 3)
     pl.delete(pl.first())
     self.assertEqual(len(pl), 2)
     pl.delete(pl.last())
     self.assertEqual(len(pl), 1)
     self.assertTrue(pl)
     pl.delete(c)
     self.assertEqual(len(pl), 0)
     self.assertFalse(pl)
    def test_last_first_0(self):
        expected_first = "a"
        expected_last = "z"
        pl = PositionalList()
        pl.add_first('c')
        pl.add_last('x')
        pl.add_first('b')
        pl.add_last('y')
        pl.add_last('z')
        pl.add_first('a')

        res = pl.first()
        self.assertIsInstance(res, PositionalList.Position)
        actual_first = res.payload()
        self.assertEqual(actual_first, expected_first)

        res = pl.last()
        self.assertIsInstance(res, PositionalList.Position)
        actual_last = res.payload()
        self.assertEqual(actual_last, expected_last)

        self.assertEqual(len(pl), 6)
 def test_first_0(self):
     """get first elt from empty list -> None"""
     pl = PositionalList()
     actual = pl.first()
     self.assertIsNone(actual)