public void TestBasicAdd() { const String characters = "LELoHP"; var table = new Trie(characters); table.Add("HELLO"); table.Add("HELL"); table.Add("HELP"); table.Add("PHELP"); Assert.IsTrue(table.Count == 4); var list = table.EnumerateAllWords(); Assert.IsTrue(list.Count == 4); Assert.IsTrue(list.Contains("HELLO")); Assert.IsTrue(list.Contains("HELL")); Assert.IsTrue(list.Contains("HELP")); Assert.IsTrue(list.Contains("PHELP")); }
public void TestEnumerate() { const String characters = "DOUTYA"; var table = new Trie(characters); // Test with none in the table Assert.IsTrue(table.Count == 0); var list = table.EnumerateAllWords(); Assert.IsTrue(list.Count == 0); // Test with one in the table table.Add("Duty"); Assert.IsTrue(table.Count == 1); list = table.EnumerateAllWords(); Assert.IsTrue(list.Count == 1); Assert.IsTrue(list.Contains("Duty")); // Add some more words and test table.Add("Toad"); table.Add("Dot"); table.Add("You"); table.Add("Dat"); table.Add("Tad"); Assert.IsTrue(table.Count == 6); list = table.EnumerateAllWords(); Assert.IsTrue(list.Count == 6); Assert.IsTrue(table.Contains("Toad")); Assert.IsTrue(table.Contains("Dot")); Assert.IsTrue(table.Contains("Dat")); Assert.IsTrue(table.Contains("You")); Assert.IsTrue(table.Contains("Tad")); }