|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- import org.junit.Test;
- import static org.junit.Assert.*;
-
- public class TriangleCheckerTest {
-
- @Test
- public void testValidTriangle() {
-
- // Arrange
- float a = 2;
- float b = 3;
- float c = 4;
-
- // Act
- TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NORMAL, type);
-
- // Arrange
- a = -2;
- b = 3;
- c = 4;
-
- // Act
- type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NONE, type);
-
- // Arrange
- a = 2;
- b = -3;
- c = 4;
-
- // Act
- type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NONE, type);
-
- // Arrange
- a = 2;
- b = 3;
- c = -4;
-
- // Act
- type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NONE, type);
-
- // Arrange
- a = 2;
- b = 3;
- c = 10;
-
- // Act
- type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NONE, type);
-
- // Arrange
- a = 10;
- b = 3;
- c = 4;
-
- // Act
- type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NONE, type);
-
- // Arrange
- a = 2;
- b = 10;
- c = 4;
-
- // Act
- type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.NONE, type);
- }
-
- @Test
- public void testIsoTriangle(){
- // Arrange
- float a = 3;
- float b = 3;
- float c = 2;
-
- // Act
- TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.ISOSCELES, type);
- }
-
- @Test
- public void testEqualTriangle(){
- // Arrange
- float a = 3;
- float b = 3;
- float c = 3;
-
- // Act
- TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
-
- // Assert
- assertEquals(TriangleChecker.TriangleType.EQUILATERAL, type);
- }
-
- }
|