PlatztauschTest.java 1.51 KB
Newer Older
Younis's avatar
Younis committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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]
    }