diff options
Diffstat (limited to 'src/test/java/de')
| -rw-r--r-- | src/test/java/de/hysky/skyblocker/utils/CalculatorTest.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/java/de/hysky/skyblocker/utils/CalculatorTest.java b/src/test/java/de/hysky/skyblocker/utils/CalculatorTest.java index 22187004..f269585d 100644 --- a/src/test/java/de/hysky/skyblocker/utils/CalculatorTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/CalculatorTest.java @@ -18,6 +18,17 @@ public class CalculatorTest { assertCalculation(9, "5 + 2 * 2"); assertCalculation(4, "5 - 2 / 2"); assertCalculation(15, "5 * (1 + 2)"); + assertCalculation(48, "3*4^2"); + assertCalculation(35, "3^3+(2^3)"); + } + + @Test + void testInvalids() { + assertThrows("5+asdf"); + assertThrows("5++3"); + assertThrows("2^"); + assertThrows("^"); + assertThrows("9 + 3* (0) )"); } @Test @@ -39,4 +50,8 @@ public class CalculatorTest { private void assertCalculation(double expected, String input) { Assertions.assertEquals(expected, Calculator.calculate(input)); } + + private void assertThrows(String input) { + Assertions.assertThrows(UnsupportedOperationException.class, () -> Calculator.calculate(input)); + } } |
