public void ContainsForPrecomputedHashes()
        {
            string s = "thequickredfoxjumpedoverthelazybrowndog";
            var    precomputedHashes = new PrecomputedHashes(s);

            Assert.True(precomputedHashes.AllExistAsSubstrings(new[] { "azy", "own", "dog", "la", "br", "fox", "thequick" }));
            Assert.True(precomputedHashes.AllExistAsSubstrings(new[] { "lazybrowndog", "azybrowndog", "zybrowndog", "ybrowndog" }));
            Assert.True(precomputedHashes.AllExistAsSubstrings(new[] { "l", "g", "a", "o" }));
        }
        public void PerformanceComparisonSmallString()
        {
            string s = "smallstring";

            string[] t                 = { "small", "mall", "string", "str", "lls" };
            var      suffixTree        = new SuffixTree(s);
            var      precomputedHashes = new PrecomputedHashes(s);

            PerformanceHelper.PerformanceTestAction(() => suffixTree.AllExistAsSubstrings(t), "SuffixTree small string");
            PerformanceHelper.PerformanceTestAction(() => SearchUsingStringContains(s, t), "String.Contains small string");
            PerformanceHelper.PerformanceTestAction(() => precomputedHashes.AllExistAsSubstrings(t), "PrecomputedHashes small string");
        }
        public void DoesNotContainForForPrecomputedHashes()
        {
            string s = "thequickredfoxjumpedoverthelazybrowndog";
            var    precomputedHashes = new PrecomputedHashes(s);

            Assert.False(precomputedHashes.AllExistAsSubstrings(new[] { "purple" }));
            Assert.False(precomputedHashes.AllExistAsSubstrings(new[] { "mountain" }));
            Assert.False(precomputedHashes.AllExistAsSubstrings(new[] { "majesties" }));

            Assert.False(precomputedHashes.AllExistAsSubstrings(new[] { "thequickrd" }));
            Assert.False(precomputedHashes.AllExistAsSubstrings(new[] { "dogm" }));
            Assert.False(precomputedHashes.AllExistAsSubstrings(new[] { "thequickredfoxjumpedoverthelazybrowndog " }));
        }
        public void PerformanceComparisonLongString()
        {
            string s = "thequickredfoxjumpedoverthelazybrowndogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethistext";

            string[] t =
            {
                "redfoxjumpedovert",                                                                                                                                                   "azybrow", "ndogandthatishowyoudoi", "quickredfoxjum", "oudoitdontyoukn", "otcoman", "useawebbrows",
                "thequickredfoxjumpedoverthelazybrowndogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethistex",
                "quickredfoxjumpedoverthelazybrowndogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethistext",
                "ogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethist"
            };

            var suffixTree        = new SuffixTree(s);
            var precomputedHashes = new PrecomputedHashes(s);
            int numTimes          = 100000;

            PerformanceHelper.PerformanceTestAction(() => suffixTree.AllExistAsSubstrings(t), "SuffixTree long string", numTimes);
            PerformanceHelper.PerformanceTestAction(() => SearchUsingStringContains(s, t), "String.Contains long string", numTimes);
            PerformanceHelper.PerformanceTestAction(() => precomputedHashes.AllExistAsSubstrings(t), "String.Contains long string", numTimes);
        }