Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_string_utils.py #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions 4-testing/17-assertions/test_string_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@
class TestStringUtils(unittest.TestCase):

def test_reverse_string(self):
# Test cases for reversing a string
self.assertEqual(reverse_string('mochi'), 'ihcom')

self.assertEqual(reverse_string('hello'), 'olleh')
self.assertEqual(reverse_string('Python'), 'nohtyP')
self.assertEqual(reverse_string(''), '') # Empty string case

def test_capitalize_string(self):
# Test cases for capitalizing a string
self.assertEqual(capitalize_string('mochi'), 'Mochi')
self.assertEqual(capitalize_string('hello'), 'Hello')
self.assertEqual(capitalize_string('python'), 'Python')
self.assertEqual(capitalize_string('hELLO'), 'Hello') # Should fix mixed case
self.assertEqual(capitalize_string(''), '') # Empty string case

def test_is_capitalized(self):
self.assertTrue(is_capitalized('mochi'))
# Test cases for checking if the string is capitalized
self.assertTrue(is_capitalized('Mochi'))
self.assertFalse(is_capitalized('mochi')) # This case should return False
self.assertTrue(is_capitalized('Hello'))
self.assertFalse(is_capitalized('hello'))
self.assertFalse(is_capitalized('')) # Empty string should return False

if __name__ == '__main__':
unittest.main()