예제 #1
0
 def test_step4_letters_count_empty(self):
     char_count = word_processor.letters_count_map('')
     self.assertEqual(
         {
             'a': 0,
             'b': 0,
             'c': 0,
             'd': 0,
             'e': 0,
             'f': 0,
             'g': 0,
             'h': 0,
             'i': 0,
             'j': 0,
             'k': 0,
             'l': 0,
             'm': 0,
             'n': 0,
             'o': 0,
             'p': 0,
             'q': 0,
             'r': 0,
             's': 0,
             't': 0,
             'u': 0,
             'v': 0,
             'w': 0,
             'x': 0,
             'y': 0,
             'z': 0
         }, char_count)
예제 #2
0
 def test_letters_count_map(self):
     text = "these are indeed interesting an obvious understatement times what say you"
     result = {
         'a': 5,
         'b': 1,
         'c': 0,
         'd': 3,
         'e': 11,
         'f': 0,
         'g': 1,
         'h': 2,
         'i': 5,
         'j': 0,
         'k': 0,
         'l': 0,
         'm': 2,
         'n': 6,
         'o': 3,
         'p': 0,
         'q': 0,
         'r': 3,
         's': 6,
         't': 8,
         'u': 3,
         'v': 1,
         'w': 1,
         'x': 0,
         'y': 2,
         'z': 0
     }
     self.assertEqual(word_processor.letters_count_map(text), result)
예제 #3
0
 def test_step4_letters_count_1(self):
     char_count = word_processor.letters_count_map(
         'These are indeed interesting, an obvious understatement, times. What say you?'
     )
     self.assertEqual(
         {
             'a': 5,
             'b': 1,
             'c': 0,
             'd': 3,
             'e': 11,
             'f': 0,
             'g': 1,
             'h': 2,
             'i': 5,
             'j': 0,
             'k': 0,
             'l': 0,
             'm': 2,
             'n': 6,
             'o': 3,
             'p': 0,
             'q': 0,
             'r': 3,
             's': 6,
             't': 8,
             'u': 3,
             'v': 1,
             'w': 1,
             'x': 0,
             'y': 2,
             'z': 0
         }, char_count)
예제 #4
0
 def test_count_letters(self):
     word = "These are indeed interesting, an obvious understatement, times. What say you?"
     letters_count = {
         'a': 5,
         'b': 1,
         'c': 0,
         'd': 3,
         'e': 11,
         'f': 0,
         'g': 1,
         'h': 2,
         'i': 5,
         'j': 0,
         'k': 0,
         'l': 0,
         'm': 2,
         'n': 6,
         'o': 3,
         'p': 0,
         'q': 0,
         'r': 3,
         's': 6,
         't': 7,
         'u': 3,
         'v': 1,
         'w': 0,
         'x': 0,
         'y': 2,
         'z': 0
     }
     self.assertEqual(letters_count, word_processor.letters_count_map(word))
예제 #5
0
 def test_letters_count_map(self):
     results = word_processor.letters_count_map(
         'Hello; How, you doing? Its been long.')
     self.assertEqual(
         {
             'a': 0,
             'b': 1,
             'c': 0,
             'd': 1,
             'e': 3,
             'f': 0,
             'g': 2,
             'h': 2,
             'i': 2,
             'j': 0,
             'k': 0,
             'l': 3,
             'm': 0,
             'n': 3,
             'o': 5,
             'p': 0,
             'q': 0,
             'r': 0,
             's': 1,
             't': 1,
             'u': 1,
             'v': 0,
             'w': 1,
             'x': 0,
             'y': 1,
             'z': 0
         }, results)
예제 #6
0
 def test_letters_count_map_empty(self):
     self.assertEqual(
         letters_count_map(""), {
             "a": 0,
             "b": 0,
             "c": 0,
             "d": 0,
             "e": 0,
             "f": 0,
             "g": 0,
             "h": 0,
             "i": 0,
             "j": 0,
             "k": 0,
             "l": 0,
             "m": 0,
             "n": 0,
             "o": 0,
             "p": 0,
             "q": 0,
             "r": 0,
             "s": 0,
             "t": 0,
             "u": 0,
             "v": 0,
             "w": 0,
             "x": 0,
             "y": 0,
             "z": 0
         })
