Exemple #1
0
 def test_box_into_list1(self):
     t = 465
     head = ListNode(5)
     head.append(ListNode(6)).append(ListNode(4))
     v1 = get_list_value(head)
     v2 = get_list_value(ListNode.box_into_list(t))
     self.assertEqual(v1, v2)
Exemple #2
0
 def test_box_into_list2(self):
     t = 342
     head = ListNode(2)
     head.append(ListNode(4)).append(ListNode(3))
     v1 = get_list_value(head)
     v2 = get_list_value(ListNode.box_into_list(t))
     self.assertEqual(v1, v2)
Exemple #3
0
    def test_solution3(self):
        h1 = ListNode(9)

        h2 = ListNode(5)
        h2.append(ListNode(6)).append(ListNode(4))

        s = Solution()
        sum_list = s.addTwoNumbers(h1, h2)
        real_list = ListNode.box_into_list(474)
        self.assertEqual(get_list_value(real_list),
                         get_list_value(sum_list))
Exemple #4
0
    def test_solution3(self):
        h1 = ListNode(9)

        h2 = ListNode(5)
        h2.next = ListNode(6)
        h2.next.next = ListNode(4)

        s = Solution()
        sum_list = s.addTwoNumbers(h1, h2)
        real_list = Solution.box_into_list(474)
        self.assertEqual(Solution.get_list_val(real_list),
                         Solution.get_list_val(sum_list))
Exemple #5
0
    def test_list5(self):
        head = ListNode(5)
        head.append(ListNode(6)).append(ListNode(4))

        list_val = 465
        self.assertEqual(list_val, get_list_value(head))
Exemple #6
0
    def test_list4(self):
        head = ListNode(3)
        head.append(ListNode(9))

        list_val = 93
        self.assertEqual(list_val, get_list_value(head))
Exemple #7
0
    def test_list3(self):
        head = ListNode(3)

        list_val = 3
        self.assertEqual(list_val, get_list_value(head))
Exemple #8
0
    def test_list2(self):
        head = ListNode(0)

        list_val = 0
        self.assertEqual(list_val, get_list_value(head))
Exemple #9
0
    def test_list1(self):
        head = ListNode(2)
        head.append(ListNode(4)).append(ListNode(3))

        list_val = 342
        self.assertEqual(list_val, get_list_value(head))
Exemple #10
0
    def test_solution1(self):
        h1 = ListNode(2)
        node2 = ListNode(4)
        node3 = ListNode(3)
        h1.next = node2
        node2.next = node3

        h2 = ListNode(5)
        n2 = ListNode(6)
        n3 = ListNode(4)
        h2.next = n2
        n2.next = n3

        s = Solution()
        sum_list = s.addTwoNumbers(h1, h2)
        real_list = Solution.box_into_list(807)
        self.assertEqual(Solution.get_list_val(real_list),
                         Solution.get_list_val(sum_list))