diff options
author | Sven Göthel <[email protected]> | 2024-10-13 03:12:42 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-10-13 03:36:06 +0200 |
commit | c818f4449257555375fb247a02e0e85c0404e2d5 (patch) | |
tree | b45f017a1fc44a98d712f6a1cac1365a47db0473 /src | |
parent | 97f71068ddfa4f4175b1fd35cf7230f7ede38c0d (diff) |
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/jau/test/Test0104Java01.java | 91 | ||||
-rw-r--r-- | src/test/java/jau/test/Test0104Java01Aufgabe01b.java | 2 |
2 files changed, 47 insertions, 46 deletions
diff --git a/src/test/java/jau/test/Test0104Java01.java b/src/test/java/jau/test/Test0104Java01.java index 5c94980..0439c63 100644 --- a/src/test/java/jau/test/Test0104Java01.java +++ b/src/test/java/jau/test/Test0104Java01.java @@ -265,7 +265,7 @@ public class Test0104Java01 { * Unary-Operatoren (1 Argument) anhand des primitiven Datentyps `int` */ @Test - void test03_1_3_b_unary_post_prefix() { + void test03_1_2_b_unary_post_prefix() { { int i = 1; int j = 1; @@ -344,7 +344,7 @@ public class Test0104Java01 { * Zuweisungs-Operatoren inklusive der 4 Grundrechenarten anhand des primitiven Datentyps `int` */ @Test - void test03_1_3_c_zuweisung() { + void test03_1_2_c_zuweisung() { // Einfache Zuweisung { int i = 6; @@ -395,7 +395,7 @@ public class Test0104Java01 { * Operatoren der logischen Vergleiche anhand des primitiven Datentyps `int` */ @Test - void test03_1_3_d_vergleich() { + void test03_1_2_d_vergleich() { // Gleichheit (equality) { final int i = 8; @@ -428,7 +428,7 @@ public class Test0104Java01 { * Operatoren der logischen Verknuepfung anhand des primitiven Datentyps `int` und `boolean` */ @Test - void test03_1_3_e_logisch() { + void test03_1_2_e_logisch() { // Logisch-Und (and) als auch Logisch-Oder (or) { final int i = 8; @@ -474,7 +474,7 @@ public class Test0104Java01 { * Primitive data types incl. under- and overflow. */ @Test - void test03_1_4_primitive_underoverflow() { + void test03_1_3_primitive_underoverflow() { // trigger (ausloesung) short over- and underflow: no practical use-case { final short one = 1; @@ -531,6 +531,42 @@ public class Test0104Java01 { } /** + * Primitive Datentypen und Literale (Konstante) + */ + @Test + void test03_1_4_immutable() { + // Unveraenderbare (Immutable) Variablen, i.e. Konstante + final int const_i0 = 1; + // const_i0 = const_i0 + 1; // FEHLER + Assertions.assertEquals(1, const_i0); + } + + int instanz_var = 0; + + int erhoeheUm(final int a) { + instanz_var += a; + return instanz_var; + } + + @Test + void test03_2_1_method_instanz() { + instanz_var = 0; + Assertions.assertEquals(2, erhoeheUm(2)); + Assertions.assertEquals(2, instanz_var); + Assertions.assertEquals(5, erhoeheUm(3)); + Assertions.assertEquals(5, instanz_var); + } + + static int addiere(final int a, final int b) { + return a+b; + } + + @Test + void test03_2_2_method_static() { + Assertions.assertEquals(5, addiere(2, 3)); + } + + /** * Manual definition */ public static class Test03A implements Comparable<Test03A> { @@ -625,7 +661,7 @@ public class Test0104Java01 { } @Test - void test03_2_a_class() { + void test03_2_3a_class() { // 0: Analog to instances of primitive types, class instances are shown below this block { // i1 (locale variable) ist der Name fuer den Speicherbereich der Groesse 'int' @@ -774,7 +810,7 @@ public class Test0104Java01 { } @Test - void test03_2_4_class_no_destructor() { + void test03_2_3b_class_no_destructor() { // Lebenszyklus (Lifecycle / Object-Duration) // // AutoClosable interface helps to remedy lack of destructor @@ -827,26 +863,16 @@ public class Test0104Java01 { } } - /** - * Primitive Datentypen und Literale (Konstante) - */ - @Test - void test03_3_immutable() { - // Unveraenderbare (Immutable) Variablen, i.e. Konstante - final int const_i0 = 1; - // const_i0 = const_i0 + 1; // FEHLER - Assertions.assertEquals(1, const_i0); - } - // 3.3 Speicher-Klassen von Variablen - // 3.3.3 Klassen Instanz Variable (Field) - int lili = 0; // 3.3.2 Globale (Klassen) Variablen static int lala = 0; // Konstante .. 3.3.2 Globale (Klassen) Variablen (immutable) static final int lulu = 0; + // 3.3.3 Klassen Instanz Variable (Field) + int lili = 0; + /** * 3.3 Speicher-Klassen von Variablen */ @@ -1245,31 +1271,6 @@ public class Test0104Java01 { } } - static int addiere(final int a, final int b) { - return a+b; - } - - @Test - void test30_method_static() { - Assertions.assertEquals(5, addiere(2, 3)); - } - - int instanz_var = 0; - - int erhoeheUm(final int a) { - instanz_var += a; - return instanz_var; - } - - @Test - void test31_method_instanz() { - instanz_var = 0; - Assertions.assertEquals(2, erhoeheUm(2)); - Assertions.assertEquals(2, instanz_var); - Assertions.assertEquals(5, erhoeheUm(3)); - Assertions.assertEquals(5, instanz_var); - } - public static void main(final String[] args) { SimpleJunit5Launcher.runTests(Test0104Java01.class); } diff --git a/src/test/java/jau/test/Test0104Java01Aufgabe01b.java b/src/test/java/jau/test/Test0104Java01Aufgabe01b.java index 730479f..6e0a74c 100644 --- a/src/test/java/jau/test/Test0104Java01Aufgabe01b.java +++ b/src/test/java/jau/test/Test0104Java01Aufgabe01b.java @@ -217,7 +217,7 @@ class Test0104Java01Aufgabe01b { /** * 3.3.2 (Static) Globale (Klassen) immutable Variablen, welche mit dem rueckgabewert der static (globalen) methode calcEpsilon32() initialisiert wird. - * @see {@link Test0104Java01#test03_3_storage_class()} + * @see {@link Test0104Java01#test03_4_storage_class()} */ static final float Epsilon32 = calcEpsilon32(); |