public void TestMergeSortRandomLarge_Integers()
        {
            Random random      = new Random();
            int    upper_bound = 1000000;

            int[] randomValues = new int[upper_bound];
            for (int i = 0; i < upper_bound; i++)
            {
                randomValues[i] = random.Next(int.MinValue, int.MaxValue);
            }

            int[] sortedArray = MergeSort.Sort(randomValues);
            Array.Sort(sortedArray);

            Assert.Equal(sortedArray, randomValues);
        }
Пример #2
0
        public void tMergeSort()
        {
            List <int> test1 = new List <int>()
            {
                10, 9, 8, 7, 6
            };
            List <int> success1 = new List <int>()
            {
                6, 7, 8, 9, 10
            };
            List <int> merged1 = MergeSort.Sort(test1);
            bool       equals  = true;

            for (int i = 0; i < success1.Count; i++)
            {
                if (success1[i] != merged1[i])
                {
                    equals = false;
                    break;
                }
            }

            Assert.IsTrue(test1.Count == success1.Count && equals);
        }
 public void TestMergeSortDuplicates_String()
 {
     string[] sortedArray = MergeSort.Sort(unsortedStringsDuplicates);
     Array.Sort(unsortedStringsDuplicates);
     Assert.Equal(unsortedStringsDuplicates, sortedArray);
 }
 public void TestMergeSortDuplicates_Integers()
 {
     int[] sortedArray = MergeSort.Sort(unsortedIntegersDuplicates);
     Array.Sort(unsortedIntegersDuplicates);
     Assert.Equal(unsortedIntegersDuplicates, sortedArray);
 }
 public void TestMergeSort_Integer()
 {
     int[] sortedArray = MergeSort.Sort(unsortedIntegers);
     Array.Sort(unsortedIntegers);
     Assert.Equal(unsortedIntegers, sortedArray);
 }