def test_get_first(self): l = DoublyLinkedList() self.assertRaises(IndexError, l.get_first) for i in range(50): l.add_first(i) self.assertEqual(l.get_first(), i)
def test_add_first(self): la = DoublyLinkedList() lb = DoublyLinkedList() for i in range(1000): n = random.randint(1, 360) la.add(n) lb.add_first(n) self.assertEqual(la, lb.reverse())
def test_index_of(self): l = DoublyLinkedList() self.assertRaises(ValueError, l.index_of, 'a') for i in range(5): l.add(1) self.assertEqual(l.index_of(1), 0) l.remove_last() l.add(2) self.assertEqual(l.index_of(2), 4) l.remove_first() l.add_first(2) self.assertEqual(l.index_of(1), 1)