forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickSortTest.java
More file actions
69 lines (58 loc) · 1.63 KB
/
Copy pathQuickSortTest.java
File metadata and controls
69 lines (58 loc) · 1.63 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.thealgorithms.sorts;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
/**
* @author Akshay Dubey (https://github.com/itsAkshayDubey)
* @see QuickSort
*/
class QuickSortTest {
private QuickSort quickSort = new QuickSort();
@Test
void quickSortEmptyArrayShouldPass()
{
Integer[] array = {};
Integer[] sorted = quickSort.sort(array);
Integer[] expected = {};
assertArrayEquals(expected, sorted);
}
@Test
void quickSortSingleValueArrayShouldPass()
{
Integer[] array = {7};
Integer[] sorted = quickSort.sort(array);
Integer[] expected = {7};
assertArrayEquals(expected, sorted);
}
@Test
void quickSortWithIntegerArrayShouldPass()
{
Integer[] array = {49,4,36,9,144,1};
Integer[] sorted = quickSort.sort(array);
Integer[] expected = {1,4,9,36,49,144};
assertArrayEquals(expected, sorted);
}
@Test
void quickSortForArrayWithNegativeValuesShouldPass()
{
Integer[] array = {49,-36,-144,-49,1,9};
Integer[] sorted = quickSort.sort(array);
Integer[] expected = {-144,-49,-36,1,9,49};
assertArrayEquals(expected, sorted);
}
@Test
void quickSortForArrayWithDuplicateValuesShouldPass()
{
Integer[] array = {36,1,49,1,4,9};
Integer[] sorted = quickSort.sort(array);
Integer[] expected = {1,1,4,9,36,49};
assertArrayEquals(expected, sorted);
}
@Test
void quickSortWithStringArrayShouldPass()
{
String[] array = {"c", "a", "e", "b", "d"};
String[] sorted = quickSort.sort(array);
String[] expected = {"a","b","c","d","e"};
assertArrayEquals(expected, sorted);
}
}