Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
37 lines (28 loc) · 1.56 KB

File metadata and controls

37 lines (28 loc) · 1.56 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.sorts;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class CycleSortTest {
@Test
void cycleSortIntegerTest() {
CycleSort cycleSort = new CycleSort();
// Test case for integers
Integer[] unsortedInt = new Integer[]{5, 1, 7, 0, 2, 9, 6, 3, 4, 8};
Integer[] sortedInt = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Assertions.assertArrayEquals(sortedInt, cycleSort.sort(unsortedInt));
// Test case for floating point numbers
Float[] unsortedFloat = new Float[]{6.7f, 21.1f, 0.9f, -3.2f, 5.9f, -21.3f};
Float[] sortedFloat = new Float[]{-21.3f, -3.2f, 0.9f, 5.9f, 6.7f, 21.1f};
Assertions.assertArrayEquals(sortedFloat, cycleSort.sort(unsortedFloat));
// Test case for characters
Character[] unsortedChar = new Character[]{'c', 'a', 'b', 'A', 'C', 'B'};
Character[] sortedChar = new Character[]{'A', 'B', 'C', 'a', 'b', 'c'};
Assertions.assertArrayEquals(sortedChar, cycleSort.sort(unsortedChar));
// Test case for Strings
String[] unsortedStr = new String[]{"Edward", "Linus", "David", "Alan", "Dennis", "Robert", "Ken"};
String[] sortedStr = new String[]{"Alan", "David", "Dennis", "Edward", "Ken", "Linus", "Robert"};
Assertions.assertArrayEquals(sortedStr, cycleSort.sort(unsortedStr));
Integer[] unsortedShortInt = new Integer[]{29, 11};
Integer[] sortedShortInt = new Integer[]{11, 29};
Assertions.assertArrayEquals(sortedShortInt, cycleSort.sort(unsortedShortInt));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.