コード例 #1
0
    def test_right_append(self):
        ll = LinkedList()
        ll.right_append(5)
        ll.right_append(7)

        self.assertEqual(ll.head.data, 5)
        self.assertEqual(ll.head.pointer_next.data, 7)
        self.assertIsNone(ll.head.pointer_next.pointer_next)
コード例 #2
0
 def test__iter__(self):
     ll = LinkedList()
     ll.right_append(100)
     ll.right_append(99)
     ll.left_append(0)
     iterator = iter(ll)
     self.assertEqual(next(iterator), 0)
     self.assertEqual(next(iterator), 100)
     self.assertEqual(next(iterator), 99)
     self.assertRaises(StopIteration, next, iterator)
コード例 #3
0
    def test_right_append_empty_list(self):
        ll = LinkedList()
        ll.right_append(700)

        self.assertEqual(ll.head.data, 700)
        self.assertIsNone(ll.head.pointer_next)
コード例 #4
0
 def test__contains__(self):
     ll = LinkedList()
     ll.right_append(3)
     ll.right_append(5)
     self.assertEqual(ll.__contains__(3), True)
     self.assertEqual(ll.__contains__(10), False)