mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-06 17:29:31 +08:00
Add tests for GCD and PrimeCheck (#3062)
This commit is contained in:
41
src/test/java/com/thealgorithms/maths/GCDTest.java
Normal file
41
src/test/java/com/thealgorithms/maths/GCDTest.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user