Skip to content

Commit a21da28

Browse files
Update ArrayRightRotationTest.java
1 parent f22648a commit a21da28

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

src/test/java/com/thealgorithms/others/ArrayRightRotationTest.java

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import org.junit.jupiter.api.Test;
66

7-
public class ArrayRightRotationTest {
7+
class ArrayRightRotationTest {
88

99
@Test
1010
void testArrayRightRotation() {
@@ -16,46 +16,37 @@ void testArrayRightRotation() {
1616
}
1717

1818
@Test
19-
void testArrayRightRotationWithZeroStep() {
20-
int[] arr = {1, 2, 3, 4, 5};
19+
void testArrayRightRotationWithZeroSteps() {
20+
int[] arr = {1, 2, 3, 4, 5, 6, 7};
2121
int k = 0;
22-
int[] expected = {1, 2, 3, 4, 5};
23-
int[] result = ArrayRightRotation.rotateRight(arr, k);
24-
assertArrayEquals(expected, result);
25-
}
26-
27-
@Test
28-
void testArrayRightRotationWithLargeStep() {
29-
int[] arr = {1, 2, 3, 4, 5};
30-
int k = 7;
31-
int[] expected = {4, 5, 1, 2, 3};
22+
int[] expected = {1, 2, 3, 4, 5, 6, 7};
3223
int[] result = ArrayRightRotation.rotateRight(arr, k);
3324
assertArrayEquals(expected, result);
3425
}
3526

3627
@Test
37-
void testArrayRightRotationWithNegativeStep() {
38-
int[] arr = {1, 2, 3, 4, 5};
39-
int k = -2;
40-
int[] expected = {4, 5, 1, 2, 3};
28+
void testArrayRightRotationWithEqualSizeSteps() {
29+
int[] arr = {1, 2, 3, 4, 5, 6, 7};
30+
int k = arr.length;
31+
int[] expected = {1, 2, 3, 4, 5, 6, 7};
4132
int[] result = ArrayRightRotation.rotateRight(arr, k);
4233
assertArrayEquals(expected, result);
4334
}
4435

4536
@Test
46-
void testArrayRightRotationWithSingleElement() {
47-
int[] arr = {7};
48-
int k = 1;
49-
int[] expected = {7};
37+
void testArrayRightRotationWithLowerSizeSteps() {
38+
int[] arr = {1, 2, 3, 4, 5, 6, 7};
39+
int k = 2;
40+
int[] expected = {6, 7, 1, 2, 3, 4, 5};
5041
int[] result = ArrayRightRotation.rotateRight(arr, k);
5142
assertArrayEquals(expected, result);
5243
}
5344

5445
@Test
55-
void testArrayRightRotationWithEmptyArray() {
56-
int[] arr = {};
57-
int k = 3;
58-
int[] expected = {};
46+
void testArrayRightRotationWithHigherSizeSteps() {
47+
int[] arr = {1, 2, 3, 4, 5, 6, 7};
48+
int k = 10;
49+
int[] expected = {5, 6, 7, 1, 2, 3, 4};
5950
int[] result = ArrayRightRotation.rotateRight(arr, k);
6051
assertArrayEquals(expected, result);
6152
}

0 commit comments

Comments
 (0)