-
Notifications
You must be signed in to change notification settings - Fork 19.7k
/
Copy pathArrayLeftRotationTest.java
54 lines (45 loc) · 1.37 KB
/
ArrayLeftRotationTest.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
54
package com.thealgorithms.others;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
class ArrayLeftRotationTest {
@Test
void testForOneElement() {
int[] arr = {3};
int[] result = ArrayLeftRotation.rotateLeft(arr, 3);
assertArrayEquals(arr, result);
}
@Test
void testForZeroStep() {
int[] arr = {3, 1, 5, 8, 6};
int[] result = ArrayLeftRotation.rotateLeft(arr, 0);
assertArrayEquals(arr, result);
}
@Test
void testForEqualSizeStep() {
int[] arr = {3, 1, 5, 8, 6};
int[] result = ArrayLeftRotation.rotateLeft(arr, 5);
assertArrayEquals(arr, result);
}
@Test
void testForLowerSizeStep() {
int[] arr = {3, 1, 5, 8, 6};
int n = 2;
int[] expected = {5, 8, 6, 3, 1};
int[] result = ArrayLeftRotation.rotateLeft(arr, n);
assertArrayEquals(expected, result);
}
@Test
void testForHigherSizeStep() {
int[] arr = {3, 1, 5, 8, 6};
int n = 7;
int[] expected = {5, 8, 6, 3, 1};
int[] result = ArrayLeftRotation.rotateLeft(arr, n);
assertArrayEquals(expected, result);
}
@Test
void testForEmptyArray() {
int[] arr = {};
int[] result = ArrayLeftRotation.rotateLeft(arr, 3);
assertArrayEquals(arr, result);
}
}