Example #1
0
	def test_sum_equal_lists(self):
		n1 = Node(12)
		n2 = Node(55)
		n3 = Node(128)

		linked_list1 = List()
		linked_list1.add_in_tail(n1)
		linked_list1.add_in_tail(n2)
		linked_list1.add_in_tail(n3)

		n4 = Node(12)
		n5 = Node(55)
		n6 = Node(128)

		linked_list2 = List()
		linked_list2.add_in_tail(n4)
		linked_list2.add_in_tail(n5)
		linked_list2.add_in_tail(n6)

		result = List.sum_lists(linked_list1, linked_list2)

		self.assertEqual(result, [24, 110, 256])
Example #2
0
	def test_sum_not_equal_lists(self):
		n1 = Node(12)
		n2 = Node(55)
		n3 = Node(128)

		linked_list1 = List()
		linked_list1.add_in_tail(n1)
		linked_list1.add_in_tail(n2)
		linked_list1.add_in_tail(n3)

		n4 = Node(12)
		n5 = Node(55)
		n6 = Node(128)
		n7 = Node(200)

		linked_list2 = List()
		linked_list2.add_in_tail(n4)
		linked_list2.add_in_tail(n5)
		linked_list2.add_in_tail(n6)
		linked_list2.add_in_tail(n7)

		result = List.sum_lists(linked_list1, linked_list2)

		self.assertIsNone(result)