|
|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
package LernProgramm; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
@ -10,10 +9,19 @@ import java.io.PrintStream; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
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 |
|
|
|
void test() { |
|
|
|
assertTrue(true); |
|
|
|
} |
|
|
|
|
|
|
|
// PrimZahlen |
|
|
|
@Test |
|
|
|
public void testPrimBis100() { |
|
|
|
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()); |
|
|
|
} |
|
|
|
|
|
|
|
// Binärrechner |
|
|
|
@Test |
|
|
|
public void testAddition() { |
|
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '+'); |
|
|
|
assertEquals(10101, result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
@ -48,6 +56,7 @@ class testProgramm { |
|
|
|
assertTrue(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testDivision() { |
|
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '/'); |
|
|
@ -86,6 +95,7 @@ class testProgramm { |
|
|
|
assertEquals(1, result, 0); |
|
|
|
} |
|
|
|
|
|
|
|
// Fakultaet |
|
|
|
@Test |
|
|
|
public void testFakultaetWithPositiveNumber() { |
|
|
|
String input = "5\n"; |
|
|
@ -100,7 +110,6 @@ class testProgramm { |
|
|
|
assertEquals("120\n", out.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
public void testFakultaetWithZero() { |
|
|
|
String input = "0\n"; |
|
|
@ -113,7 +122,7 @@ class testProgramm { |
|
|
|
FunktionenAusgelagert.Fakultaet(); |
|
|
|
|
|
|
|
assertTrue(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Schaltjahr |
|
|
|
@Test |
|
|
@ -139,7 +148,6 @@ class testProgramm { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
public void testTimer() { |
|
|
|
int actualTime = (int) (Math.random() * 10 + 1); |
|
|
@ -153,16 +161,9 @@ class testProgramm { |
|
|
|
assertTrue(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
void testtest() { |
|
|
|
assertTrue(true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |