Skip to content

Commit c4a13fc

Browse files
authored
Merge pull request TheAlgorithms#512 from lakshay17244/patch-1
Negative Integer, worst case array test added
2 parents e4827bd + 7a8191f commit c4a13fc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/com/sorts/InsertionSortTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public void insertionSortTest() {
1515
Integer[] sortedInt = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
1616
Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt));
1717

18+
Integer[] unsortedInt = new Integer[]{5,4,3,2,1,0};
19+
Integer[] sortedInt = new Integer[]{0, 1, 2, 3, 4, 5};
20+
Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt));
21+
22+
Integer[] unsortedInt = new Integer[]{-1,-2,-3,-4,-5};
23+
Integer[] sortedInt = new Integer[]{-5,-4,-3,-2,-1};
24+
Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt));
25+
26+
Integer[] unsortedInt = new Integer[]{-1,-5,-10,-990,990,1010};
27+
Integer[] sortedInt = new Integer[]{-990,-10,-5,-1,990,1010};
28+
Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt));
29+
1830
Character[] unsortedChar = new Character[]{'f', 'h', 'c', 'a', 'b', 'd', 'g', 'e'};
1931
Character[] sortedChar = new Character[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
2032
Assert.assertArrayEquals(sortedChar, insertionSort.sort(unsortedChar));

0 commit comments

Comments
 (0)