def test_AddDecimalLinkedList_SecondLonger_Carry(self):
        first = LinkedList()
        second = LinkedList()
        compare_list = LinkedList()

        first.from_list([8, 5, 0])
        second.from_list([1, 2, 4, 9])
        compare_list.from_list([2, 0, 9, 9])

        res = first.add_as_decimal(second)

        for index, item in enumerate(res):
            self.assertEquals(item.data, compare_list[index].data)
    def test_AddDecimalLinkedList_SameLength_Carry(self):
        first = LinkedList()
        second = LinkedList()
        compare_list = LinkedList()

        first.from_list([8, 7, 8, 5])
        second.from_list([2, 2, 1, 6])
        compare_list.from_list([1, 1, 0, 0, 1])

        res = first.add_as_decimal(second)

        for index, item in enumerate(res):
            self.assertEquals(item.data, compare_list[index].data)
Пример #3
0
    def test_AddDecimalLinkedList_SecondLonger_Carry(self):
        first = LinkedList()
        second = LinkedList()
        compare_list = LinkedList()

        first.from_list([8, 5, 0])
        second.from_list([1, 2, 4, 9])
        compare_list.from_list([2, 0, 9, 9])

        res = first.add_as_decimal(second)

        for index, item in enumerate(res):
            self.assertEquals(item.data, compare_list[index].data)
Пример #4
0
    def test_AddDecimalLinkedList_SameLength_Carry(self):
        first = LinkedList()
        second = LinkedList()
        compare_list = LinkedList()

        first.from_list([8, 7, 8, 5])
        second.from_list([2, 2, 1, 6])
        compare_list.from_list([1, 1, 0, 0, 1])

        res = first.add_as_decimal(second)

        for index, item in enumerate(res):
            self.assertEquals(item.data, compare_list[index].data)
    def test_AddDecimalLinkedList_SameLength_NoCarry(self):
        first = LinkedList()
        second = LinkedList()
        compare_list = LinkedList()

        num_of_elements = 4
        for i in range(num_of_elements):
            first.append(i)
            second.append(i)
            compare_list.append(i + i)

        print(first)
        print(second)
        print(compare_list)

        res = first.add_as_decimal(second)

        for index, item in enumerate(res):
            self.assertEquals(item.data, compare_list[index].data)
Пример #6
0
    def test_AddDecimalLinkedList_SameLength_NoCarry(self):
        first = LinkedList()
        second = LinkedList()
        compare_list = LinkedList()

        num_of_elements = 4
        for i in range(num_of_elements):
            first.append(i)
            second.append(i)
            compare_list.append(i+i)

        print(first)
        print(second)
        print(compare_list)

        res = first.add_as_decimal(second)

        for index, item in enumerate(res):
            self.assertEquals(item.data, compare_list[index].data)