Esempio n. 1
0
 def test_case_insensitive_search(self):
     trie = Trie()
     word = "apple"
     trie.add_word(word)
     assert trie.search_word(word.title())
     assert trie.search_word(word.upper())
     assert trie.search_word(word.lower())
Esempio n. 2
0
    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")
Esempio n. 3
0
    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)
Esempio n. 4
0
    def test_load_file_contents(self):
        trie = Trie()
        for fname in loadArtifacts.get_dictionary_test_files():
            trie.load_file_contents(fname)

        assert trie.search_word("aardvarks")
Esempio n. 5
0
 def test_case_sensitive_search(self):
     trie = Trie(is_case_sensitive=True)
     word = "Apple"
     trie.add_word(word)
     assert not trie.search_word(word.upper())
     assert not trie.search_word(word.lower())
Esempio n. 6
0
 def test_is_word_false_missing_word(self):
     trie = Trie()
     missing_word = "cat"
     assert not trie.search_word(missing_word)
Esempio n. 7
0
 def test_add_word_search_word(self):
     trie = Trie()
     trie.add_word("Apple")
     trie.add_word("Bat")
     assert trie.search_word("Apple")
     assert trie.search_word("Bat")