def change_list2(n): n1 = Node(3) n2 = Node(4) n3 = Node(5) n4 = Node(6) n1.next = n2 n2.next = n3 n3.next = n4 n.next = n1
def testListManipulationInCallable(self): h = Node(3) h2 = Node(4) h3 = Node(5) self.__addNode(h,h2) self.assertEqual(h.next, h2) self.__addNode(h.next,h3) self.assertEqual(h2.next, h3) h.next = h3 self.assertEqual(h.next, h3)
def intersection(): n = Node(0) s = set() s.add(n) n1 = Node(0) if n in s: print("hi<-- gets printed") else: print("nay") if n1 in s: print("hi") else: print("nay <-- gets printed")
def check2(): h = Node(3) change_list2(h) print(h) print(h.next) print(h.next.next) print(h.next.next.next)
def check1(): n1 = Node(3) n2 = Node(4) n3 = Node(5) n4 = Node(6) n1.next = n2 n2.next = n3 n3.next = n4 print(n1) print(n2) print(n3) print(n4) change_list(n1) print("****") print(n1) print(n2) print(n3) print(n4)
def check3(): n1 = Node(300) n1.next = Node(400) n1.next.next = Node(500) h = n1 h.next = Node(10000) print(n1)
def testListManipulation(self): h = Node(3) h2 = Node(4) h3 = Node(5) h.next = h2 h.next.next = h3 self.assertEqual(h2.next, h3) h.next = h3 self.assertEqual(h.next, h3)
def testNullNodeCreation(self): h = Node() print(h) self.assertEqual(h, None) self.assertEqual(h.val, None) self.assertEqual(h.next, None)
def testListCreation(self): h = Node(3) h2 = Node(4) h.next = h2 self.assertEqual(h.val, 3) self.assertEqual(h.next, h2)
def testNonNodeAddition(self): h = Node(3) with self.assertRaises(TypeError): h.next = 5
def testNodeCreation(self): h = Node(3) # self.assertEqual(print(h), "Node(3)->None") self.assertEqual(h.val, 3) self.assertEqual(h.next, None)