Skip to content

Commit f6d6795

Browse files
committed
test: add unit test for BubbleSort with negative numbers
- Added testBubbleSortNegativeNumbers to verify sorting works correctly with negative values - Ensures the sort handles negative numbers properly
1 parent 404e140 commit f6d6795

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/java/com/thealgorithms/sorts/BubbleSortTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ public int hashCode() {
160160
}
161161
}
162162

163+
@Test
164+
public void bubbleSortNegativeNumbers() {
165+
Integer[] inputArray = {5, -1, 7, 0};
166+
Integer[] outputArray = bubbleSort.sort(inputArray);
167+
Integer[] expectedOutput = {-1, 0, 5, 7};
168+
assertArrayEquals(expectedOutput, outputArray);
169+
}
170+
163171
@Test
164172
public void bubbleSortCustomObjects() {
165173
Person[] inputArray = {

0 commit comments

Comments
 (0)