public void ContainingIndexTest() { MinimalDAGSearcher <char> minimalDAGSearcher = new MinimalDAGSearcher <char>(_dawg); List <char> CharPool = new List <char>() { 'a', 's', 'd', 'o' }; /*{ '*', '*', '*', '*', '*', '*' };*/ var existing = new char[] { default(char), default(char), default(char), 'i', 'z', 'z', 'a', 'r', default(char), default(char), 'd', default(char) }; var ExpectedMatches = new List <string>() { "do", "ado", "ad", "ads", "add", "odd", "od", "ods", "oda" }; var contians = _dawg.Contains("ado"); List <string> Actual = new List <string>(); for (int i = 0; i < 1000; i++) { Actual = minimalDAGSearcher.FindMatchingSequencesContainingIndex(CharPool, new Pattern <char>(existing, default(char)), 0, 10).Select(x => string.Concat(x.MatchingSequence)).ToList(); } CollectionAssert.AreEquivalent(ExpectedMatches, Actual); }
public void ContainingPossibleIndexTest() { MinimalDAGSearcher <char> minimalDAGSearcher = new MinimalDAGSearcher <char>(_dawg); List <char> CharPool = new List <char>(); //var existing = new char[] { default(char), default(char), default(char), 'i', 'z', 'z', 'a', 'r', default(char), default(char), default(char) }; var existing = new HashSet <char>[] { null, null, new HashSet <char>() { 'l', 'g' }, new HashSet <char>() { 'i' }, new HashSet <char>() { 'z' }, new HashSet <char>() { 'z' }, new HashSet <char>() { 'a' }, new HashSet <char>() { 'r' }, null, null, null }; var ExpectedMatches = new List <string>() { "blizzard", "blizzardly", "blizzards", "blizzardy", "gizzard", "gizzards", }; var Actual = minimalDAGSearcher.FindMatchingSequencesContainingIndex(CharPool, new Pattern <char>(existing, default(char)), 6, 2).Select(x => string.Concat(x.MatchingSequence)).ToList(); CollectionAssert.AreEquivalent(ExpectedMatches, Actual); }
public void IndexBlankTest() { List <char> pool = new List <char>() { 't', 'h', 'y', 'k', 'd', 'l' }; int BlankCount = 1; char[] existing = new char[] { '\0', '\0', 'e', 'a', '\0', '\0', '\0', 's', 'e', 'i', 'z', 'o', 'r', '\0', '\0' }; MinimalDAGSearcher <char> minimalDAGSearcher = new MinimalDAGSearcher <char>(_dawg); var results = minimalDAGSearcher.FindMatchingSequencesContainingIndex(pool, new Pattern <char>(existing, default(char)), BlankCount, 2).ToList(); Assert.IsTrue(results.Count > 0); //FindMatchingSequencesContainingIndex(IEnumerable<T> valuePool, T[] existingValues, T emptyValue, int wildCardCount, int index) }