Skip to content

Commit 5d34dae

Browse files
committed
improve -Wrote test for the rotate algorithm and fix some syntax error in rotate algorithm.
1 parent b8c8459 commit 5d34dae

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

rotate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ def rotate_string(sequence: str, value: int) -> str:
44
if value <= len(sequence):
55
return result[value:value+len(sequence)]
66
else:
7-
return resut[value-len(sequence):value]
8-
7+
return result[value-len(sequence):value]

tests/test_rotate.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from ..rotate import rotate_string
2+
3+
class TestRotate:
4+
def test_rotate_string(self):
5+
assert rotate_string('Github', 3) == 'hubGit'
6+
assert rotate_string('Github', 6) == 'Github'
7+
assert rotate_string('Github', 7) == 'ithubG'
8+
assert rotate_string('Github', -1) == ''
9+
assert rotate_string('Github', -3) == ''
10+
assert rotate_string('', 3) == ''
11+
assert rotate_string('', -3) == ''

0 commit comments

Comments
 (0)