| 90 | |
| 91 | |
| 92 | def 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 | |
| 111 | def print_results(msg: str, passes: bool) -> None: |