|
|
@@ -2,7 +2,7 @@ import org.junit.Test; |
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
public class TriangleCheckerTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
public void testValidTriangle() { |
|
|
|
|
|
|
@@ -10,12 +10,40 @@ public class TriangleCheckerTest { |
|
|
|
float a = 2; |
|
|
|
float b = 3; |
|
|
|
float c = 4; |
|
|
|
float d = 32; |
|
|
|
float e = 8; |
|
|
|
float f = 0; |
|
|
|
float g = 6; |
|
|
|
float h = 9; |
|
|
|
float i = 28; |
|
|
|
|
|
|
|
// Act |
|
|
|
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); |
|
|
|
TriangleChecker.TriangleType normal = TriangleChecker.TriangleType.NORMAL; |
|
|
|
TriangleChecker.TriangleType none = TriangleChecker.TriangleType.NONE; |
|
|
|
TriangleChecker.TriangleType isoceles = TriangleChecker.TriangleType.ISOSCELES; |
|
|
|
TriangleChecker.TriangleType equilateral = TriangleChecker.TriangleType.EQUILATERAL; |
|
|
|
|
|
|
|
assertTrue(TriangleChecker.checkTriangleShape(a, b, c)); |
|
|
|
assertFalse(TriangleChecker.checkTriangleShape(a, d, c)); |
|
|
|
assertFalse(TriangleChecker.checkTriangleShape(e, d, e)); |
|
|
|
assertFalse(TriangleChecker.checkTriangleShape(a, f, h)); |
|
|
|
assertFalse(TriangleChecker.checkTriangleShape(i, c, d)); |
|
|
|
assertTrue(TriangleChecker.checkTriangleShape(g, i, d)); |
|
|
|
|
|
|
|
// Assert |
|
|
|
assertEquals(TriangleChecker.TriangleType.NORMAL, type); |
|
|
|
assertEquals(normal, testTriangle(a, b, c)); |
|
|
|
assertEquals(none, testTriangle(a, b, d)); |
|
|
|
assertEquals(none, testTriangle(a, f, d)); |
|
|
|
assertEquals(none, testTriangle(f, f, d)); |
|
|
|
assertEquals(none, testTriangle(c, c, d)); |
|
|
|
assertEquals(equilateral, testTriangle(a, a, a)); |
|
|
|
assertEquals(isoceles, testTriangle(a, d, d)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public TriangleChecker.TriangleType testTriangle(float side1, float side2, float side3) { |
|
|
|
|
|
|
|
return TriangleChecker.checkTriangle(side1, side2, side3); |
|
|
|
|
|
|
|
} |
|
|
|
|