forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrandSortTest.java
More file actions
34 lines (29 loc) · 1.12 KB
/
StrandSortTest.java
File metadata and controls
34 lines (29 loc) · 1.12 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
package com.thealgorithms.sorts;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Arrays;
import java.util.LinkedList;
import org.junit.jupiter.api.Test;
class StrandSortTest {
@Test
// valid test case
public void StrandSortNonDuplicateTest() {
int[] expectedArray = {1, 2, 3, 4, 5};
LinkedList<Integer> actualList = StrandSort.strandSort(new LinkedList<Integer>(Arrays.asList(3, 1, 2, 4, 5)));
int[] actualArray = new int[actualList.size()];
for (int i = 0; i < actualList.size(); i++) {
actualArray[i] = actualList.get(i);
}
assertArrayEquals(expectedArray, actualArray);
}
@Test
// valid test case
public void StrandSortDuplicateTest() {
int[] expectedArray = {2, 2, 2, 5, 7};
LinkedList<Integer> actualList = StrandSort.strandSort(new LinkedList<Integer>(Arrays.asList(7, 2, 2, 2, 5)));
int[] actualArray = new int[actualList.size()];
for (int i = 0; i < actualList.size(); i++) {
actualArray[i] = actualList.get(i);
}
assertArrayEquals(expectedArray, actualArray);
}
}