Browse Source

Test: Add more numbers to test in loop

remotes/origin/test/client/add-test-cases
Alena Bandarovich 11 months ago
parent
commit
da859d795f
  1. 24
      src/test/java/CalculationsTest.java

24
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]));
}
}
}
Loading…
Cancel
Save