示例#1
0
        public void SortSimpleArray()
        {
            var array = GenerateRandomArray(3);

            HoareSort.QuickSort(array);
            Assert.That(array[0] < array[1] && array[1] < array[2], "Simple array sorting");
        }
示例#2
0
        public void SortHugeArray()
        {
            var array = GenerateRandomArray(1500000000);

            HoareSort.QuickSort(array);
            for (var i = 1; i < array.Length; i++)
            {
                Assert.That(array[i - 1] < array[i]);
            }
        }
示例#3
0
        public void SortArrayEqualsElements()
        {
            var array = new int[100];

            HoareSort.QuickSort(array);
            foreach (var n in array)
            {
                Assert.That(n == array[0]);
            }
        }
示例#4
0
        public void SortNormalArray()
        {
            var array   = GenerateRandomArray(1000);
            var indexes = GenerateRandomArray(20, array.Length);

            HoareSort.QuickSort(array);
            for (var i = 0; i < indexes.Length; i += 2)
            {
                Assert.That((array[indexes[i]] < array[indexes[1 + i]] && indexes[i] < indexes[1 + i]) ||
                            (array[indexes[i]] > array[indexes[1 + i]] && indexes[i] > indexes[1 + i]), "Normal array sorting");
            }
        }
示例#5
0
        public void SortEmptyArray()
        {
            var array = new int[0];

            HoareSort.QuickSort(array);
        }