def test_add_two_words_remove_word(self): trie = Trie() trie.add_word("Apple") trie.add_word("Bat") assert trie.search_word("Apple") trie.remove_word("Apple") assert not trie.search_word("Apple") assert trie.search_word("Bat")
def test_add_overlapping_words_remove_long_word(self): trie = Trie() short_word = "Apple" long_word = "Applebees" trie.add_word(short_word) trie.add_word(long_word) assert trie.search_word(short_word) assert trie.search_word(long_word) trie.remove_word(long_word) assert not trie.search_word(long_word) assert trie.search_word(short_word)
def test_remove_not_a_word(self): trie = Trie() word = "application" not_a_word = "app" trie.add_word(word) assert not trie.remove_word(not_a_word)
def test_remove_non_existent_word(self): trie = Trie() non_existent_word = "abcd" trie.add_word("app") assert not trie.remove_word(non_existent_word)