Ejemplo n.º 1
0
 public void One()
 {
     int[] lst = new int[] {5};
     QuickSort<int> qs = new QuickSort<int>();
     qs.quicksort(lst, null);
     Assert.AreEqual(1, lst.Length);
 }
Ejemplo n.º 2
0
 public void Empty()
 {
     int[] lst = new int[0];
     QuickSort<int> qs = new QuickSort<int>();
     qs.quicksort(lst, null);
     Assert.AreEqual(0, lst.Length);
 }
Ejemplo n.º 3
0
 public void Rev()
 {
     int[] lst = new int[] { 2, 1, 3 };
     QuickSort<int>.TCmp cmpFwd = delegate(int a, int b) { return ((a < b) ? 1 : ((a > b) ? -1 : 0)); };
     QuickSort<int> qs = new QuickSort<int>();
     qs.quicksort(lst, cmpFwd);
     Assert.AreEqual(3, lst[0]);
     Assert.AreEqual(2, lst[1]);
     Assert.AreEqual(1, lst[2]);
 }
Ejemplo n.º 4
0
 public void Random()
 {
     int[] lst = new int[100];
     for (int i = 0; i < lst.Length; i++)
         lst[i] = (i + 25) % 100;
     QuickSort<int>.TCmp cmpFwd = delegate(int a, int b) { return ((a < b) ? -1 : ((a > b) ? 1 : 0)); };
     QuickSort<int> qs = new QuickSort<int>();
     qs.quicksort(lst, cmpFwd);
     for (int i = 0; i < lst.Length; i++)
         Assert.AreEqual(i, lst[i]);
 }