4
4
5
5
import org .junit .jupiter .api .Test ;
6
6
7
- public class ArrayRightRotationTest {
7
+ class ArrayRightRotationTest {
8
8
9
9
@ Test
10
10
void testArrayRightRotation () {
@@ -16,46 +16,37 @@ void testArrayRightRotation() {
16
16
}
17
17
18
18
@ 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 };
21
21
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 };
32
23
int [] result = ArrayRightRotation .rotateRight (arr , k );
33
24
assertArrayEquals (expected , result );
34
25
}
35
26
36
27
@ 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 };
41
32
int [] result = ArrayRightRotation .rotateRight (arr , k );
42
33
assertArrayEquals (expected , result );
43
34
}
44
35
45
36
@ 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 };
50
41
int [] result = ArrayRightRotation .rotateRight (arr , k );
51
42
assertArrayEquals (expected , result );
52
43
}
53
44
54
45
@ 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 };
59
50
int [] result = ArrayRightRotation .rotateRight (arr , k );
60
51
assertArrayEquals (expected , result );
61
52
}
0 commit comments