예제 #1
0
        public void SumListsInForwardOrderTest_AdditionalCarrier_2()
        {
            var head1 = new Node(1);
            var head2 = new Node(9).AppendToTail(9).AppendToTail(9);

            var result = SumLists.SumListsInForwardOrder(head1, head2);

            var resultString = "";

            while (result != null)
            {
                resultString += result.Data;
                resultString += "-";
                result        = result.Next;
            }

            resultString.TrimEnd('-').Should().Be("1-0-0-0");
        }
예제 #2
0
        public void SumListsInForwardOrderTest_TwoListsWithSameLength()
        {
            var head1 = new Node(9).AppendToTail(7).AppendToTail(8);
            var head2 = new Node(6).AppendToTail(8).AppendToTail(5);

            var result = SumLists.SumListsInForwardOrder(head1, head2);

            var resultString = "";

            while (result != null)
            {
                resultString += result.Data;
                resultString += "-";
                result        = result.Next;
            }

            resultString.TrimEnd('-').Should().Be("1-6-6-3");
        }
예제 #3
0
        public void SumListsInForwardOrderTest_TwoListsWithDifferentLength()
        {
            var head1 = new Node(7).AppendToTail(1).AppendToTail(6).AppendToTail(3).AppendToTail(1).AppendToTail(9);
            var head2 = new Node(5).AppendToTail(9).AppendToTail(2);

            var result = SumLists.SumListsInForwardOrder(head1, head2);

            var resultString = "";

            while (result != null)
            {
                resultString += result.Data;
                resultString += "-";
                result        = result.Next;
            }

            resultString.TrimEnd('-').Should().Be("7-1-6-9-1-1");
        }