Skip to content

Commit b88179c

Browse files
authored
Added tests for PriorityQueueSort
1 parent 3145732 commit b88179c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.thealgorithms.sorts;
2+
3+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4+
import org.junit.jupiter.api.Test;
5+
6+
class PriorityQueueSortTest {
7+
8+
@Test
9+
void testSortNormalArray() {
10+
int[] input = {7, 2, 9, 4, 1};
11+
int[] expected = {1, 2, 4, 7, 9};
12+
assertArrayEquals(expected, PriorityQueueSort.sort(input));
13+
}
14+
15+
@Test
16+
void testEmptyArray() {
17+
int[] input = {};
18+
int[] expected = {};
19+
assertArrayEquals(expected, PriorityQueueSort.sort(input));
20+
}
21+
22+
@Test
23+
void testNegativeNumbers() {
24+
int[] input = {3, -1, 2, -5, 0};
25+
int[] expected = {-5, -1, 0, 2, 3};
26+
assertArrayEquals(expected, PriorityQueueSort.sort(input));
27+
}
28+
29+
@Test
30+
void testAlreadySortedArray() {
31+
int[] input = {1, 2, 3, 4, 5};
32+
int[] expected = {1, 2, 3, 4, 5};
33+
assertArrayEquals(expected, PriorityQueueSort.sort(input));
34+
}
35+
36+
@Test
37+
void testArrayWithDuplicates() {
38+
int[] input = {5, 1, 3, 3, 2, 5};
39+
int[] expected = {1, 2, 3, 3, 5, 5};
40+
assertArrayEquals(expected, PriorityQueueSort.sort(input));
41+
}
42+
}

0 commit comments

Comments
 (0)