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.

62 lines
1.4 KiB

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