From 7b9dc7ea4035e46d8bbdbeab8531266ae0932a41 Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Fri, 9 Feb 2024 23:03:32 +0100 Subject: [PATCH] Test: Check method for wrong and negative entries --- src/test/java/CalculationsTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/CalculationsTest.java b/src/test/java/CalculationsTest.java index 634a972..1073c19 100644 --- a/src/test/java/CalculationsTest.java +++ b/src/test/java/CalculationsTest.java @@ -35,5 +35,11 @@ public class CalculationsTest { // Test with large number assertEquals(3628800, fact.calculateFactorial(10)); } + + @Test(expected = IllegalArgumentException.class) + public void testNegativeNumber() { + Calculations fact = new Calculations(); + fact.calculateFactorial(-5); // Should throw IllegalArgumentException + } }