public void InsertAndExistsAndNotExists() { var words = new[] { "Car", "Cat" }; var strEncoder = Encoding.GetEncoding("iso-8859-1"); var sut = new Tries256 <string>(); for (int i = 0; i < words.Length; i++) { var b = strEncoder.GetBytes(words[i]); sut.Insert(b, words[i]); } for (int i = 0; i < words.Length; i++) { var b = strEncoder.GetBytes(words[i]); var match = sut.Search(b); Assert.True(match != null && match.CodeWord == words[i]); } var wordsNotExist = new[] { "car", "cat", "tac", "rac", "r", "ca", "catastrophe" }; for (int i = 0; i < wordsNotExist.Length; i++) { var b = strEncoder.GetBytes(wordsNotExist[i]); var match = sut.Search(b); Assert.True(match == null); } }
public void InsertAndCount() { var words = new[] { "Car", "Cat", "Car", "Cat" }; var strEncoder = Encoding.GetEncoding("iso-8859-1"); var sut = new Tries256 <string>(); for (int i = 0; i < words.Length; i++) { var b = strEncoder.GetBytes(words[i]); sut.Insert(b, words[i]); } Assert.True(sut.Count == words.Distinct().Count()); }