|
|
@@ -2,7 +2,7 @@ import org.junit.Test; |
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
public class TriangleCheckerTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
public void testValidTriangle() { |
|
|
|
|
|
|
@@ -19,4 +19,71 @@ public class TriangleCheckerTest { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testUnvalidTriangle() { |
|
|
|
|
|
|
|
// Arrange |
|
|
|
float a = 1; |
|
|
|
float b = 1; |
|
|
|
float c = 100; |
|
|
|
|
|
|
|
// Act |
|
|
|
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); |
|
|
|
|
|
|
|
// Assert |
|
|
|
assertEquals(TriangleChecker.TriangleType.NONE, type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testNegativeTriangle() { |
|
|
|
|
|
|
|
// Arrange |
|
|
|
float a = -2; |
|
|
|
float b = 2; |
|
|
|
float c = 3; |
|
|
|
|
|
|
|
// Act |
|
|
|
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); |
|
|
|
|
|
|
|
// Assert |
|
|
|
assertEquals(TriangleChecker.TriangleType.NONE, type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testEquilateralTriangle() { |
|
|
|
|
|
|
|
// Arrange |
|
|
|
float a = 2; |
|
|
|
float b = 2; |
|
|
|
float c = 2; |
|
|
|
|
|
|
|
// Act |
|
|
|
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); |
|
|
|
|
|
|
|
// Assert |
|
|
|
assertEquals(TriangleChecker.TriangleType.EQUILATERAL, type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testIsoscelesTriangle() { |
|
|
|
|
|
|
|
// Arrange |
|
|
|
float a = 3; |
|
|
|
float b = 3; |
|
|
|
float c = 4; |
|
|
|
|
|
|
|
// Act |
|
|
|
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); |
|
|
|
|
|
|
|
// Assert |
|
|
|
assertEquals(TriangleChecker.TriangleType.ISOSCELES, type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |