You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.3 KiB

2 years ago
2 years ago
  1. package LernProgramm;
  2. import static org.junit.jupiter.api.Assertions.*;
  3. import java.io.ByteArrayInputStream;
  4. import java.io.ByteArrayOutputStream;
  5. import java.io.PrintStream;
  6. import org.junit.jupiter.api.Test;
  7. class testProgramm {
  8. @Test
  9. void test() {
  10. assertTrue(true);
  11. }
  12. @Test
  13. public void testPrimBis100() {
  14. ByteArrayOutputStream out = new ByteArrayOutputStream();
  15. System.setOut(new PrintStream(out));
  16. FunktionenAusgelagert.PrimBis100();
  17. 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());
  18. }
  19. @Test
  20. public void testAddition() {
  21. int result = FunktionenAusgelagert.calculate("1010", "1011", '+');
  22. assertEquals(10101, result);
  23. }
  24. @Test
  25. public void testSubtraction() {
  26. int result = FunktionenAusgelagert.calculate("1010", "1011", '-');
  27. result++;
  28. if (result < 0 || result > 0) {
  29. assertTrue(true);
  30. }
  31. }
  32. @Test
  33. public void testMultiplication() {
  34. int result = FunktionenAusgelagert.calculate("1010", "1011", '*');
  35. result++;
  36. if (result < 0 || result > 0) {
  37. assertTrue(true);
  38. }
  39. }
  40. @Test
  41. public void testDivision() {
  42. int result = FunktionenAusgelagert.calculate("1010", "1011", '/');
  43. assertEquals(0, result);
  44. }
  45. @Test
  46. public void testInvalidOperation() {
  47. int result = FunktionenAusgelagert.calculate("1010", "1011", '%');
  48. assertEquals(0, result);
  49. }
  50. }