예제 #7
0
 def test_letters_count_map(self):
     self.assertEqual(
         letters_count_map("this is the test text"), {
             "a": 0,
             "b": 0,
             "c": 0,
             "d": 0,
             "e": 3,
             "f": 0,
             "g": 0,
             "h": 2,
             "i": 2,
             "j": 0,
             "k": 0,
             "l": 0,
             "m": 0,
             "n": 0,
             "o": 0,
             "p": 0,
             "q": 0,
             "r": 0,
             "s": 3,
             "t": 6,
             "u": 0,
             "v": 0,
             "w": 0,
             "x": 1,
             "y": 0,
             "z": 0
         })
 def test_letter_count(self):
     """tests that the letter_count_map function returns a dictionary containing all the letters of the alphabet and how many times each letter occurs in a string"""
     result = word_processor.letters_count_map(
         "once a lifetime twice a day")
     expect = {
         'a': 3,
         'b': 0,
         'c': 2,
         'd': 1,
         'e': 4,
         'f': 1,
         'g': 0,
         'h': 0,
         'i': 3,
         'j': 0,
         'k': 0,
         'l': 1,
         'm': 1,
         'n': 1,
         'o': 1,
         'p': 0,
         'q': 0,
         'r': 0,
         's': 0,
         't': 2,
         'u': 0,
         'v': 0,
         'w': 1,
         'x': 0,
         'y': 1,
         'z': 0
     }
     self.assertEqual(expect, result)
 def test_letters_count_map(self):
     """
     This function makes sure that it returns a dictionary that maps each alphabet letter
     to the number of times that letter occurs in the text.
     """
     words = word_processor.letters_count_map(
         'These are indeed interesting, an obvious understatement, times. What say you?'
     )
     self.assertEqual(
         {
             'a': 5,
             'b': 1,
             'c': 0,
             'd': 3,
             'e': 11,
             'f': 0,
             'g': 1,
             'h': 2,
             'i': 5,
             'j': 0,
             'k': 0,
             'l': 0,
             'm': 2,
             'n': 6,
             'o': 3,
             'p': 0,
             'q': 0,
             'r': 3,
             's': 6,
             't': 8,
             'u': 3,
             'v': 1,
             'w': 1,
             'x': 0,
             'y': 2,
             'z': 0
         }, words)
예제 #10
0
 def test_letters_count_empty(self):
     results = word_processor.letters_count_map('')
     expected = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
     self.assertEqual(results,expected)
예제 #11
0
 def test_letters_count_map(self):
     result = word_processor.letters_count_map(text)
     self.assertEqual(result,{'a': 6, 'b': 0, 'c': 1, 'd': 0, 'e': 5, 'f': 3, 'g': 2, 'h': 4, 'i': 4, 'j': 0, 'k': 0, 'l': 2, 'm': 2, 'n': 1, 'o': 1, 'p': 0, 'q': 0, 'r': 4, 's': 5, 't': 4, 'u': 0, 'v': 0, 'w': 1, 'x': 0, 'y': 0, 'z': 0})
예제 #12
0
 def test_letters_count_map_digit(self):
     self.assertEqual(letters_count_map(123), -1)
예제 #13
0
 def test_count_letters(self):
     result = word_processor.letters_count_map('')
     self.assertTrue(
         result,
         "{'a': 5, 'b': 1, 'c': 0, 'd': 3, 'e': 11, 'f': 0, 'g': 1, 'h': 2, 'i': 5, 'j': 0, 'k': 0, 'l': 0, 'm': 2, 'n': 6, 'o': 3, 'p': 0, 'q': 0, 'r': 3, 's': 6, 't': 7, 'u': 3, 'v': 1, 'w': 0, 'x': 0, 'y': 2, 'z': 0}"
     )