Exemple #1
0
        public void QuickSort_TestArraySort_ExpectedArray()
        {
            int[] testArray     = { 7, -2, 1, 4, 0, 9, 5, 3, 1, 8 };
            int[] expectedArray = { -2, 0, 1, 1, 3, 4, 5, 7, 8, 9 };

            Sortings.QuickSort(testArray);
            CollectionAssert.AreEqual(expectedArray, testArray);
        }
Exemple #2
0
        public void QuickSort_NullArray()
        {
            // Arrange
            int[] array = null;

            // Act
            Sortings.QuickSort(array);
        }
Exemple #3
0
        public void QuickSort_IntArrayOfNegativeAndBigEl()
        {
            // Arrange
            var expexted = new[] { int.MinValue, -333, 0, 1, 9999, int.MaxValue };
            var actual   = new[] { 9999, int.MaxValue, -333, int.MinValue, 0, 1 };

            // Act
            Sortings.QuickSort(actual);

            // Assert
            Assert.IsTrue(expexted.SequenceEqual(actual));
        }
Exemple #4
0
        public void QuickSort_IntArrayOf5El()
        {
            // Arrange
            var expexted = new[] { 1, 2, 3, 4, 5 };
            var actual   = new[] { 3, 1, 2, 5, 4 };

            // Act
            Sortings.QuickSort(actual);

            // Assert
            Assert.IsTrue(expexted.SequenceEqual(actual));
        }
Exemple #5
0
        public void QuickSort_LargeArray_ExtectedArray()
        {
            int    minPossibleValue = 0;
            int    maxPossibleValue = 1000000;
            Random randNum          = new Random();

            int[] largeTestArray = new int[Int32.MaxValue / 10];
            for (int i = 0; i < largeTestArray.Length; i++)
            {
                largeTestArray[i] = randNum.Next(minPossibleValue, maxPossibleValue);
            }

            int[] expectedArray = largeTestArray;
            Array.Sort(expectedArray);

            Sortings.QuickSort(largeTestArray);
            CollectionAssert.AreEqual(expectedArray, largeTestArray);
        }
Exemple #6
0
 public void QuickSort_EmptyArray_ArgumentNullException()
 {
     Sortings.QuickSort(new int[] { });
 }
Exemple #7
0
 public void QuickSort_Null_ArgumentNullException()
 {
     Sortings.QuickSort(null);
 }