Beispiel #1
0
        /// <summary>
        /// Test removing an item from an empty list
        /// </summary>
        static void TestRemoveFromEmptyLinkedList()
        {
            UnsortedLinkedList <string> list = new UnsortedLinkedList <string>();

            Console.Write("TestRemoveFromEmptyLinkedList: ");
            if (!list.Remove("Foxtrot"))
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: false Actual: true");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Test removing an item not in the list
        /// </summary>
        static void TestRemoveItemNotInLinkedList()
        {
            UnsortedLinkedList <string> array = new UnsortedLinkedList <string>();

            array.Add("Foxtrot");
            Console.Write("TestRemoveItemNotInLinkedList: ");
            if (!array.Remove("Golf"))
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: false Actual: true");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Test removing an item from the interior of the list
        /// </summary>
        static void TestRemoveItemFromInteriorOfLinkedList()
        {
            UnsortedLinkedList <string> list = new UnsortedLinkedList <string>();

            list.Add("Foxtrot");
            list.Add("Echo");
            list.Add("Delta");
            Console.Write("TestRemoveItemInteriorOfLinkedList: ");
            bool   removed    = list.Remove("Echo");
            string listString = list.ToString();

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