public void TestStoogeSort()
        {
            int[] arr      = { 3, 7, 4, 8, 6, 2, 1, 5 };
            int   n        = arr.Length;
            var   actual   = sort.Sort(arr, 0, n - 1);
            var   expected = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };

            Assert.Equal(expected, actual);
        }
示例#2
0
        public void SortingTests()
        {
            int[] array;
            List<int> aList;

            LoadArray(out array);
            BubbleSort.Sort(array);
            Assert.IsTrue(IsArraySorted(array));

            LoadList(out aList);
            BubbleSort.Sort(aList);
            Assert.IsTrue(IsListSorted(aList));

            LoadArray(out array);
            HeapSort.Sort(array);
            Assert.IsTrue(IsArraySorted(array));

            LoadArray(out array);
            InsertionSort.Sort(array);
            Assert.IsTrue(IsArraySorted(array));

            LoadArray(out array);
            MergeSort.Sort(array);
            Assert.IsTrue(IsArraySorted(array));

            LoadList(out aList);
            MergeSort.Sort(aList);
            Assert.IsTrue(IsListSorted(aList));

            LoadArray(out array);
            QuickSort.Sort(array);
            Assert.IsTrue(IsArraySorted(array));

            LoadArray(out array);
            SelectionSort.Sort(array);
            Assert.IsTrue(IsArraySorted(array));

            LoadList(out aList);
            SelectionSort.Sort(aList);
            Assert.IsTrue(IsListSorted(aList));

            LoadList(out aList);
            StoogeSort.Sort(aList);
            Assert.IsTrue(IsListSorted(aList));

        }