def test_storage_of_words_with_almost_equal_elements(self): trie = Trie() # Add a single word to it words = ['eGonn', 'yUrAAc', 'MirrrVa', 'eGonnn', 'yUrAc', 'MirVaaa', 'eGonnnnnnn', 'yUrAaaaaaac', 'MirVa'] for word in words: trie.add_the_word_letter_by_letter(word) assert trie.contains('egon') is False assert trie.contains('yuraaaac') is False assert trie.contains('mirrva') is False assert trie.contains('egonn') is True assert trie.contains('yurac') is True assert trie.contains('mirva') is True assert trie.contains('egonnnnnnnn') is False assert trie.contains('yuraAaaaaaac') is False assert trie.contains('mirvaa') is False assert trie.contains('egonnnnnn') is True assert trie.contains('yurac') is True assert trie.contains('mirva') is True
def test_single_item_trie_add_the_word_letter_by_letter_contains(self): # Create a trie trie = Trie() # Add a single word to it trie.add_the_word_letter_by_letter('egon') # Make sure the trie contains each word inserted assert trie.contains('egon') is True assert trie.contains('eGoN') is True assert trie.contains('egoN') is True
def test_single_item_trie_add_the_word_letter_by_letter_contains(self): # Create a trie trie = Trie() # Add a single word to it words = ['eGonn', 'yUrAc', 'MirVa'] for word in words: trie.add_the_word_letter_by_letter('egon') assert trie.contains('egonn') is True assert trie.contains('yurac') is True assert trie.contains('mirva') is True
def test_add_the_word_letter_by_letter_and_contains_on_medium_trie(self): # Create a trie trie = Trie() # Does it make a distinction with caps lock words = ['egon', 'yurac', 'mirva', 'al', 'mathew'] for word in words: trie.add_the_word_letter_by_letter(word) # Make sure the trie contains each word inserted for word in words: assert trie.contains(word) is True # Make sure the trie does not contain another word assert trie.contains('word not in list') is False assert trie.contains('juan') is False
def test_add_the_word_letter_by_letter_and_contains_with_capital_letter(self): # Create a trie trie = Trie() # Does it make a distinction with caps lock words = ['eGon', 'yurAc', 'mIrva', 'al', 'matThEw', 'DafF'] for word in words: trie.add_the_word_letter_by_letter(word) # Make sure the trie contains each word inserted for word in words: assert trie.contains(word) is True # Make sure the trie does not contain another word assert trie.contains('word not in list') is False assert trie.contains('egon') is True assert trie.contains('EgOn') is True assert trie.contains('juan') is False
def test_contains_with_absent_word(self): trie = Trie() assert trie.contains('Egon') == False
def test_contains_on_empty_trie(self): trie = Trie() assert trie.contains('') == True