From 44d1dd85c2e9c000483c65ca9048735acb99cff0 Mon Sep 17 00:00:00 2001 From: 3024753 <3024753@stud.hs-mannheim.de> Date: Wed, 25 Mar 2026 16:39:21 +0100 Subject: [PATCH] =?UTF-8?q?JUnit=20Tesst=20f=C3=BCr=20InsertionSort=20wurd?= =?UTF-8?q?e=20geschrieben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PR2pvl/src/Bubblesort.java | 3 ++- PR2pvl/src/InsertionSortTest.java | 20 ++++++++++++++++++++ PR2pvl/src/bubbletest.java | 11 ++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 PR2pvl/src/InsertionSortTest.java diff --git a/PR2pvl/src/Bubblesort.java b/PR2pvl/src/Bubblesort.java index c81ffa5..9b14103 100644 --- a/PR2pvl/src/Bubblesort.java +++ b/PR2pvl/src/Bubblesort.java @@ -8,7 +8,7 @@ public class Bubblesort { } - public static void bubblesort(int[] arr) { + public static int[] bubblesort(int[] arr) { boolean ready = false; @@ -29,6 +29,7 @@ public class Bubblesort { System.out.println(Arrays.toString(arr)); } // while + return arr; } diff --git a/PR2pvl/src/InsertionSortTest.java b/PR2pvl/src/InsertionSortTest.java new file mode 100644 index 0000000..6b89a22 --- /dev/null +++ b/PR2pvl/src/InsertionSortTest.java @@ -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); + } + +} diff --git a/PR2pvl/src/bubbletest.java b/PR2pvl/src/bubbletest.java index 85002c5..967cfea 100644 --- a/PR2pvl/src/bubbletest.java +++ b/PR2pvl/src/bubbletest.java @@ -1,16 +1,17 @@ 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 - void test() { + public void test() { int arr[] = {3,2,5}; int fin[]= {2,3,5}; - - + + Assert.assertArrayEquals(Bubblesort.bubblesort(arr), fin); } }