示例#1
0
 def test_first_index_in_set(self):
     """first_index_in_set should return index of first occurrence """
     vowels = 'aeiou'
     s1 = 'ebcua'
     s2 = 'bcbae'
     s3 = ''
     s4 = 'cbd'
     self.assertEqual(first_index_in_set(s1, vowels), 0)
     self.assertEqual(first_index_in_set(s2, vowels), 3)
     self.assertEqual(first_index_in_set(s3, vowels), None)
     self.assertEqual(first_index_in_set(s4, vowels), None)
示例#2
0
 def test_first_index_in_set(self):
     """first_index_in_set should return index of first occurrence """
     vowels = 'aeiou'
     s1 = 'ebcua'
     s2 = 'bcbae'
     s3 = ''
     s4 = 'cbd'
     self.assertEqual(first_index_in_set(s1, vowels), 0)
     self.assertEqual(first_index_in_set(s2, vowels), 3)
     self.assertEqual(first_index_in_set(s3, vowels), None)
     self.assertEqual(first_index_in_set(s4, vowels), None)
示例#3
0
 def test_first_index_in_set(self):
     """first_index_in_set should return index of first occurrence """
     vowels = "aeiou"
     s1 = "ebcua"
     s2 = "bcbae"
     s3 = ""
     s4 = "cbd"
     self.assertEqual(first_index_in_set(s1, vowels), 0)
     self.assertEqual(first_index_in_set(s2, vowels), 3)
     self.assertEqual(first_index_in_set(s3, vowels), None)
     self.assertEqual(first_index_in_set(s4, vowels), None)
示例#4
0
 def firstNotInAlphabet(self, sequence, alphabet=None):
     """Returns index of first item not in alphabet, or None.
     
     Defaults to self.Alphabet if alphabet not supplied.
     """
     if alphabet is None:
         alphabet = self.Alphabet
     return first_index_in_set(sequence, alphabet)
示例#5
0
 def firstNotInAlphabet(self, sequence, alphabet=None):
     """Returns index of first item not in alphabet, or None.
     
     Defaults to self.Alphabet if alphabet not supplied.
     """
     if alphabet is None:
         alphabet = self.Alphabet
     return first_index_in_set(sequence, alphabet)
示例#6
0
 def isValidOnAlphabet(self, sequence, alphabet=None):
     """Returns True if sequence contains only items in alphabet.
     
     Alphabet can actually be anything that implements __contains__.
     Defaults to self.Alphabet if not supplied.
     """
     if alphabet is None:
         alphabet = self.Alphabet
     return first_index_in_set(sequence, alphabet) is not None
示例#7
0
 def isValidOnAlphabet(self, sequence, alphabet=None):
     """Returns True if sequence contains only items in alphabet.
     
     Alphabet can actually be anything that implements __contains__.
     Defaults to self.Alphabet if not supplied.
     """
     if alphabet is None:
         alphabet = self.Alphabet
     return first_index_in_set(sequence, alphabet) is not None