Commit 02470908 authored by Torstein's avatar Torstein

Fixet feil med testcaser som gjorde at quicksort fremstod som langsom.

parent 1f42cdcb
...@@ -11,7 +11,7 @@ import inf101v16f12.recursion.Sorting; ...@@ -11,7 +11,7 @@ import inf101v16f12.recursion.Sorting;
public class TestSorting { public class TestSorting {
public static final int TESTS = 5; public static final int TESTS = 5;
public static final int LISTLEN = 750*2; public static final int LISTLEN = 10000*2;
private static final Random r = new Random(); private static final Random r = new Random();
@Test @Test
...@@ -54,9 +54,9 @@ public class TestSorting { ...@@ -54,9 +54,9 @@ public class TestSorting {
int[] lst = new int[LISTLEN]; int[] lst = new int[LISTLEN];
for (int j=0; j<LISTLEN; j++) { for (int j=0; j<LISTLEN; j++) {
lst[j] = r.nextInt(LISTLEN) - (LISTLEN/2); lst[j] = r.nextInt(LISTLEN) - (LISTLEN/2);
Sorting.mergeSort(lst);
assertTrue(isSorted(lst));
} }
Sorting.mergeSort(lst);
assertTrue(isSorted(lst));
} }
} }
...@@ -66,9 +66,9 @@ public class TestSorting { ...@@ -66,9 +66,9 @@ public class TestSorting {
int[] lst = new int[LISTLEN]; int[] lst = new int[LISTLEN];
for (int j=0; j<LISTLEN; j++) { for (int j=0; j<LISTLEN; j++) {
lst[j] = r.nextInt(LISTLEN) - (LISTLEN/2); lst[j] = r.nextInt(LISTLEN) - (LISTLEN/2);
Sorting.quickSort(lst);
assertTrue(isSorted(lst));
} }
Sorting.quickSort(lst);
assertTrue(isSorted(lst));
} }
} }
...@@ -78,9 +78,9 @@ public class TestSorting { ...@@ -78,9 +78,9 @@ public class TestSorting {
int[] lst = new int[LISTLEN]; int[] lst = new int[LISTLEN];
for (int j=0; j<LISTLEN; j++) { for (int j=0; j<LISTLEN; j++) {
lst[j] = r.nextInt(LISTLEN) - (LISTLEN/2); lst[j] = r.nextInt(LISTLEN) - (LISTLEN/2);
Sorting.selectionSort(lst);
assertTrue(isSorted(lst));
} }
Sorting.selectionSort(lst);
assertTrue(isSorted(lst));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment