def test_addTwoNumbers(self): solution = Solution() l1 = ListNode(2) l1.next = ListNode(4) l1.next.next = ListNode(3) l2 = ListNode(5) l2.next = ListNode(6) l2.next.next = ListNode(4) lsum = ListNode(7) lsum.next = ListNode(0) lsum.next.next = ListNode(8) solution.addTwoNumbers(l1, l2) == lsum
class SolutionTest(unittest.TestCase): def setUp(self): self.sol = Solution() def test_1(self): l1 = make_link_list(2, 4, 3) l2 = make_link_list(5, 6, 4) self.assertEqual(display_link_list(self.sol.addTwoNumbers(l1, l2)), "7 -> 0 -> 8") def test_2(self): l1 = make_link_list(0) l2 = make_link_list(0) self.assertEqual(display_link_list(self.sol.addTwoNumbers(l1, l2)), "0") def test_3(self): l1 = make_link_list(9, 9, 9) l2 = make_link_list(1, 1, 1) self.assertEqual(display_link_list(self.sol.addTwoNumbers(l1, l2)), "0 -> 1 -> 1 -> 1")