Example #1
0
    def test_clone_linked_list(self):
        head = self.creating_list()
        new_head = Node.clone_linked_list(head)

        # getting the two lists for comparison
        old_list = Node.get_linked_list(head)
        new_list = Node.get_linked_list(new_head)

        self.assertEqual(new_list[1].data, 6)
        self.assertEqual(new_list[1].next, new_list[2])
        self.assertEqual(new_list[1].rnd, new_list[3])
        self.assertEqual(old_list, new_list)
        self.assertIsNot(old_list, new_list)
Example #2
0
 def test_get_linked_list(self):
     head = self.creating_list()
     result_list = Node.get_linked_list(head)
     self.assertEqual(result_list[2].data, 7)
     self.assertEqual(result_list[2].next, result_list[3])
     self.assertEqual(result_list[2].rnd, result_list[1])