Exemplo n.º 1
0
 public void QuickSortSingletonArray()
 {
     int[] a = new int[] { 88 };
     int[] expectedOutput = a.Clone() as int[];
     QuickSort.Sort(a);
     Assert.IsTrue(ArrayUtility.AreArraysEqual(a, expectedOutput));
 }
Exemplo n.º 2
0
 public void HeapSortEmptyArray()
 {
     int[] a = new int[0];
     int[] expectedOutput = a.Clone() as int[];
     HeapSort.Sort(a);
     Assert.IsTrue(ArrayUtility.AreArraysEqual(a, expectedOutput));
 }
Exemplo n.º 3
0
        public void QuickSortLargeRandomArray()
        {
            int arrayLength = 1000;

            int[] inputArray = new int[arrayLength];

            Random randomGenerator = new Random();

            for (int i = 0; i < arrayLength; i++)
            {
                inputArray[i] = randomGenerator.Next(maxValue: 20);
            }

            int[] expectedArray = inputArray.Clone() as int[];
            // default sort puts min at the front of the sorted array
            Array.Sort(expectedArray);

            QuickSort.Sort(inputArray);
            Assert.IsTrue(ArrayUtility.AreArraysEqual(inputArray, expectedArray));
        }