public void TestAllKeys() { var words = new[] { "one", "two", "three", "threshing" }; var trie = new PrefixTrie(words); var withPrefixO = trie.AllKeys("o").ToList(); withPrefixO.Should().BeEquivalentTo(new[] { "one" }); var withPrefixTh = trie.AllKeys("th").ToList(); withPrefixTh.Should().BeEquivalentTo(words.Where(w => w.StartsWith("th"))); }
public void TestAllKeys_InvalidPrefix() { var words = new[] { "one", "two", "three", "threshing" }; var trie = new PrefixTrie(words); var withPrefixEmptyString = trie.AllKeys("twofold").ToList(); withPrefixEmptyString.Should().BeEmpty(); }
public void TestAllKeys_EmptyPrefix() { var words = new[] { "one", "two", "three", "threshing" }; var trie = new PrefixTrie(words); var withPrefixEmptyString = trie.AllKeys("").ToList(); withPrefixEmptyString.Should().BeEquivalentTo(words); }