예제 #1
0
        public void Should_count_inversions(int[] arr, long expected)
        {
            var count = CountingInversions.CountInversions(arr);

            AssertHelpers.AssertIsSorted(arr);
            Assert.Equal(expected, count);
        }
예제 #2
0
        public void Should_sort_an_array(int[] a, int numSwaps, int firstElement, int lastElement)
        {
            var printer = new FakePrinter();
            var sort    = new BubbleSort(printer);

            sort.Sort(a);
            AssertHelpers.AssertIsSorted(a);
            Assert.Equal($"Array is sorted in {numSwaps} swaps.", printer.Printed[0]);
            Assert.Equal($"First Element: {firstElement}", printer.Printed[1]);
            Assert.Equal($"Last Element: {lastElement}", printer.Printed[2]);
        }
예제 #3
0
        public void Should_sort_array(int[] arr)
        {
            var sortedArr = Quick.Sort(arr);

            AssertHelpers.AssertIsSorted(sortedArr);
        }