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.

100 lines
1.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package programmiermethoden_und_Werkzeuge;
  2. import static org.junit.Assert.*;
  3. import org.junit.Test;
  4. public class TaschenrechnerTest {
  5. @Test
  6. public void testAddition() {
  7. int a = 3;
  8. int b = 4;
  9. int ab = a + b;
  10. int result = Taschenrechner.addition(a,b);
  11. assertEquals(ab, result);
  12. }
  13. @Test
  14. public void testMultiplikation() {
  15. int a = 6;
  16. int b = 6;
  17. int ab = a * b;
  18. int result = Taschenrechner.multiplikation(a, b);
  19. assertEquals(ab, result);
  20. }
  21. @Test
  22. public void testDivision() {
  23. int a = 14;
  24. int b = 7;
  25. int ab = a / b;
  26. int result = Taschenrechner.division(a, b);
  27. assertEquals(ab, result);
  28. }
  29. @Test
  30. public void testPotenzieren() {
  31. int a = 2;
  32. int b = 3;
  33. int ab = (int)Math.pow(a, b);
  34. int result = Taschenrechner.potenzieren(a, b);
  35. assertEquals(ab, result);
  36. }
  37. @Test
  38. public void testKleinerAls() {
  39. int a = 9;
  40. int b = 6;
  41. boolean ab = a<b;
  42. boolean result = Taschenrechner.kleinerAls(a, b);
  43. assertEquals(ab, result);
  44. }
  45. @Test
  46. public void testGroeßerAls() {
  47. int a = 6;
  48. int b = 9;
  49. boolean ab = a>b;
  50. boolean result = Taschenrechner.groeßerAls(a, b);
  51. assertEquals(ab, result);
  52. }
  53. @Test
  54. public void testGleich() {
  55. int a = 5;
  56. int b = 5;
  57. boolean ab = a==b;
  58. boolean result = Taschenrechner.gleich(a, b);
  59. assertEquals(ab, result);
  60. }
  61. @Test
  62. public void testRandomIntegerNummer() {
  63. int a = 2;
  64. int b = 10;
  65. int r = (int) (Math.random() * (a + 1)) + b;
  66. boolean result = r > a && r >= b;
  67. assertEquals(true, result);
  68. }
  69. @SuppressWarnings("deprecation")
  70. @Test
  71. public void testKreisUmfang() {
  72. int r = 3;
  73. double u = 2* r *Math.PI;
  74. double result = Taschenrechner.kreisUmfang(r);
  75. assertEquals(u, result);
  76. }
  77. }