diff --git a/test/com/leetcode/arrays/RotateArrayTest.java b/test/com/leetcode/arrays/RotateArrayTest.java new file mode 100644 index 00000000..ba686fdb --- /dev/null +++ b/test/com/leetcode/arrays/RotateArrayTest.java @@ -0,0 +1,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); + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy