|
@ -1,7 +1,6 @@ |
|
|
import org.junit.Test; |
|
|
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 { |
|
|
public class CalculationsTest { |
|
|
|
|
|
|
|
@ -47,15 +46,16 @@ public class CalculationsTest { |
|
|
@Test |
|
|
@Test |
|
|
public void testIsPrime() { |
|
|
public void testIsPrime() { |
|
|
// Prime |
|
|
// 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])); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|