Пример #1
0
    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.")
Пример #2
0
    def test_leading_empty(self):
        '''Test an empty list.'''

        output = leading_substrings('')
        output_expected = []

        self.assertEqual(output_expected, output,
                         "'' is decomposed correctly.")
Пример #3
0
 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')
Пример #4
0
 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.')
Пример #5
0
 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.')
Пример #6
0
 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.')
Пример #7
0
 def test_leading_sub_empty(self):
     '''Tests empty string'''
     input = ''
     output_expected = []
     output = leading.leading_substrings(input)
     self.assertEqual(output_expected, output, 'No characters')
Пример #8
0
 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')
Пример #9
0
 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')
Пример #10
0
 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')
Пример #11
0
 def test_empty(self):
     '''Test an empty string.'''
     input = ""
     output_expected = []
     output = leading.leading_substrings(input)
     self.assertEqual(output_expected, output, "Empty string.")
Пример #12
0
 def justspaces(self):
     '''Test when 4 spaces string'''
     input = "    "
     output_expected = [" ", "  ", "   ", "    "]
     output = leading.leading_substrings(input)
     self.assertEqual(output_expected, output, "Only spaces case.")
Пример #13
0
 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.")
Пример #14
0
 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.")