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
42 lines (32 loc) · 1.45 KB
/
Copy pathtest_string_utils.py
File metadata and controls
42 lines (32 loc) · 1.45 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
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("world") == "dlrow"
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."""
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("Hello, World!") == "!dlroW ,olleH"
def test_reverse_string_with_unicode():
"""Test reversal of string with unicode characters."""
assert reverse_string("こんにちは") == "はちにんこ"
def test_reverse_string_with_numbers():
"""Test reversal of string with numbers."""
assert reverse_string("123 abc") == "cba 321"
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(12345)
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"])