forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySelectionSortTest.java
More file actions
44 lines (29 loc) · 1.04 KB
/
MySelectionSortTest.java
File metadata and controls
44 lines (29 loc) · 1.04 KB
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
package com.zetcode.sort;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.RepetitionInfo;
import java.util.Arrays;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.assertEquals;
class MySelectionSortTest {
private final int N = 10;
private int[] vals = new int[N];
@BeforeEach
void beforeEach(RepetitionInfo info) {
System.out.printf("Test #%d%n", info.getCurrentRepetition());
var r = new Random(System.nanoTime());
for (int i=0; i< N; i++) {
vals[i] = r.nextInt(100);
}
}
@RepeatedTest(value = 40, name = "#{displayName} {currentRepetition}/{totalRepetitions}")
@DisplayName("should sort values")
void doSort() {
System.out.println(Arrays.toString(vals));
var sorted = MySelectionSort.doSort(vals);
Arrays.sort(vals);
System.out.println(Arrays.toString(sorted));
assertEquals(sorted, vals);
}
}