|
|
@@ -1,44 +1,51 @@
|
|
1
|
|
-import org.junit.Test;
|
|
|
1
|
+import org.junit.Before;
|
|
2
|
2
|
import org.junit.Ignore;
|
|
3
|
3
|
import org.junit.Rule;
|
|
|
4
|
+import org.junit.Test;
|
|
4
|
5
|
import org.junit.rules.ExpectedException;
|
|
5
|
6
|
|
|
6
|
7
|
import static org.hamcrest.CoreMatchers.*;
|
|
7
|
8
|
import static org.junit.Assert.*;
|
|
8
|
9
|
|
|
9
|
|
-public class PrimeTest {
|
|
|
10
|
+public class PrimeCalculatorTest {
|
|
|
11
|
+ private PrimeCalculator primeCalculator;
|
|
|
12
|
+
|
|
|
13
|
+ @Before
|
|
|
14
|
+ public void setup() {
|
|
|
15
|
+ primeCalculator = new PrimeCalculator();
|
|
|
16
|
+ }
|
|
10
|
17
|
|
|
11
|
18
|
@Rule
|
|
12
|
19
|
public ExpectedException thrown = ExpectedException.none();
|
|
13
|
|
-
|
|
|
20
|
+
|
|
14
|
21
|
@Test
|
|
15
|
22
|
public void testFirstPrime() {
|
|
16
|
|
- assertThat(Prime.nth(1), is(2));
|
|
|
23
|
+ assertThat(primeCalculator.nth(1), is(2));
|
|
17
|
24
|
}
|
|
18
|
25
|
|
|
19
|
26
|
@Ignore
|
|
20
|
27
|
@Test
|
|
21
|
28
|
public void testSecondPrime() {
|
|
22
|
|
- assertThat(Prime.nth(2), is(3));
|
|
|
29
|
+ assertThat(primeCalculator.nth(2), is(3));
|
|
23
|
30
|
}
|
|
24
|
31
|
|
|
25
|
32
|
@Ignore
|
|
26
|
33
|
@Test
|
|
27
|
34
|
public void testSixthPrime() {
|
|
28
|
|
- assertThat(Prime.nth(6), is(13));
|
|
|
35
|
+ assertThat(primeCalculator.nth(6), is(13));
|
|
29
|
36
|
}
|
|
30
|
37
|
|
|
31
|
38
|
@Ignore
|
|
32
|
39
|
@Test
|
|
33
|
40
|
public void testBigPrime() {
|
|
34
|
|
- assertThat(Prime.nth(10001), is(104743));
|
|
|
41
|
+ assertThat(primeCalculator.nth(10001), is(104743));
|
|
35
|
42
|
}
|
|
36
|
43
|
|
|
37
|
44
|
@Ignore
|
|
38
|
45
|
@Test
|
|
39
|
46
|
public void testUndefinedPrime() {
|
|
40
|
47
|
thrown.expect(IllegalArgumentException.class);
|
|
41
|
|
- Prime.nth(0);
|
|
|
48
|
+ primeCalculator.nth(0);
|
|
42
|
49
|
}
|
|
43
|
|
-
|
|
|
50
|
+
|
|
44
|
51
|
}
|