コード例 #1
0
    def test_lots_of_carry(self):

        first_list = generate_node_list([9, 9, 9, 9])
        second_list = generate_node_list([9, 9, 9])

        expected_sum = 10998
        actual_sum = sum_lists(first_list, second_list)

        self.assertEqual(expected_sum, actual_sum)
コード例 #2
0
    def test_diff_length(self):

        first_list = generate_node_list([7, 1, 6, 1])
        second_list = generate_node_list([5, 9, 2])

        expected_sum = 1912
        actual_sum = sum_lists(first_list, second_list)

        self.assertEqual(expected_sum, actual_sum)
コード例 #3
0
    def test_lots_of_carry(self):

        first_list = generate_node_list([9, 9, 9, 9])
        second_list = generate_node_list([9, 9, 9])

        expected_list = [1, 0, 9, 9, 8]
        actual_list = generate_list_node(
            sum_lists_big_to_small(first_list, second_list))

        self.assertEqual(actual_list, expected_list)
コード例 #4
0
    def test_diff_length(self):

        first_list = generate_node_list([1, 6, 1, 7])
        second_list = generate_node_list([2, 9, 5])

        expected_list = [1, 9, 1, 2]
        actual_list = generate_list_node(
            sum_lists_big_to_small(first_list, second_list))

        self.assertEqual(actual_list, expected_list)
コード例 #5
0
    def test_one_empty(self):

        first_list = generate_node_list([9, 9, 9, 9])
        second_list = None

        expected_sum = 9999
        actual_sum = sum_lists(first_list, second_list)

        self.assertEqual(expected_sum, actual_sum)
コード例 #6
0
    def test_book(self):

        raw_list = [3, 5, 8, 5, 10, 2, 1]
        expected_list = [1, 2, 3, 5, 8, 5, 10]

        pivot = 5

        start_node = generate_node_list(raw_list)

        actual_node = partition(start_node, 5)

        actual_list = generate_list_node(actual_node)

        self.assertEqual(expected_list, actual_list)
コード例 #7
0
    def test_basic_not_palindrome(self):

        test_list = generate_node_list([0, 2, 2, 1, 0])

        self.assertEqual(False, is_palindrome(test_list))
コード例 #8
0
    def test_reverse_list(self):
        test_list = generate_node_list([1, 2, 3, 4, 5, 6])
        expected_list = generate_node_list([6, 5, 4, 3, 2, 1])
        reversed_list = reverse_list_with_clone(test_list)

        self.assertEqual(True, compare_lists(expected_list, reversed_list))
コード例 #9
0
    def test_reverse_list_one_element(self):
        test_list = generate_node_list([6])
        expected_list = generate_node_list([6])
        reversed_list = reverse_list_with_clone(test_list)

        self.assertEqual(True, compare_lists(expected_list, reversed_list))