- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathArrayRightRotationTest.java
53 lines (45 loc) · 1.57 KB
/
ArrayRightRotationTest.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
packagecom.thealgorithms.others;
importstaticorg.junit.jupiter.api.Assertions.assertArrayEquals;
importorg.junit.jupiter.api.Test;
classArrayRightRotationTest {
@Test
voidtestArrayRightRotation() {
int[] arr = {1, 2, 3, 4, 5, 6, 7};
intk = 3;
int[] expected = {5, 6, 7, 1, 2, 3, 4};
int[] result = ArrayRightRotation.rotateRight(arr, k);
assertArrayEquals(expected, result);
}
@Test
voidtestArrayRightRotationWithZeroSteps() {
int[] arr = {1, 2, 3, 4, 5, 6, 7};
intk = 0;
int[] expected = {1, 2, 3, 4, 5, 6, 7};
int[] result = ArrayRightRotation.rotateRight(arr, k);
assertArrayEquals(expected, result);
}
@Test
voidtestArrayRightRotationWithEqualSizeSteps() {
int[] arr = {1, 2, 3, 4, 5, 6, 7};
intk = arr.length;
int[] expected = {1, 2, 3, 4, 5, 6, 7};
int[] result = ArrayRightRotation.rotateRight(arr, k);
assertArrayEquals(expected, result);
}
@Test
voidtestArrayRightRotationWithLowerSizeSteps() {
int[] arr = {1, 2, 3, 4, 5, 6, 7};
intk = 2;
int[] expected = {6, 7, 1, 2, 3, 4, 5};
int[] result = ArrayRightRotation.rotateRight(arr, k);
assertArrayEquals(expected, result);
}
@Test
voidtestArrayRightRotationWithHigherSizeSteps() {
int[] arr = {1, 2, 3, 4, 5, 6, 7};
intk = 10;
int[] expected = {5, 6, 7, 1, 2, 3, 4};
int[] result = ArrayRightRotation.rotateRight(arr, k);
assertArrayEquals(expected, result);
}
}