Example #1
0
        public void AddingAfterClearingSuffixTree()
        {
            var suffixTree = new SuffixTree();

            var words = new string[]
            {
                "One", "one", "oNe", "two", "hello",
                "test", "here", "there", "?!??!?!?!?",
                "VeryVeryVeryLoooooooooooooooooong",
                ".k[2c3-9024g-u,9weg,ouimwt", "3q2tgwadh",
                "`+rv`+*1v+vt23*1`vt*1v", "!@#)(*^$!%@_",
                "  bum  ", "  bam  ", "  bum  bam  ",
                "1", "12", "123", "1234", "12345", "123456"
            };


            for (int i = 0; i < words.Length; i++)
            {
                if (suffixTree.Contains(words[i]))
                {
                    Assert.Fail();
                }

                suffixTree.Add(words[i]);

                if (!suffixTree.Contains(words[i]))
                {
                    Assert.Fail();
                }
            }

            if (suffixTree.Count != words.Length)
            {
                Assert.Fail();
            }

            suffixTree.Clear();

            if (suffixTree.Count != 0)
            {
                Assert.Fail();
            }

            for (int i = 0; i < words.Length; i++)
            {
                if (suffixTree.Contains(words[i]))
                {
                    Assert.Fail();
                }

                suffixTree.Add(words[i]);

                if (!suffixTree.Contains(words[i]))
                {
                    Assert.Fail();
                }
            }

            Assert.IsTrue(suffixTree.Count == words.Length);
        }