|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
|
package LernProgramm; |
|
|
package LernProgramm; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
@ -10,10 +9,19 @@ import java.io.PrintStream; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
class testProgramm { |
|
|
class testProgramm { |
|
|
|
|
|
|
|
|
|
|
|
// Hier werden die Tests gemacht |
|
|
|
|
|
// der erste prüft eingach nur, ob tests im allgemeinen möglich sind! |
|
|
|
|
|
// Die annderen testen die Funktionenn in der ausgelagerten Klasse zur besseren |
|
|
|
|
|
// Übersicht |
|
|
|
|
|
|
|
|
|
|
|
// Testest |
|
|
@Test |
|
|
@Test |
|
|
void test() { |
|
|
void test() { |
|
|
assertTrue(true); |
|
|
assertTrue(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// PrimZahlen |
|
|
@Test |
|
|
@Test |
|
|
public void testPrimBis100() { |
|
|
public void testPrimBis100() { |
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
@ -24,11 +32,11 @@ class testProgramm { |
|
|
assertEquals("2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 ", out.toString()); |
|
|
assertEquals("2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 ", out.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Binärrechner |
|
|
@Test |
|
|
@Test |
|
|
public void testAddition() { |
|
|
public void testAddition() { |
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '+'); |
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '+'); |
|
|
assertEquals(10101, result); |
|
|
assertEquals(10101, result); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
@ -48,6 +56,7 @@ class testProgramm { |
|
|
assertTrue(true); |
|
|
assertTrue(true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testDivision() { |
|
|
public void testDivision() { |
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '/'); |
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '/'); |
|
@ -86,6 +95,7 @@ class testProgramm { |
|
|
assertEquals(1, result, 0); |
|
|
assertEquals(1, result, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Fakultaet |
|
|
@Test |
|
|
@Test |
|
|
public void testFakultaetWithPositiveNumber() { |
|
|
public void testFakultaetWithPositiveNumber() { |
|
|
String input = "5\n"; |
|
|
String input = "5\n"; |
|
@ -100,7 +110,6 @@ class testProgramm { |
|
|
assertEquals("120\n", out.toString()); |
|
|
assertEquals("120\n", out.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testFakultaetWithZero() { |
|
|
public void testFakultaetWithZero() { |
|
|
String input = "0\n"; |
|
|
String input = "0\n"; |
|
@ -113,7 +122,7 @@ class testProgramm { |
|
|
FunktionenAusgelagert.Fakultaet(); |
|
|
FunktionenAusgelagert.Fakultaet(); |
|
|
|
|
|
|
|
|
assertTrue(true); |
|
|
assertTrue(true); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Schaltjahr |
|
|
// Schaltjahr |
|
|
@Test |
|
|
@Test |
|
@ -139,7 +148,6 @@ class testProgramm { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testTimer() { |
|
|
public void testTimer() { |
|
|
int actualTime = (int) (Math.random() * 10 + 1); |
|
|
int actualTime = (int) (Math.random() * 10 + 1); |
|
@ -153,16 +161,9 @@ class testProgramm { |
|
|
assertTrue(result); |
|
|
assertTrue(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void testtest() { |
|
|
void testtest() { |
|
|
assertTrue(true); |
|
|
assertTrue(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |