forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShellSortTest.java
More file actions
44 lines (37 loc) · 1.05 KB
/
ShellSortTest.java
File metadata and controls
44 lines (37 loc) · 1.05 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.examplehub.sorts;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.examplehub.utils.RandomUtils;
import com.examplehub.utils.SortUtils;
import java.util.Arrays;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ShellSortTest {
private Sort sort;
@BeforeEach
public void before() {
sort = new ShellSort();
}
@Test
void testSort() {
int[] ints = RandomUtils.randomInts(-50, 50, 100);
sort.sort(ints);
assertTrue(SortUtils.isSorted(ints));
}
@Test
void testSortIntegers() {
Integer[] integers =
Arrays.stream(RandomUtils.randomInts(-50, 50, 100)).boxed().toArray(Integer[]::new);
sort.sort(integers);
assertTrue(SortUtils.isSorted(integers));
}
@Test
void testSortedDoubles() {
Double[] doubles = new Double[100];
double[] tempDoubles = RandomUtils.randomDoubles(-50, 50, 100);
for (int i = 0; i < doubles.length; ++i) {
doubles[i] = tempDoubles[i];
}
sort.sort(doubles);
assertTrue(SortUtils.isSorted(doubles));
}
}