def test_counting_words_separated_by_multiple_spaces(self): # test two words separated by multiple spaces self.assertEqual(utils.count_words('two words'), 2) # test multiple words separated by multiple spaces self.assertEqual( utils.count_words('there are\tfive words.\nhere.'), 5)
def test_words_with_leading_and_trailing_space(self): # test leading space self.assertEqual(utils.count_words(' two words'), 2) # test trailing space self.assertEqual(utils.count_words('two words '), 2) # test both leading and trailing space self.assertEqual(utils.count_words(' two words '), 2)
def test_counting_words_separated_by_single_spaces(self): # test two words separated by a single space self.assertEqual(utils.count_words('two words'), 2) # test two words with punctuation self.assertEqual(utils.count_words('hello, world!'), 2) # test multiple words separated by single spaces self.assertEqual(utils.count_words('there are five words here.'), 5)
def test_punctuation_is_stripped(self): # test punctuation with no words self.assertEqual(utils.count_words("?!"), 0) # test puctuation on the end of a word self.assertEqual(utils.count_words("Hey!"), 1) # test punctuation separated from a word self.assertEqual(utils.count_words("Hey !!!"), 1)
def test_counting_one_word(self): # test a normal word self.assertEqual(utils.count_words('hello'), 1) # test a nonsense word self.assertEqual(utils.count_words('alkjef'), 1)
def test_only_space(self): # test a single space self.assertEqual(utils.count_words(' '), 0) # test multiple kinds of spaces self.assertEqual(utils.count_words(' \n\t '), 0)
def test_the_empty_string(self): self.assertEqual(utils.count_words(''), 0)