mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-06 17:29:31 +08:00
Fix empty input handling in GCD (#4199)
This commit is contained in:
@ -48,4 +48,19 @@ public class GCDTest {
|
||||
void test7() {
|
||||
Assertions.assertEquals(GCD.gcd(9, 6), 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArrayGcd1() {
|
||||
Assertions.assertEquals(GCD.gcd(new int[]{9, 6}), 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArrayGcd2() {
|
||||
Assertions.assertEquals(GCD.gcd(new int[]{2*3*5*7, 2*5*5*5, 2*5*11, 5*5*5*13}), 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArrayGcdForEmptyInput() {
|
||||
Assertions.assertEquals(GCD.gcd(new int[]{}), 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user