-
Notifications
You must be signed in to change notification settings - Fork 19.4k
/
NewManShanksPrimeTest.java
80 lines (71 loc) · 2.35 KB
/
NewManShanksPrimeTest.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.thealgorithms.dynamicprogramming;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Unit tests for the NewManShanksPrime class.
* This test class verifies the correctness of the nthManShanksPrime method
* for various input cases.
*/
class NewManShanksPrimeTest {
/**
* Test case for the 1st New Man Shanks prime.
* The expected answer is 1.
*/
@Test
void testNthManShanksPrime1() {
int n = 1;
int expectedAnswer = 1;
assertTrue(NewManShanksPrime.nthManShanksPrime(n, expectedAnswer), "The 1st New Man Shanks prime should be 1.");
}
/**
* Test case for the 2nd New Man Shanks prime.
* The expected answer is 3.
*/
@Test
void testNthManShanksPrime2() {
int n = 2;
int expectedAnswer = 3;
assertTrue(NewManShanksPrime.nthManShanksPrime(n, expectedAnswer), "The 2nd New Man Shanks prime should be 3.");
}
/**
* Test case for the 3rd New Man Shanks prime.
* The expected answer is 7.
*/
@Test
void testNthManShanksPrime3() {
int n = 3;
int expectedAnswer = 7;
assertTrue(NewManShanksPrime.nthManShanksPrime(n, expectedAnswer), "The 3rd New Man Shanks prime should be 7.");
}
/**
* Test case for the 4th New Man Shanks prime.
* The expected answer is 17.
*/
@Test
void testNthManShanksPrime4() {
int n = 4;
int expectedAnswer = 17;
assertTrue(NewManShanksPrime.nthManShanksPrime(n, expectedAnswer), "The 4th New Man Shanks prime should be 17.");
}
/**
* Test case for the 5th New Man Shanks prime.
* The expected answer is 41.
*/
@Test
void testNthManShanksPrime5() {
int n = 5;
int expectedAnswer = 41;
assertTrue(NewManShanksPrime.nthManShanksPrime(n, expectedAnswer), "The 5th New Man Shanks prime should be 41.");
}
/**
* Test case with an incorrect expected answer.
* For n = 2, the expected answer is 3.
*/
@Test
void testNthManShanksPrimeIncorrectAnswer() {
int n = 2;
int expectedAnswer = 4; // Incorrect expected value
assertFalse(NewManShanksPrime.nthManShanksPrime(n, expectedAnswer), "The 2nd New Man Shanks prime should not be 4.");
}
}