Esempio n. 1
0
 def test_count_multiple_occurences(self):
     self.assertEqual({
         'one': 1,
         'fish': 4,
         'two': 1,
         'red': 1,
         'blue': 1
     }, my_word_count('one fish two fish red fish blue fish'))
Esempio n. 2
0
 def test_preserves_punctuation(self):
     self.assertEqual(
         {
             'car': 1,
             'carpet': 1,
             'as': 1,
             'java': 1,
             ':': 2,
             'javascript!!&@$%^&': 1
         }, my_word_count('car : carpet as java : javascript!!&@$%^&'))
Esempio n. 3
0
 def test_newlines(self):
     self.assertEqual(
         {
             'rah': 2,
             'ah': 3,
             'roma': 2,
             'ma': 1,
             'ga': 2,
             'oh': 1,
             'la': 2,
             'want': 1,
             'your': 1,
             'bad': 1,
             'romance': 1
         },
         my_word_count(
             'rah rah ah ah ah\nroma roma ma\nga ga oh la la\nwant your bad romance'
         ))
Esempio n. 4
0
 def test_count_one_of_each(self):
     self.assertEqual({
         'one': 1,
         'of': 1,
         'each': 1
     }, my_word_count('one of each'))
Esempio n. 5
0
 def test_count_one_word(self):
     self.assertEqual({'word': 1}, my_word_count('word'))
Esempio n. 6
0
 def test_multiple_spaces(self):
     self.assertEqual({
         'wait': 1,
         'for': 1,
         'it': 1
     }, my_word_count('wait for       it'))
Esempio n. 7
0
 def test_mixed_case(self):
     self.assertEqual({
         'go': 1,
         'Go': 1,
         'GO': 1
     }, my_word_count('go Go GO'))
Esempio n. 8
0
 def test_include_numbers(self):
     self.assertEqual({
         'testing': 2,
         '1': 1,
         '2': 1
     }, my_word_count('testing 1 2 testing'))