diff --git a/src/test/java/com/thealgorithms/maths/GCDTest.java b/src/test/java/com/thealgorithms/maths/GCDTest.java new file mode 100644 index 000000000000..3f4d9393465d --- /dev/null +++ b/src/test/java/com/thealgorithms/maths/GCDTest.java @@ -0,0 +1,41 @@ +package com.thealgorithms.maths; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class GCDTest { + @Test + void test1() { + Assertions.assertThrows(ArithmeticException.class, () -> GCD.gcd(-1,0)); + } + + @Test + void test2() { + Assertions.assertThrows(ArithmeticException.class, () -> GCD.gcd(10, -2)); + } + + @Test + void test3() { + Assertions.assertThrows(ArithmeticException.class, () -> GCD.gcd(-5, -3)); + } + + @Test + void test4() { + Assertions.assertEquals(GCD.gcd(0, 2), 2); + } + + @Test + void test5() { + Assertions.assertEquals(GCD.gcd(10, 0), 10); + } + + @Test + void test6() { + Assertions.assertEquals(GCD.gcd(1, 0), 1); + } + + @Test + void test7() { + Assertions.assertEquals(GCD.gcd(9, 6), 3); + } +} diff --git a/src/test/java/com/thealgorithms/maths/PrimeCheckTest.java b/src/test/java/com/thealgorithms/maths/PrimeCheckTest.java new file mode 100644 index 000000000000..59fe78525346 --- /dev/null +++ b/src/test/java/com/thealgorithms/maths/PrimeCheckTest.java @@ -0,0 +1,41 @@ +package com.thealgorithms.maths; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class PrimeCheckTest { + @Test + void test1() { + Assertions.assertTrue(PrimeCheck.isPrime(2)); + } + + @Test + void test2() { + Assertions.assertFalse(PrimeCheck.isPrime(-1)); + } + + @Test + void test3() { + Assertions.assertFalse(PrimeCheck.isPrime(4)); + } + + @Test + void test4() { + Assertions.assertTrue(PrimeCheck.isPrime(5)); + } + + @Test + void test5() { + Assertions.assertFalse(PrimeCheck.isPrime(15)); + } + + @Test + void test6() { + Assertions.assertTrue(PrimeCheck.isPrime(11)); + } + + @Test + void test7() { + Assertions.assertFalse(PrimeCheck.isPrime(49)); + } +}