def test_leading_bear(self): '''Test an bear list.''' output = leading_substrings('bear') output_expected = ['b', 'be', 'bea', 'bear'] self.assertEqual(output_expected, output, "'bear' is decomposed correctly.")
def test_leading_empty(self): '''Test an empty list.''' output = leading_substrings('') output_expected = [] self.assertEqual(output_expected, output, "'' is decomposed correctly.")
def test_leading_sub_multi_word(self): '''Test for more than one word''' input = 'the test ran' output_expected = [ 't', 'th', 'the', 'the ', 'the t', 'the te', 'the tes', 'the test', 'the test ', 'the test r', 'the test ra', 'the test ran' ] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, 'Multiple words')
def test_empty_string(self): '''Test empty string''' inputed = '' output = leading.leading_substrings(inputed) output_expected = [] self.assertEqual(output, output_expected, 'The string is empty.')
def test_longer_string(self): '''Test on a longer string.''' inputed = 'hello' output = leading.leading_substrings(inputed) output_expected = ['h', 'he', 'hel', 'hell', 'hello'] self.assertEqual(output, output_expected, 'The string is longer.')
def test_one_characte_string(self): '''Test on a one-character string.''' inputed = 'a' output = leading.leading_substrings(inputed) output_expected = ['a'] self.assertEqual(output, output_expected, 'The string is of length 1.')
def test_leading_sub_empty(self): '''Tests empty string''' input = '' output_expected = [] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, 'No characters')
def test_leading_sub_two(self): '''Tests for two characters''' input = 'hi' output_expected = ['h', 'hi'] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, 'Two characters')
def test_leading_sub_double_extra_space(self): '''Tests for one extra space at the beginning and end''' input = ' test ' output_expected = [' ', ' t', ' te', ' tes', ' test', ' test '] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, 'Space beginning and end')
def test_leading_sub_one(self): '''Tests for one character''' input = 'a' output_expected = ['a'] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, 'One character')
def test_empty(self): '''Test an empty string.''' input = "" output_expected = [] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, "Empty string.")
def justspaces(self): '''Test when 4 spaces string''' input = " " output_expected = [" ", " ", " ", " "] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, "Only spaces case.")
def test_two_char(self): '''Test when two letter string''' input = "ab" output_expected = ["a", "ab"] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, "Two letter case.")
def test_one_char(self): '''Test when one letter string''' input = "a" output_expected = ["a"] output = leading.leading_substrings(input) self.assertEqual(output_expected, output, "One letter case.")