예제 #1
0
 public void InvalidInput()
 {
     Assert.Throws <ArgumentNullException>(() => InversePairsCount.GetCount(null));
     Assert.Equal(0, InversePairsCount.GetCount(new int[0]));
 }
예제 #2
0
 public void TestWithRandomArray()
 {
     int[] array = GenerateArray(5000);
     Assert.Equal(GetResultByBruteForce(array), InversePairsCount.GetCount(array));
 }
예제 #3
0
 public void TestWithSortedArray()
 {
     int[] array = GenerateArray(5000);
     Array.Sort(array);
     Assert.Equal(0, InversePairsCount.GetCount(array));
 }
예제 #4
0
 public void TestWithReverselySortedArray()
 {
     int[] array = GenerateArray(5000);
     Array.Sort(array, (int a, int b) => b - a);
     Assert.Equal(GetResultByBruteForce(array), InversePairsCount.GetCount(array));
 }
예제 #5
0
 public void ExampleOnBook()
 {
     Assert.Equal(5, InversePairsCount.GetCount(new[] { 7, 5, 6, 4 }));
 }