|
3 | 3 | # Import the function you want to test |
4 | 4 | from methods.stringmainpulation import * |
5 | 5 |
|
6 | | -class TestCountVowels(unittest.TestCase): |
7 | | - def test_no_vowels(self): |
| 6 | +class TestStringManipulation(unittest.TestCase): |
| 7 | + def test_count_vowels_string_no_vowels(self): |
8 | 8 | result = count_vowels("rhythm") |
9 | 9 | self.assertEqual(result, {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0}) |
10 | 10 |
|
11 | | - def test_all_vowels(self): |
| 11 | + def test_count_vowels_string_has_vowels(self): |
12 | 12 | result = count_vowels("aeiouAEIOU") |
13 | 13 | self.assertEqual(result, {'a': 2, 'e': 2, 'i': 2, 'o': 2, 'u': 2}) |
14 | 14 |
|
15 | | - def test_mixed_string(self): |
| 15 | + def test_count_vowels_string_vowels_and_consonants(self): |
16 | 16 | result = count_vowels("Hello, World!") |
17 | 17 | self.assertEqual(result, {'a': 0, 'e': 1, 'i': 0, 'o': 2, 'u': 0}) |
18 | 18 |
|
19 | | - def test_empty_string_counting_vowels(self): |
| 19 | + def test_count_vowels_empty_string(self): |
20 | 20 | result = count_vowels("") |
21 | 21 | self.assertEqual(result, {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0}) |
22 | 22 |
|
23 | | - def test_case_insensitive(self): |
| 23 | + def test_count_vowels_empty_string(self): |
24 | 24 | result = count_vowels("Python Is Awesome") |
25 | 25 | self.assertEqual(result, {'a': 1, 'e': 2, 'i': 1, 'o': 2, 'u': 0}) |
26 | 26 |
|
27 | | - def test_empty_string(self): |
28 | | - result = ispalindrome("") |
| 27 | + def test_count_vowels_string_non_ascii_chars_only(self): |
| 28 | + result = count_vowels("#!@$% ?") |
| 29 | + self.assertEqual(result, {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0}) |
| 30 | + |
| 31 | + def test_is_palindrome_empty_string(self): |
| 32 | + result = is_palindrome("") |
29 | 33 | self.assertTrue(result) |
30 | 34 |
|
31 | | - def test_single_character(self): |
32 | | - result = ispalindrome("a") |
| 35 | + def test_is_palindrome_whitespace_only(self): |
| 36 | + result = is_palindrome(" ") |
33 | 37 | self.assertTrue(result) |
34 | 38 |
|
35 | | - def test_palindrome_with_spaces(self): |
36 | | - result = ispalindrome("A man a plan a canal Panama") |
| 39 | + def test_is_palindrome_single_character(self): |
| 40 | + result = is_palindrome("a") |
37 | 41 | self.assertTrue(result) |
38 | 42 |
|
39 | | - def test_palindrome_with_punctuation(self): |
40 | | - result = ispalindrome("Was it a car or a cat I saw?") |
| 43 | + def test_is_palindrome_sentence_without_punctuation(self): |
| 44 | + result = is_palindrome("A man a plan a canal Panama") |
41 | 45 | self.assertTrue(result) |
42 | 46 |
|
43 | | - def test_non_palindrome(self): |
44 | | - result = ispalindrome("Hello, World!") |
| 47 | + def test_is_palindrome_sentence_with_punctuation(self): |
| 48 | + result = is_palindrome("Was it a car or a cat I saw?") |
| 49 | + self.assertTrue(result) |
| 50 | + |
| 51 | + def test_is_palindrome_sentence_not_palindrome(self): |
| 52 | + result = is_palindrome("Hello, World!") |
45 | 53 | self.assertFalse(result) |
46 | 54 |
|
47 | | - def test_empty_string_remove_punctuation(self): |
| 55 | + def test_remove_punctuation_empty_string_remove_punctuation(self): |
48 | 56 | result = remove_punctuation("") |
49 | 57 | self.assertEqual(result, "") |
50 | 58 |
|
51 | | - def test_no_punctuation(self): |
| 59 | + def test_remove_punctuation_sentence_no_punctuation(self): |
52 | 60 | result = remove_punctuation("This is a test string") |
53 | 61 | self.assertEqual(result, "This is a test string") |
54 | 62 |
|
55 | | - def test_with_punctuation(self): |
| 63 | + def test_remove_punctuation_sentence_with_punctuation(self): |
56 | 64 | result = remove_punctuation("Hello, World! This is a test.") |
57 | 65 | self.assertEqual(result, "Hello World This is a test") |
58 | 66 |
|
59 | | - def test_mixed_characters(self): |
| 67 | + def test_remove_punctuation_mixed_characters(self): |
60 | 68 | result = remove_punctuation("123@abc#def%") |
61 | 69 | self.assertEqual(result, "123abcdef") |
62 | 70 |
|
63 | | - def test_unicode_punctuation(self): |
64 | | - result = remove_punctuation("Unicode — string: ™ ©") |
65 | | - self.assertEqual(result, "Unicode string ") |
66 | | - |
67 | 71 | if __name__ == '__main__': |
68 | 72 | unittest.main() |
0 commit comments