|
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
|
public class TriangleCheckerTest { |
|
|
public class TriangleCheckerTest { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Arrange |
|
|
|
|
|
float a = 2; |
|
|
|
|
|
float b = 3; |
|
|
|
|
|
float c = 4; |
|
|
|
|
|
float d = - a; |
|
|
|
|
|
|
|
|
|
|
|
TriangleChecker.TriangleType none = TriangleChecker.TriangleType.NONE; |
|
|
|
|
|
TriangleChecker.TriangleType normal = TriangleChecker.TriangleType.NORMAL; |
|
|
|
|
|
TriangleChecker.TriangleType isosceles = TriangleChecker.TriangleType.ISOSCELES; // Gleichschenklig |
|
|
|
|
|
TriangleChecker.TriangleType equilateral = TriangleChecker.TriangleType.EQUILATERAL; // Gleichseitig |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testValidTriangle() { |
|
|
public void testValidTriangle() { |
|
|
|
|
|
|
|
|
// Arrange |
|
|
|
|
|
float a = 2; |
|
|
|
|
|
float b = 3; |
|
|
|
|
|
float c = 4; |
|
|
|
|
|
|
|
|
assertTrue(TriangleChecker.checkTrianglePossible(a,b,c)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(0,0,0)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(0,b,c)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(a,0,c)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(a,b,0)); |
|
|
|
|
|
|
|
|
|
|
|
//combination of falses |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(d,c,c)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(0,0,c)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(d,d,d)); |
|
|
|
|
|
assertFalse(TriangleChecker.checkTrianglePossible(a,b,0)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Act |
|
|
|
|
|
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); |
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void testTriangleType(){ |
|
|
|
|
|
|
|
|
// Assert |
|
|
|
|
|
assertEquals(TriangleChecker.TriangleType.NORMAL, type); |
|
|
|
|
|
|
|
|
assertEquals(none, TriangleChecker.checkTriangle(a, b, 400)); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
assertEquals(normal, TriangleChecker.checkTriangle(a, b, c)); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(isosceles, TriangleChecker.checkTriangle(a, b, b)); |
|
|
|
|
|
assertEquals(isosceles, TriangleChecker.checkTriangle(a, a, c/3)); |
|
|
|
|
|
assertEquals(isosceles, TriangleChecker.checkTriangle(c, b, c)); |
|
|
|
|
|
assertNotEquals(isosceles, TriangleChecker.checkTriangle(a, b, c)); |
|
|
|
|
|
assertNotEquals(isosceles, TriangleChecker.checkTriangle(a, a, a)); |
|
|
|
|
|
|
|
|
|
|
|
assertNotEquals(equilateral, TriangleChecker.checkTriangle(b, a, a)); |
|
|
|
|
|
assertEquals(equilateral, TriangleChecker.checkTriangle(a, a, a)); |
|
|
|
|
|
assertNotEquals(equilateral, TriangleChecker.checkTriangle(a, b, a)); |
|
|
|
|
|
assertNotEquals(equilateral, TriangleChecker.checkTriangle(a, a, b)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |