Exemplo n.º 1
0
        public void Reverse_Test01()
        {
            LinkedListInteger list = new LinkedListInteger();

            list.Head           = new Node <int>(1);
            list.Head.Next      = new Node <int>(2);
            list.Head.Next.Next = new Node <int>(3);
            Assert.Equal(123, list.ToInt());
            Assert.Equal(123, list.ToInt());

            list.Head = OTS.ReverseList(list.Head);
            Assert.Equal(321, list.ToInt());
        }
Exemplo n.º 2
0
        public void Stack_Carry_Sum01()
        {
            LinkedListInteger a = new LinkedListInteger();

            a.Head      = new Node <int>(1);
            a.Head.Next = new Node <int>(2);
            LinkedListInteger b = new LinkedListInteger();

            b.Head = new Node <int>(8);


            var sum             = OTS.LinkedListSumUsingStacks(a, b);
            LinkedListInteger s = new LinkedListInteger {
                Head = sum
            };

            Assert.Equal(20, s.ToInt());
        }
Exemplo n.º 3
0
        public void Basic_Sum01()
        {
            LinkedListInteger a = new LinkedListInteger();

            a.Head      = new Node <int>(1);
            a.Head.Next = new Node <int>(2);
            LinkedListInteger b = new LinkedListInteger();

            b.Head      = new Node <int>(3);
            b.Head.Next = new Node <int>(4);


            var sum             = OTS.LinkedListSum(a, b);
            LinkedListInteger s = new LinkedListInteger {
                Head = sum
            };

            Assert.Equal(46, s.ToInt());
        }
Exemplo n.º 4
0
        public void Carry_Sum02()
        {
            LinkedListInteger a = new LinkedListInteger();

            a.Head                = new Node <int>(9);
            a.Head.Next           = new Node <int>(9);
            a.Head.Next.Next      = new Node <int>(9);
            a.Head.Next.Next.Next = new Node <int>(9);
            LinkedListInteger b = new LinkedListInteger();

            b.Head = new Node <int>(6);


            var sum             = OTS.LinkedListSum(a, b);
            LinkedListInteger s = new LinkedListInteger {
                Head = sum
            };

            Assert.Equal(10005, s.ToInt());
        }