Skip to content

[TEST] Add tests for GCD algorithm based on MC/DC standard and PrimeCheck algorithm based on All-DU-Paths standard #3062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/test/java/com/thealgorithms/maths/GCDTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
41 changes: 41 additions & 0 deletions src/test/java/com/thealgorithms/maths/PrimeCheckTest.java
Original file line number Diff line number Diff line change
@@ -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));
}
}