fix a bug #1250
This commit is contained in:
parent
f3f2661d35
commit
7b1c328594
@ -15,7 +15,7 @@ public class CycleSort {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
// Traverse array and put the elements on their respective right places
|
// Traverse array and put the elements on their respective right places
|
||||||
for (int i = 0; i < n - 2; i++) {
|
for (int i = 0; i < n - 1; i++) {
|
||||||
|
|
||||||
// Initialize item as the starting point
|
// Initialize item as the starting point
|
||||||
T item = arr[i];
|
T item = arr[i];
|
||||||
|
@ -36,7 +36,7 @@ class StackTest {
|
|||||||
myStack.push(30);
|
myStack.push(30);
|
||||||
myStack.push(40);
|
myStack.push(40);
|
||||||
|
|
||||||
Assertions.assertEquals(40, myStack.peek());
|
Assertions.assertEquals(40, (int) myStack.peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -57,7 +57,7 @@ class StackTest {
|
|||||||
myStack.push(40);
|
myStack.push(40);
|
||||||
myStack.push(50);
|
myStack.push(50);
|
||||||
|
|
||||||
Assertions.assertEquals(50, myStack.pop());
|
Assertions.assertEquals(50, (int) myStack.pop());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,5 +30,8 @@ class CycleSortTest {
|
|||||||
String[] sortedStr = new String[]{"Alan", "David", "Dennis", "Edward", "Ken", "Linus", "Robert"};
|
String[] sortedStr = new String[]{"Alan", "David", "Dennis", "Edward", "Ken", "Linus", "Robert"};
|
||||||
Assertions.assertArrayEquals(sortedStr, cycleSort.sort(unsortedStr));
|
Assertions.assertArrayEquals(sortedStr, cycleSort.sort(unsortedStr));
|
||||||
|
|
||||||
|
Integer[] unsortedShortInt = new Integer[]{29, 11};
|
||||||
|
Integer[] sortedShortInt = new Integer[]{11, 29};
|
||||||
|
Assertions.assertArrayEquals(sortedShortInt, cycleSort.sort(unsortedShortInt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user