-
Notifications
You must be signed in to change notification settings - Fork 19.4k
/
PollardRhoTest.java
49 lines (37 loc) · 1.19 KB
/
PollardRhoTest.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
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class PollardRhoTest {
@Test
void testPollardRhoForNumber315MustReturn5() {
// given
int number = 315;
int expectedResult = 5;
// when
int actualResult = PollardRho.pollardRho(number);
// then
assertEquals(expectedResult, actualResult);
}
@Test
void testPollardRhoForNumber187MustReturn11() {
// given
int number = 187;
int expectedResult = 11;
// when
int actualResult = PollardRho.pollardRho(number);
// then
assertEquals(expectedResult, actualResult);
}
@Test
void testPollardRhoForNumber239MustThrowException() {
// given
int number = 239;
String expectedMessage = "GCD cannot be found.";
// when
Exception exception = assertThrows(RuntimeException.class, () -> { PollardRho.pollardRho(number); });
String actualMessage = exception.getMessage();
// then
assertEquals(expectedMessage, actualMessage);
}
}