コード例 #1
0
# 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)
コード例 #2
0
def test_add_words(words): 
    t = create_trie_node()
    for word in words: 
        add_word(word, t)
    return t
コード例 #3
0
ファイル: test_trie.py プロジェクト: kwitte2232/CS121
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)
コード例 #4
0
def test_completions(): 
    t = create_trie_node()