|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using Algorithms.Sorting; |
| 4 | +using NUnit.Framework; |
| 5 | + |
| 6 | +namespace AlgorithmsTests.Sorting |
| 7 | +{ |
| 8 | + [TestFixture] |
| 9 | + public class CombSorterTests |
| 10 | + { |
| 11 | + [TestCase(new[] { 0, 2 }, new[] { 0, 2 })] |
| 12 | + [TestCase(new[] { 3, 2 }, new[] { 2, 3 })] |
| 13 | + [TestCase(new[] { 1, 9, 3, 7, 5, 2 }, new[] { 1, 2, 3, 5, 7, 9 })] |
| 14 | + [TestCase(new[] { 541, 87, 23, 87, 18, 687, 1587, 579, 25742, 5841, 2 }, new[] { 2, 18, 23, 87, 87, 541, 579, 687, 1587, 5841, 25742 })] |
| 15 | + public void CombSortTest(int[] toSortInts, int[] expectedSortedInts) |
| 16 | + { |
| 17 | + toSortInts.CombSort(); |
| 18 | + CollectionAssert.AreEqual(toSortInts, expectedSortedInts); |
| 19 | + } |
| 20 | + |
| 21 | + [TestCase(new[] { 0, 2 }, new[] { 0, 2 })] |
| 22 | + [TestCase(new[] { 3, 2 }, new[] { 2, 3 })] |
| 23 | + [TestCase(new[] { 1, 9, 3, 7, 5, 2 }, new[] { 1, 2, 3, 5, 7, 9 })] |
| 24 | + [TestCase(new[] { 541, 87, 23, 87, 18, 687, 1587, 579, 25742, 5841, 2 }, new[] { 2, 18, 23, 87, 87, 541, 579, 687, 1587, 5841, 25742 })] |
| 25 | + public void CombSortAscendingTest(int[] toSortInts, int[] expectedSortedInts) |
| 26 | + { |
| 27 | + toSortInts.CombSortAscending(Comparer<int>.Default); |
| 28 | + CollectionAssert.AreEqual(toSortInts, expectedSortedInts); |
| 29 | + } |
| 30 | + |
| 31 | + [TestCase(new[] { 0, 2 }, new[] { 2, 0 })] |
| 32 | + [TestCase(new[] { 3, 2 }, new[] { 3, 2 })] |
| 33 | + [TestCase(new[] { 1, 9, 3, 7, 5, 2 }, new[] { 9, 7, 5, 3, 2, 1 })] |
| 34 | + [TestCase(new[] { 541, 87, 23, 87, 18, 687, 1587, 579, 25742, 5841, 2 }, new[] { 25742, 5841, 1587, 687, 579, 541, 87, 87, 23, 18, 2 })] |
| 35 | + public void CombSortDescendingTest(int[] toSortInts, int[] expectedSortedInts) |
| 36 | + { |
| 37 | + toSortInts.CombSortDescending(Comparer<int>.Default); |
| 38 | + CollectionAssert.AreEqual(toSortInts, expectedSortedInts); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments