-> Test jetzt für alle Fälle positivmaster
// Analyse der Dreiecksart | // Analyse der Dreiecksart | ||||
public static TriangleType checkTriangle(float a, float b, float c) { | public static TriangleType checkTriangle(float a, float b, float c) { | ||||
if (a+b>c || b+c>a || a+c>b) { | |||||
if ((a+b>c || b+c>a || a+c>b) && (a>0 && b>0 && c>0)) { | |||||
if (a==b && b==c) { | if (a==b && b==c) { | ||||
return TriangleType.EQUILATERAL; | return TriangleType.EQUILATERAL; |
public void testValidTriangle() { | public void testValidTriangle() { | ||||
// Arrange | // Arrange | ||||
float a = 2; | |||||
float b = 2; | |||||
float a = 0; | |||||
float b = 0; | |||||
float c = 2; | float c = 2; | ||||
// Act | // Act | ||||
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); | TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c); | ||||
// Assert | // Assert | ||||
assertEquals(TriangleChecker.TriangleType.EQUILATERAL, type); | |||||
assertEquals(TriangleChecker.TriangleType.NONE, type); | |||||
} | } | ||||