Skip to content

Commit ab09983

Browse files
committed
Add template test cases
1 parent 08f94af commit ab09983

5 files changed

Lines changed: 41 additions & 1 deletion

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ lint:
1919
run:
2020
pipenv run python -m main
2121

22+
.PHONY: tests
23+
tests:
24+
pipenv run python -m pytest tests -rP

main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
print("Hello")
1+
from utils import concatenate_strings
2+
3+
s1 = "Hello, "
4+
s2 = "World!"
5+
6+
print(concatenate_strings(str1=s1, str2=s2))

tests/__init__.py

Whitespace-only changes.

tests/test_utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from utils import concatenate_strings
2+
3+
4+
def test_concatenate_strings():
5+
# Test with normal strings
6+
assert concatenate_strings("Hello, ", "World!") == "Hello, World!", "Test with normal strings failed"
7+
8+
# Test with empty strings
9+
assert concatenate_strings("", "") == "", "Test with empty strings failed"
10+
assert concatenate_strings("Hello", "") == "Hello", "Test with empty string (second argument) failed"
11+
assert concatenate_strings("", "World!") == "World!", "Test with empty string (first argument) failed"
12+
13+
# Test with numeric strings
14+
assert concatenate_strings("123", "456") == "123456", "Test with numeric strings failed"
15+
16+
# Test with special characters
17+
assert concatenate_strings("Hello@", "#World") == "Hello@#World", "Test with special characters failed"
18+
19+
# Test with mixed characters
20+
assert concatenate_strings("123", "ABC") == "123ABC", "Test with mixed characters failed"

utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def concatenate_strings(str1: str, str2: str):
2+
"""
3+
Concatenates two given strings.
4+
5+
Parameters:
6+
str1 (str): The first string.
7+
str2 (str): The second string.
8+
9+
Returns:
10+
str: The concatenated string.
11+
"""
12+
return str1 + str2

0 commit comments

Comments
 (0)