Skip to content

Commit

Permalink
Initial commit with to_uppercase function and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NimahMasuud committed Jan 12, 2025
1 parent 9799df1 commit 765f6a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions solutions/tests/test_to_uppercase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
Unit tests for the to_uppercase function.
Created on XX XX XX
@author: Your Name
Created on 11 01 2025
@author: Nimah Masuud
"""

import unittest
Expand Down
35 changes: 19 additions & 16 deletions solutions/to_uppercase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@
# -*- coding: utf-8 -*-
"""
Module for converting strings to uppercase.
Module contents:
- to_uppercase: Converts a given string to uppercase.
Created on XX XX XX
@author: Your Name
Created on 09 Jan 2025
@author: Nimah
"""


def to_uppercase(s: str) -> str:
"""Converts a string to uppercase.
Parameters:
s (str): The string to be converted.
Returns:
str: The string with all characters in uppercase.
Raises:
TypeError: If the input is not a string.
>>> to_uppercase("hello")
'HELLO'
>>> to_uppercase("Python")
'PYTHON'
>>> to_uppercase("123abc")
'123ABC'
Examples:
>>> to_uppercase("hello")
'HELLO'
>>> to_uppercase("Python")
'PYTHON'
>>> to_uppercase("123abc")
'123ABC'
>>> to_uppercase("")
''
>>> to_uppercase("!@#$%^")
'!@#$%^'
"""
if not isinstance(s, str):
raise TypeError("Input must be a string.")
return s.upper()


if __name__ == "__main__":
import doctest

doctest.testmod()

0 comments on commit 765f6a5

Please sign in to comment.