From 7a8191f097e85c4e976e5704a9e4475dfaa314a9 Mon Sep 17 00:00:00 2001 From: Lakshay Sharma Date: Sat, 8 Sep 2018 01:57:32 +0530 Subject: [PATCH] Negative Integer, worst case array test added --- src/test/java/com/sorts/InsertionSortTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/com/sorts/InsertionSortTest.java b/src/test/java/com/sorts/InsertionSortTest.java index 0344c2b1..0d35f571 100644 --- a/src/test/java/com/sorts/InsertionSortTest.java +++ b/src/test/java/com/sorts/InsertionSortTest.java @@ -15,6 +15,18 @@ public class InsertionSortTest { Integer[] sortedInt = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt)); + Integer[] unsortedInt = new Integer[]{5,4,3,2,1,0}; + Integer[] sortedInt = new Integer[]{0, 1, 2, 3, 4, 5}; + Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt)); + + Integer[] unsortedInt = new Integer[]{-1,-2,-3,-4,-5}; + Integer[] sortedInt = new Integer[]{-5,-4,-3,-2,-1}; + Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt)); + + Integer[] unsortedInt = new Integer[]{-1,-5,-10,-990,990,1010}; + Integer[] sortedInt = new Integer[]{-990,-10,-5,-1,990,1010}; + Assert.assertArrayEquals(sortedInt, insertionSort.sort(unsortedInt)); + Character[] unsortedChar = new Character[]{'f', 'h', 'c', 'a', 'b', 'd', 'g', 'e'}; Character[] sortedChar = new Character[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; Assert.assertArrayEquals(sortedChar, insertionSort.sort(unsortedChar));