-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotateArrayTest.py
More file actions
48 lines (43 loc) · 1.11 KB
/
RotateArrayTest.py
File metadata and controls
48 lines (43 loc) · 1.11 KB
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
import unittest
import RotateArray
class RotateArrayTest(unittest.TestCase):
def testZeroRotations(self):
nums = [1,2,3,4,5]
K = 0
ra = RotateArray.RotateArray(nums)
ra.rotate(K)
expected = [1,2,3,4,5]
actual = ra.nums
self.assertSequenceEqual(actual, expected)
def testThreeRotations(self):
nums = [1,2,3,4,5]
K = 3
ra = RotateArray.RotateArray(nums)
ra.rotate(K)
expected = [3,4,5,1,2]
actual = ra.nums
self.assertSequenceEqual(actual, expected)
def testMoreThanLengthOfArray(self):
nums = [1,2,3,4,5]
K = 6
ra = RotateArray.RotateArray(nums)
ra.rotate(K)
expected = [5,1,2,3,4]
actual = ra.nums
self.assertSequenceEqual(actual, expected)
def testEmptyArray(self):
nums = []
K = 3
ra = RotateArray.RotateArray(nums)
ra.rotate(K)
expected = []
actual = ra.nums
self.assertSequenceEqual(actual, expected)
def testSingleElementArray(self):
nums = [1]
K = 4
ra = RotateArray.RotateArray(nums)
ra.rotate(K)
expected = [1]
actual = ra.nums
self.assertSequenceEqual(actual, expected)