forked from SyedGhazanferAnwar/MailGeek
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_string_utils.py
More file actions
38 lines (29 loc) · 1.31 KB
/
Copy pathtest_string_utils.py
File metadata and controls
38 lines (29 loc) · 1.31 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
import pytest
from src.string_utils import reverse_string
def test_reverse_string_basic():
"""Test basic string reversal."""
assert reverse_string("hello") == "olleh"
assert reverse_string("python") == "nohtyp"
def test_reverse_string_empty():
"""Test reversal of an empty string."""
assert reverse_string("") == ""
def test_reverse_string_single_char():
"""Test reversal of a single character string."""
assert reverse_string("a") == "a"
def test_reverse_string_with_spaces():
"""Test reversal of string with spaces."""
assert reverse_string("hello world") == "dlrow olleh"
def test_reverse_string_with_special_chars():
"""Test reversal of string with special characters."""
assert reverse_string("a1b2c3!@#") == "#@!3c2b1a"
def test_reverse_string_unicode():
"""Test reversal of string with unicode characters."""
assert reverse_string("こんにちは") == "はちにんこ"
def test_reverse_string_invalid_input():
"""Test that TypeError is raised for non-string inputs."""
with pytest.raises(TypeError, match="Input must be a string"):
reverse_string(123)
with pytest.raises(TypeError, match="Input must be a string"):
reverse_string(None)
with pytest.raises(TypeError, match="Input must be a string"):
reverse_string(["hello"])