|
|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
package LernProgramm; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
@ -10,11 +9,20 @@ import java.io.PrintStream; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
class testProgramm { |
|
|
|
@Test |
|
|
|
|
|
|
|
// 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); |
|
|
|
} |
|
|
|
@Test |
|
|
|
|
|
|
|
// PrimZahlen |
|
|
|
@Test |
|
|
|
public void testPrimBis100() { |
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
System.setOut(new PrintStream(out)); |
|
|
@ -24,14 +32,14 @@ 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()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
// Binärrechner |
|
|
|
@Test |
|
|
|
public void testAddition() { |
|
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '+'); |
|
|
|
assertEquals(10101, result); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testSubtraction() { |
|
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '-'); |
|
|
|
result++; |
|
|
@ -40,7 +48,7 @@ class testProgramm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testMultiplication() { |
|
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '*'); |
|
|
|
result++; |
|
|
@ -48,7 +56,8 @@ class testProgramm { |
|
|
|
assertTrue(true); |
|
|
|
} |
|
|
|
} |
|
|
|
@Test |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testDivision() { |
|
|
|
int result = FunktionenAusgelagert.calculate("1010", "1011", '/'); |
|
|
|
assertEquals(0, result); |
|
|
@ -60,7 +69,7 @@ class testProgramm { |
|
|
|
assertEquals(0, result); |
|
|
|
} |
|
|
|
|
|
|
|
// Taschenrechner |
|
|
|
// Taschenrechner |
|
|
|
@Test |
|
|
|
public void testAddition1() { |
|
|
|
|
|
|
@ -74,7 +83,7 @@ class testProgramm { |
|
|
|
assertEquals(1.5, result, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testMultiplication1() { |
|
|
|
double result = 5 * 3.5; |
|
|
|
assertEquals(17.5, result, 0); |
|
|
@ -86,7 +95,8 @@ class testProgramm { |
|
|
|
assertEquals(1, result, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
// Fakultaet |
|
|
|
@Test |
|
|
|
public void testFakultaetWithPositiveNumber() { |
|
|
|
String input = "5\n"; |
|
|
|
ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); |
|
|
@ -100,8 +110,7 @@ class testProgramm { |
|
|
|
assertEquals("120\n", out.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testFakultaetWithZero() { |
|
|
|
String input = "0\n"; |
|
|
|
ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); |
|
|
@ -113,9 +122,9 @@ class testProgramm { |
|
|
|
FunktionenAusgelagert.Fakultaet(); |
|
|
|
|
|
|
|
assertTrue(true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Schaltjahr |
|
|
|
// Schaltjahr |
|
|
|
@Test |
|
|
|
public void testSchaltjahr() { |
|
|
|
ByteArrayInputStream in = new ByteArrayInputStream("2000\n".getBytes()); |
|
|
@ -128,7 +137,7 @@ class testProgramm { |
|
|
|
assertEquals("Welches Jahr möchtest du untersuchen?\nSchaltjahr!\n", out.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testNumber() { |
|
|
|
int expected = 0; |
|
|
|
int actual = getNumber(); |
|
|
@ -139,8 +148,7 @@ class testProgramm { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testTimer() { |
|
|
|
int actualTime = (int) (Math.random() * 10 + 1); |
|
|
|
int estimatedTime = (int) (Math.random() * 10 + 1); |
|
|
@ -153,16 +161,9 @@ class testProgramm { |
|
|
|
assertTrue(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
void testtest() { |
|
|
|
assertTrue(true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |