From 7fb452b384dcbdf2a64592b5c3deef3c27682095 Mon Sep 17 00:00:00 2001 From: cuong Date: Thu, 16 Jun 2022 21:34:42 +0700 Subject: [PATCH] Update unit tests for rotate array number --- test/com/leetcode/arrays/RotateArrayTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/com/leetcode/arrays/RotateArrayTest.java 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