# CS122: Auto-completing keyboard using Tries # # Tests for your trie implementation # # YOUR NAME HERE from trie_dict import create_trie_node, add_word, is_word, num_completions, get_completions t = create_trie_node() add_word("a", t) add_word("an", t) add_word("and", t) add_word("are", t) add_word("bee", t) # Write your tests here # Example of an assertion. If "bee" was not inserted # correctly in the trie, the following statement will # cause the program to exit with an error message. assert is_word("bee", t)
def test_add_words(words): t = create_trie_node() for word in words: add_word(word, t) return t
from trie_dict import create_trie_node, add_word, is_word, num_completions, get_completions t = create_trie_node() add_word("a", t) add_word("an", t) add_word("and", t) add_word("ant", t) add_word("ants", t) add_word("andy", t) #print("THE TRIE", t) add_word("are", t) add_word("be", t) add_word("bet", t) add_word("bee", t) add_word("beet", t) add_word("beer", t) add_word("beers", t) #print(t) # Write your tests here # Example of an assertion. If "bee" was not inserted # correctly in the trie, the following statement will # cause the program to exit with an error message. #assert is_word("bee", t) #print(is_word("ar", t)) rv1 = get_completions("an", t) rv2 = get_completions("bee", t) rv3 = get_completions("as", t)
def test_completions(): t = create_trie_node()