Praktikum 4
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.

TriangleCheckerTest.java 2.3KB

2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import org.junit.Test;
  2. import static org.junit.Assert.*;
  3. public class TriangleCheckerTest {
  4. @Test
  5. public void testValidTriangle() {
  6. // Arrange
  7. float a = 2;
  8. float b = 3;
  9. float c = 4;
  10. // Act
  11. TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
  12. // Assert
  13. assertEquals(TriangleChecker.TriangleType.NORMAL, type);
  14. // Arrange
  15. a = -2;
  16. b = 3;
  17. c = 4;
  18. // Act
  19. type = TriangleChecker.checkTriangle(a, b, c);
  20. // Assert
  21. assertEquals(TriangleChecker.TriangleType.NONE, type);
  22. // Arrange
  23. a = 2;
  24. b = -3;
  25. c = 4;
  26. // Act
  27. type = TriangleChecker.checkTriangle(a, b, c);
  28. // Assert
  29. assertEquals(TriangleChecker.TriangleType.NONE, type);
  30. // Arrange
  31. a = 2;
  32. b = 3;
  33. c = -4;
  34. // Act
  35. type = TriangleChecker.checkTriangle(a, b, c);
  36. // Assert
  37. assertEquals(TriangleChecker.TriangleType.NONE, type);
  38. // Arrange
  39. a = 2;
  40. b = 3;
  41. c = 10;
  42. // Act
  43. type = TriangleChecker.checkTriangle(a, b, c);
  44. // Assert
  45. assertEquals(TriangleChecker.TriangleType.NONE, type);
  46. // Arrange
  47. a = 10;
  48. b = 3;
  49. c = 4;
  50. // Act
  51. type = TriangleChecker.checkTriangle(a, b, c);
  52. // Assert
  53. assertEquals(TriangleChecker.TriangleType.NONE, type);
  54. // Arrange
  55. a = 2;
  56. b = 10;
  57. c = 4;
  58. // Act
  59. type = TriangleChecker.checkTriangle(a, b, c);
  60. // Assert
  61. assertEquals(TriangleChecker.TriangleType.NONE, type);
  62. }
  63. @Test
  64. public void testIsoTriangle(){
  65. // Arrange
  66. float a = 3;
  67. float b = 3;
  68. float c = 2;
  69. // Act
  70. TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
  71. // Assert
  72. assertEquals(TriangleChecker.TriangleType.ISOSCELES, type);
  73. }
  74. @Test
  75. public void testEqualTriangle(){
  76. // Arrange
  77. float a = 3;
  78. float b = 3;
  79. float c = 3;
  80. // Act
  81. TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
  82. // Assert
  83. assertEquals(TriangleChecker.TriangleType.EQUILATERAL, type);
  84. }
  85. }