-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from yanxiaodi/xy-fix-bubbleSorter
Fix the BubbleSorter and add the unit test.
- Loading branch information
Showing
2 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Algorithms.Sorting; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace UnitTest.AlgorithmsTests | ||
{ | ||
public static class BubbleSorterTest | ||
{ | ||
[Fact] | ||
public static void DoTest() | ||
{ | ||
var list = new List<int>() { 23, 42, 4, 16, 8, 15, 3, 9, 55, 0, 34, 12, 2, 46, 25 }; | ||
list.BubbleSort(); | ||
Assert.True(list.SequenceEqual(list.OrderBy(x => x)), "Wrong BubbleSort ascending"); | ||
|
||
list.BubbleSortDescending(Comparer<int>.Default); | ||
Assert.True(list.SequenceEqual(list.OrderByDescending(x => x)), "Wrong BubbleSort descending"); | ||
} | ||
} | ||
} |