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

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

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

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