From 4e32889224dc007d92eeb4ef57a505408a0143f2 Mon Sep 17 00:00:00 2001 From: Younis <nida.younis@hft-stuttgart.de> Date: Tue, 24 Sep 2024 12:47:46 +0000 Subject: [PATCH] Add new file PlatztauschTest --- PlatztauschTest.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 PlatztauschTest.java diff --git a/PlatztauschTest.java b/PlatztauschTest.java new file mode 100644 index 0000000..7be42b6 --- /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] + } -- GitLab