forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMergeSortTest.java
More file actions
37 lines (30 loc) · 928 Bytes
/
MergeSortTest.java
File metadata and controls
37 lines (30 loc) · 928 Bytes
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
package com.examplehub.sorts;
import static org.junit.jupiter.api.Assertions.*;
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 MergeSortTest {
private Sort sort;
@BeforeEach
public void before() {
sort = new MergeSort();
}
@Test
void testSort() {
int[] numbers = new int[] {1, 3, 5, 7, 9, 2, 4, 6, 8, 10};
sort.sort(numbers);
assertTrue(Arrays.equals(numbers, new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
int[] ints = RandomUtils.randomInts(-50, 50, 100);
sort.sort(ints);
assertTrue(SortUtils.isSorted(ints));
}
@Test
void sortInteger() {
Integer[] integers =
Arrays.stream(RandomUtils.randomInts(-50, 50, 100)).boxed().toArray(Integer[]::new);
sort.sort(integers);
assertTrue(SortUtils.isSorted(integers));
}
}