コード例 #1
0
        /// <summary>
        /// Test removing an item from an empty array
        /// </summary>
        static void TestRemoveEmptyDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            System.Console.Write("TestRemoveEmptyDynamicArray: ");
            if (!array.Remove("Foxtrot"))
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: false Actual: true");
            }
        }
コード例 #2
0
        /// <summary>
        /// Test finding the index of an item in an empty array
        /// </summary>
        static void TestIndexOfEmptyDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            System.Console.Write("TestIndexOfEmptyDynamicArray: ");
            int actualIndex = array.IndexOf("Foxtrot");

            if (actualIndex == -1)
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: -1 Actual: " + actualIndex);
            }
        }
コード例 #3
0
        /// <summary>
        /// Test adding an item to an empty array
        /// </summary>
        static void TestAddEmptyDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            array.Add("Foxtrot");
            System.Console.Write("TestAddEmptyDynamicArray: ");
            String arrayString = array.ToString();

            if (arrayString.Equals("Foxtrot") &&
                array.Count == 1)
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: Foxtrot Actual: " + arrayString);
            }
        }
コード例 #4
0
        /// <summary>
        /// Test finding the index of an item at the back of the array
        /// </summary>
        static void TestIndexOfBackOfDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            array.Add("Delta");
            array.Add("Echo");
            array.Add("Foxtrot");
            System.Console.Write("TestIndexOfBackOfDynamicArray: ");
            int actualIndex = array.IndexOf("Foxtrot");

            if (actualIndex == 2)
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: 2 Actual: " + actualIndex);
            }
        }
コード例 #5
0
        /// <summary>
        /// Test adding an item to the iterior of the array
        /// </summary>
        static void TestAddInteriorOfDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            array.Add("Delta");
            array.Add("Foxtrot");
            array.Add("Echo");
            System.Console.Write("TestAddInteriorOfDynamicArray: ");
            String arrayString = array.ToString();

            if (arrayString.Equals("Delta,Echo,Foxtrot") &&
                array.Count == 3)
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: Delta,Echo,Foxtrot Actual: " + arrayString);
            }
        }
コード例 #6
0
        /// <summary>
        /// Test removing an item at the back of the array
        /// </summary>
        static void TestRemoveItemBackOfDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            array.Add("Delta");
            array.Add("Echo");
            array.Add("Foxtrot");
            System.Console.Write("TestRemoveItemBackOfDynamicArray: ");
            bool   removed     = array.Remove("Foxtrot");
            String arrayString = array.ToString();

            if (removed &&
                arrayString.Equals("Delta,Echo") &&
                array.Count == 2)
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: Delta,Echo Actual: " + arrayString);
            }
        }
コード例 #7
0
        /// <summary>
        /// Test adding an item to an array that needs to be expanded. Also tests adding an item at
        /// the beginning of the array
        /// </summary>
        static void TestAddExpandDynamicArray()
        {
            OrderedDynamicArray <String> array = new OrderedDynamicArray <String>();

            array.Add("Foxtrot");
            array.Add("Echo");
            array.Add("Delta");
            array.Add("Charlie");
            array.Add("Bravo");
            array.Add("Alpha");
            System.Console.Write("TestAddExpandedDynamicArray: ");
            String arrayString = array.ToString();

            if (arrayString.Equals("Alpha,Bravo,Charlie,Delta,Echo,Foxtrot") &&
                array.Count == 6)
            {
                System.Console.WriteLine("Passed");
            }
            else
            {
                System.Console.WriteLine("FAILED!!! Expected: Alpha,Bravo,Charlie,Delta,Echo,Foxtrot Actual: " + arrayString);
            }
        }