forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoldbachConjectureTest.java
29 lines (26 loc) · 1.25 KB
/
GoldbachConjectureTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.thealgorithms.maths;
import static com.thealgorithms.maths.GoldbachConjecture.getPrimeSum;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class GoldbachConjectureTest {
@Test
void testValidEvenNumbers() {
assertEquals(new GoldbachConjecture.Result(3, 7), getPrimeSum(10)); // 10 = 3 + 7
assertEquals(new GoldbachConjecture.Result(5, 7), getPrimeSum(12)); // 12 = 5 + 7
assertEquals(new GoldbachConjecture.Result(3, 11), getPrimeSum(14)); // 14 = 3 + 11
assertEquals(new GoldbachConjecture.Result(5, 13), getPrimeSum(18)); // 18 = 5 + 13
}
@Test
void testInvalidOddNumbers() {
assertThrows(IllegalArgumentException.class, () -> getPrimeSum(7));
assertThrows(IllegalArgumentException.class, () -> getPrimeSum(15));
}
@Test
void testLesserThanTwo() {
assertThrows(IllegalArgumentException.class, () -> getPrimeSum(1));
assertThrows(IllegalArgumentException.class, () -> getPrimeSum(2));
assertThrows(IllegalArgumentException.class, () -> getPrimeSum(-5));
assertThrows(IllegalArgumentException.class, () -> getPrimeSum(-26));
}
}