def test_get_loop_one_elem(self): """ list: 1 -> None get_loop should return the head of the list. :return: void """ n = Node(1, None) n.next = n self.assertTrue(get_loop(n) is n)
def setUp(self) -> None: self.n1 = Node("n1") a = Node("a") self.b = Node("b") c = Node("c") self.n2 = Node("n2") self.d = Node("d") self.n1.next = a a.next = self.b self.b.next = c self.n2.next = self.d self.d.next = self.b
def test_get_loop(self): """ list: 1 -> 2 -> 3 -> 4 -> 2 (2 is the same Node instance as the first 2) get_loop should return the Node instance with value 2 :return: void """ n4 = Node(4, None) n3 = Node(3, n4) n2 = Node(2, n3) n1 = Node(1, n2) n4.next = n2 #import pdb #pdb.set_trace() self.assertTrue(get_loop(n1) is n2)