forked from rampatra/Algorithms-and-Data-Structures-in-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotateArrayTest.java
34 lines (27 loc) · 828 Bytes
/
RotateArrayTest.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
package com.leetcode.arrays;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class RotateArrayTest {
@Test
public void testRotateArray_whenRotateThreeStep() {
// Given
RotateArray rotateArray = new RotateArray();
int[] arr = {1, 2, 3, 4, 5, 6, 7};
int[] exepctedArr = {5, 6, 7, 1, 2, 3, 4};
// When
rotateArray.rotate(arr, 3);
// Then
assertArrayEquals(arr, exepctedArr);
}
@Test
public void testRotateArray_whenRotateFourStepAndArrayHasOnlyOneElement() {
// Given
RotateArray rotateArray = new RotateArray();
int[] arr = {1};
int[] exepctedArr = {1};
// When
rotateArray.rotate(arr, 4);
// Then
assertArrayEquals(arr, exepctedArr);
}
}