Exemplo n.º 1
0
        public void LinkedListTest()
        {
            uint[] array0 = new uint[] { 0, 1, 2, 3, 4, 5, 6 };    // 6,543,210
            uint[] array1 = new uint[] { 0, 2, 4, 6, 8, 0, 3, 1 }; //13,086,420
            uint[] array2 = new uint[] { 9, 8, 7 };                //       789
            uint[] array3 = new uint[] { };
            uint[] array4 = new uint[] { 100 };                    //       100
            uint[] array5 = new uint[] { 0, 1, 3, 3, 4, 5, 6 };    // 6,543,310
            uint[] array6 = new uint[] { 9, 8, 8 };                //       889
            uint[] array7 = new uint[] { 0, 0, 1 };                //       100
            uint[] array8 = new uint[] { 8, 7, 7, 1 };             //     1,778

            SingleLinkedList <uint> List0 = new SingleLinkedList <uint>(array0);
            SingleLinkedList <uint> List1 = new SingleLinkedList <uint>(array1);
            SingleLinkedList <uint> List2 = new SingleLinkedList <uint>(array2);
            SingleLinkedList <uint> List3 = new SingleLinkedList <uint>(array3);
            SingleLinkedList <uint> List4 = new SingleLinkedList <uint>(array4);
            SingleLinkedList <uint> List5 = new SingleLinkedList <uint>(array5);
            SingleLinkedList <uint> List6 = new SingleLinkedList <uint>(array6);

            SingleLinkedList <uint> test1 = Questions.AddListsAsNumbers(List0, List0);
            SingleLinkedList <uint> test2 = Questions.AddListsAsNumbers(List1, List3);
            SingleLinkedList <uint> test3 = Questions.AddListsAsNumbers(List2, List4);
            SingleLinkedList <uint> test4 = Questions.AddListsAsNumbers(List3, List4);
            SingleLinkedList <uint> test5 = Questions.AddListsAsNumbers(List0, List4);
            SingleLinkedList <uint> test6 = Questions.AddListsAsNumbers(List6, List6);

            Assert.IsTrue(test1.ToArray().Compare(array1));
            Assert.IsTrue(test2.ToArray().Compare(array1));
            Assert.IsTrue(test3.ToArray().Compare(array6));
            Assert.IsTrue(test4.ToArray().Compare(array7));
            Assert.IsTrue(test5.ToArray().Compare(array5));
            Assert.IsTrue(test6.ToArray().Compare(array8));
        }