Skip to content

Commit

Permalink
test: write test rotate right bruteforce
Browse files Browse the repository at this point in the history
  • Loading branch information
rldnrl committed Dec 8, 2022
1 parent 8a8f420 commit e815e7a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions test/leetcode/RotateRightArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static leetcode.RotateRightArray.rotateRight;

public class RotateRightArrayTest {
class RotateRightArrayTest {
@Test
void rotateRightTest() {
int[] testNums1 = new int[] {1, 2, 3, 4, 5, 6, 7};
int[] testNums1Result = new int[] {5,6,7,1,2,3,4};
rotateRight(testNums1, 3);
RotateRightArray.rotateRight(testNums1, 3);
Assertions.assertArrayEquals(testNums1, testNums1Result);

int[] testNum2 = new int[] {-1,-100,3,99};
int[] testNum2Result = new int[] {3,99,-1,-100};
RotateRightArray.rotateRight(testNum2, 2);
Assertions.assertArrayEquals(testNum2, testNum2Result);
}

@Test
void rotateWithBruteforceTest() {
int[] testNums1 = new int[] {1, 2, 3, 4, 5, 6, 7};
int[] testNums1Result = new int[] {5,6,7,1,2,3,4};
RotateRightArray.rotateRightWithBruteforce(testNums1, 3);
Assertions.assertArrayEquals(testNums1, testNums1Result);

int[] testNum2 = new int[] {-1,-100,3,99};
int[] testNum2Result = new int[] {3,99,-1,-100};
rotateRight(testNum2, 2);
RotateRightArray.rotateRightWithBruteforce(testNum2, 2);
Assertions.assertArrayEquals(testNum2, testNum2Result);
}
}

0 comments on commit e815e7a

Please sign in to comment.