BAEL-3115
- GCD implementation methods using Brute force, Euclid's Algo and Stein's Algo
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.algorithms.gcd;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class GCDImplementationUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalculatingGCDByBruteForceMethod_thenCorrect() {
|
||||
int n1 = 60;
|
||||
int n2 = 90;
|
||||
int gcd = GCDImplementation.gcdByBruteForce(n1, n2);
|
||||
assertThat(gcd).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCalculatingGCDByEuclidsAlgorithm_thenCorrect() {
|
||||
int n1 = 60;
|
||||
int n2 = 90;
|
||||
int gcd = GCDImplementation.gcdByEuclidsAlgorithm(n1, n2);
|
||||
assertThat(gcd).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCalculatingGCDBySteinsAlgorithm_thenCorrect() {
|
||||
int n1 = 60;
|
||||
int n2 = 90;
|
||||
int gcd = GCDImplementation.gcdBySteinsAlgorithm(n1, n2);
|
||||
assertThat(gcd).isEqualTo(30);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user