MCPcopy
hub / github.com/TheAlgorithms/Python / test_trie

Function test_trie

data_structures/trie/trie.py:92–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90
91
92def test_trie() -> bool:
93 words = "banana bananas bandana band apple all beast".split()
94 root = TrieNode()
95 root.insert_many(words)
96 # print_words(root, "")
97 assert all(root.find(word) for word in words)
98 assert root.find("banana")
99 assert not root.find("bandanas")
100 assert not root.find("apps")
101 assert root.find("apple")
102 assert root.find("all")
103 root.delete("all")
104 assert not root.find("all")
105 root.delete("banana")
106 assert not root.find("banana")
107 assert root.find("bananas")
108 return True
109
110
111def print_results(msg: str, passes: bool) -> None:

Callers 2

pytestsFunction · 0.70
mainFunction · 0.70

Calls 5

insert_manyMethod · 0.95
findMethod · 0.95
deleteMethod · 0.95
TrieNodeClass · 0.85
splitMethod · 0.80

Tested by

no test coverage detected