コード例 #1
0
        /// <summary>
        /// Test adding an item to an empty list
        /// </summary>
        static void TestAddEmptyLinkedList()
        {
            SortedLinkedList <string> list = new SortedLinkedList <string>();

            list.Add("Foxtrot");
            Console.Write("TestAddEmptyLinkedList: ");
            string listString = list.ToString();

            if (listString.Equals("Foxtrot") &&
                list.Count == 1)
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: Foxtrot  and 1 Actual: " +
                                  listString + " and " + list.Count);
            }
        }
コード例 #2
0
        /// <summary>
        /// Test adding an item to the back of the list
        /// </summary>
        static void TestAddBackOfLinkedList()
        {
            SortedLinkedList <string> list = new SortedLinkedList <string>();

            list.Add("Delta");
            list.Add("Echo");
            Console.Write("TestAddBackOfLinkedList: ");
            string listString = list.ToString();

            if (listString.Equals("Delta,Echo") &&
                list.Count == 2)
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: Delta,Echo and 2 Actual: " +
                                  listString + " and " + list.Count);
            }
        }
コード例 #3
0
        /// <summary>
        /// Test adding an item to the iterior of the list
        /// </summary>
        static void TestAddInteriorOfLinkedList()
        {
            SortedLinkedList <string> list = new SortedLinkedList <string>();

            list.Add("Delta");
            list.Add("Golf");
            list.Add("Echo");
            list.Add("Foxtrot");
            Console.Write("TestAddInteriorOfLinkedList: ");
            string listString = list.ToString();

            if (listString.Equals("Delta,Echo,Foxtrot,Golf") &&
                list.Count == 4)
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: Delta,Echo,Foxtrot,Golf and 4 Actual: " +
                                  listString + " and " + list.Count);
            }
        }