JUnit Tesst für InsertionSort wurde geschrieben

main
Tim Anacker 2026-03-25 16:39:21 +01:00
parent 0a74c20f07
commit 44d1dd85c2
3 changed files with 28 additions and 6 deletions

View File

@ -8,7 +8,7 @@ public class Bubblesort {
} }
public static void bubblesort(int[] arr) { public static int[] bubblesort(int[] arr) {
boolean ready = false; boolean ready = false;
@ -29,6 +29,7 @@ public class Bubblesort {
System.out.println(Arrays.toString(arr)); System.out.println(Arrays.toString(arr));
} // while } // while
return arr;
} }

View File

@ -0,0 +1,20 @@
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Assert;
import org.junit.Test;
public class InsertionSortTest {
@Test
public void test() {
int[] arr = {9, 7, 6, 5, 4, 2, 1, 0};
int[] fin = {0, 1, 2, 4, 5, 6, 7, 9};
Assert.assertArrayEquals(InsertionSort.insertionSort(arr), fin);
Assert.assertArrayEquals(InsertionSort.insertionSortLSG(arr), fin);
}
}

View File

@ -1,16 +1,17 @@
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.Assert;
import org.junit.Test;
class bubbletest { public class bubbletest {
@Test @Test
void test() { public void test() {
int arr[] = {3,2,5}; int arr[] = {3,2,5};
int fin[]= {2,3,5}; int fin[]= {2,3,5};
Assert.assertArrayEquals(Bubblesort.bubblesort(arr), fin);
} }
} }