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 FindMatchingNullIntSequencesTest() { MinimalDAGSearcher <int?> DagSearcher = new MinimalDAGSearcher <int?>(_nullIntDAG); List <int?> ValuePool = new List <int?>() { 1, 2, 9, 8 }; int?[] ExistingValues = new int?[] { -1, 5, 1, -1, -1 }; var matches = DagSearcher.FindMatchingSequences(ValuePool, new Pattern <int?>(ExistingValues, -1), 0).Select(x => x.MatchingSequence.ToList()).ToList(); var ExpectedMatches = new List <List <int?> >() { new List <int?>() { 5, 1, 9, 8 }, new List <int?>() { 5, 1, 2 } }; NestedSequenceCompare(ExpectedMatches, matches); }
public void FindMatchingEnglishWordsOptionTest() { 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', default(char) }, 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", "izzard", "izzards", }; var Actual = minimalDAGSearcher.FindMatchingSequences(CharPool, new Pattern <char>(existing, default(char)), 6).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) }
public void SimpleBenchmarkTest() { MinimalDAGSearcher <char> minimalDAGSearcher = new MinimalDAGSearcher <char>(_dawg); List <char> CharPool = new List <char>(); var existing = new char[] { default(char), default(char), default(char), default(char), 'e', default(char), default(char), default(char), default(char), default(char), default(char), default(char), default(char), default(char), default(char) }; var Actual = minimalDAGSearcher.FindMatchingSequences(CharPool, new Pattern <char>(existing, default(char)), 14).Select(x => string.Concat(x.MatchingSequence)).ToList(); Assert.IsTrue(Actual.Count > 0); }