Beispiel #1
0
        public void CanConstructTree()
        {
            var sut = new AlphabetTrie();

            sut.Insert("abba");
            sut.Insert("abca");
            sut.Insert("bbca");
            sut.Insert("bbcz");
        }
Beispiel #2
0
        public void CanSearchInTree()
        {
            var sut = new AlphabetTrie();

            sut.Insert("there");
            sut.Insert("answer");
            sut.Insert("bye");
            sut.Insert("any");

            Assert.True(sut.Search("any"));
            Assert.False(sut.Search("anz"));
        }
Beispiel #3
0
        public void CanDelete()
        {
            var sut = new AlphabetTrie();

            //sut.Insert("there");
            sut.Insert("answer");
            sut.Insert("bye");
            sut.Insert("any");

            Assert.True(sut.Search("any"));
            Assert.True(sut.Search("answer"));

            sut.Delete("any");
            sut.Delete("bye");

            Assert.False(sut.Search("any"));
            Assert.True(sut.Search("answer"));
            Assert.False(sut.Search("bye"));
        }
Beispiel #4
0
        public void CanDeleteRoot()
        {
            var sut = new AlphabetTrie();

            sut.Insert("any");

            Assert.True(sut.Search("any"));

            sut.Delete("any");

            Assert.False(sut.Search("any"));
        }