Esempio n. 1
0
 private void MergeSortTest(IMergeSorter mergeSorter)
 {
     int[] a = new int[] { 3, 7, 6, 2, 5, 9, 4, 8 };
     mergeSorter.MergeSort(a, 0, a.Length - 1);
     for (int i = 0; i < a.Length; i++)
     {
         Assert.AreEqual(i + 2, a[i]);
     }
 }
Esempio n. 2
0
 private void MergeSortRandomArrayTest(IMergeSorter mergeSorter)
 {
     int[] a        = GenerateRandomArray(100);
     int[] expected = (int[])a.Clone();
     Array.Sort(expected);
     mergeSorter.MergeSort(a, 0, a.Length - 1);
     for (int i = 0; i < a.Length; i++)
     {
         Assert.AreEqual(expected[i], a[i]);
     }
 }
Esempio n. 3
0
 private void RunTests(IMergeSorter mergeSorter)
 {
     MergeSortTest(mergeSorter);
     MergeSortRandomArrayTest(mergeSorter);
 }