Beispiel #1
0
        public void MergeSort_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.MergeSort(testArray);
            CollectionAssert.AreEqual(expectedArray, testArray);
        }
Beispiel #2
0
        public void MergeSort_NullArray()
        {
            // Arrange
            int[] array = null;

            // Act
            Sortings.MergeSort(array);
        }
Beispiel #3
0
        public void MergeSort_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.MergeSort(actual);

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

            // Act
            Sortings.MergeSort(actual);

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

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

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

            Sortings.MergeSort(largeTestArray);
            CollectionAssert.AreEqual(expectedArray, largeTestArray);
        }
Beispiel #6
0
 public void MergeSort_EmptyArray_ArgumentNullException()
 {
     Sortings.MergeSort(new int[] { });
 }
Beispiel #7
0
 public void MergeSort_Null_ArgumentNullException()
 {
     Sortings.MergeSort(null);
 }