diff --git a/PlatztauschTest.java b/PlatztauschTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7be42b60a8b91ce38f7dbc8377b12d6bfa7155e9 --- /dev/null +++ b/PlatztauschTest.java @@ -0,0 +1,42 @@ +public class PlatztauschTest { + + public static void main(String[] args) { + testBasicArrayReversal(); + testEmptyArray(); + testSingleElementArray(); + testEvenNumberOfElements(); + testOddNumberOfElements(); + testArrayWithNegativeNumbers(); + } + + public static void testBasicArrayReversal() { + int[] array = {1, 2, 3, 4, 5}; + System.out.println("Test Basic Array Reversal:"); + Platztausch.ausgeben(array); // Expected Output: [1, 2, 3, 4, 5] + Platztausch.umdrehen(array); + Platztausch.ausgeben(array); // Expected Output: [5, 4, 3, 2, 1] + } + + public static void testEmptyArray() { + int[] array = {}; + System.out.println("Test Empty Array:"); + Platztausch.ausgeben(array); // Expected Output: [] + Platztausch.umdrehen(array); + Platztausch.ausgeben(array); // Expected Output: [] + } + + public static void testSingleElementArray() { + int[] array = {42}; + System.out.println("Test Single Element Array:"); + Platztausch.ausgeben(array); // Expected Output: [42] + Platztausch.umdrehen(array); + Platztausch.ausgeben(array); // Expected Output: [42] + } + + public static void testEvenNumberOfElements() { + int[] array = {1, 2, 3, 4}; + System.out.println("Test Even Number of Elements:"); + Platztausch.ausgeben(array); // Expected Output: [1, 2, 3, 4] + Platztausch.umdrehen(array); + Platztausch.ausgeben(array); // Expected Output: [4, 3, 2, 1] + }