From da859d795f693fa42425ab5a9ce22d18211314d2 Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Fri, 9 Feb 2024 23:23:13 +0100 Subject: [PATCH] Test: Add more numbers to test in loop --- src/test/java/CalculationsTest.java | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/java/CalculationsTest.java b/src/test/java/CalculationsTest.java index f5b91aa..785d377 100644 --- a/src/test/java/CalculationsTest.java +++ b/src/test/java/CalculationsTest.java @@ -1,7 +1,6 @@ import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; + +import static org.junit.Assert.*; public class CalculationsTest { @@ -47,15 +46,16 @@ public class CalculationsTest { @Test public void testIsPrime() { // Prime - assertTrue(Calculations.isPrime(2)); - assertTrue(Calculations.isPrime(3)); - assertTrue(Calculations.isPrime(5)); - - // Non-Prime - assertFalse(Calculations.isPrime(22)); - assertFalse(Calculations.isPrime(25)); - assertFalse(Calculations.isPrime(27)); - assertFalse(Calculations.isPrime(30)); + int[] primeNumbers = {2, 3, 5, 7, 11, 13}; + int[] nonPrimeNumbers = {22, 33, 25, 4, 8, 14}; + + for(int i = 0; i < primeNumbers.length; i++) { + assertTrue(Calculations.isPrime(primeNumbers[i])); + } + + for(int i = 0; i < nonPrimeNumbers.length; i++) { + assertFalse(Calculations.isPrime(nonPrimeNumbers[i])); + } } }