Пример #1
0
        public void PartialMergeSort_Comparison(int[] input, int index, int count, int[] expected)
        {
            var actual = SortExtensions.MergeSort(input, index, count, IntComparison);

            Assert.Equal(expected, actual);
            Assert.Same(input, actual);
        }
Пример #2
0
 public void MergeSort_Comparison_Preconditions()
 {
     Assert.Throws <ArgumentNullException>(
         () => SortExtensions.MergeSort(null, IntComparison));
     Assert.Throws <ArgumentNullException>(
         () => SortExtensions.MergeSort(new[] { 1 }, (Comparison <int>)null));
 }
Пример #3
0
        public void MergeSort_Comparison(int[] input, int[] expected)
        {
            var actual = SortExtensions.MergeSort(input, (l, r) => r.CompareTo(l));

            Assert.Equal(expected, actual);
            Assert.Same(input, actual);
        }
Пример #4
0
        public void MergeSort_Comparer(int[] input, int[] expected)
        {
            var actual = SortExtensions.MergeSort(input, IntComparer);

            Assert.Equal(expected, actual);
            Assert.Same(input, actual);
        }
Пример #5
0
 public void PartialMergeSort_Preconditions()
 {
     Assert.Throws <ArgumentNullException>(
         () => SortExtensions.MergeSort((IList <int>)null, 0, 0));
     Assert.Throws <ArgumentOutOfRangeException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, -1, 1));
     Assert.Throws <ArgumentOutOfRangeException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 0, -1));
     Assert.Throws <ArgumentException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 2, 1));
     Assert.Throws <ArgumentException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 0, 3));
 }
Пример #6
0
 public void PartialMergeSort_Comparison_Preconditions()
 {
     Assert.Throws <ArgumentNullException>(
         () => SortExtensions.MergeSort(null, 0, 0, IntComparison));
     Assert.Throws <ArgumentNullException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 0, 1, (Comparison <int>)null));
     Assert.Throws <ArgumentOutOfRangeException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, -1, 1, IntComparison));
     Assert.Throws <ArgumentOutOfRangeException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 0, -1, IntComparison));
     Assert.Throws <ArgumentException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 2, 1, IntComparison));
     Assert.Throws <ArgumentException>(
         () => SortExtensions.MergeSort(new[] { 1, 2 }, 0, 3, IntComparison));
 }
Пример #7
0
 public void MergeSort_Preconditions()
 {
     Assert.Throws <ArgumentNullException>(
         () => SortExtensions.MergeSort((IList <int>)null));
 }