Skip to content

Commit 828fcbb

Browse files
author
Lucas Lemaire
committed
Add CombSort unit tests
1 parent a625123 commit 828fcbb

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

AlgorithmsTests/AlgorithmsTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<Compile Include="Properties\AssemblyInfo.cs" />
5454
<Compile Include="Sorting\BubbleSorterTests.cs" />
5555
<Compile Include="Sorting\BucketSorterTests.cs" />
56+
<Compile Include="Sorting\CombSorterTests.cs" />
5657
<Compile Include="Sorting\ValuesProvider\ISortingValuesProvider.cs" />
5758
<Compile Include="Sorting\AllSortTests.cs" />
5859
<Compile Include="Sorting\ValuesProvider\SortingStringValuesProvider.cs" />
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

Comments
 (0)