public void OnlyOneMatchAttheEnd() { string target = "CAABRABRADARCADRCADA"; PatternFinder finder = new PatternFinder("CADA", SearchOptions.Raita); var result = finder.Find(target); // Assert.IsTrue(result.IsMatch); Assert.IsTrue(result.Index == 16); while (result.IsMatch) { result = result.Next(); Assert.IsFalse(result.IsMatch); } }
public void OnlyOneMatchAtTheMiddle() { string target = "CAABRABRADARCCADAADR"; PatternFinder finder = new PatternFinder("CADA", SearchOptions.TunedBM); var result = finder.Find(target); // Assert.IsTrue(result.IsMatch); Assert.IsTrue(result.Index == 13); while (result.IsMatch) { result = result.Next(); Assert.IsFalse(result.IsMatch); } }
public void OnlyOneMatchAtfirstIndex() { string target = "CADACAABRABRADARCADR"; PatternFinder finder = new PatternFinder("CADA", SearchOptions.Sunday); var result = finder.Find(target); // Assert.IsTrue(result.IsMatch); Assert.IsTrue(result.Index == 0); while (result.IsMatch) { result = result.Next(); Assert.IsFalse(result.IsMatch); } }
public void TestMoreThanOneWildCard() { string target = "ABRACADABRA"; PatternFinder finder = new PatternFinder("??BR", SearchOptions.Wildcard); var result = finder.Find(target); List<int> matches = new List<int>(); List<string> patterns = new List<string>(); while (result.IsMatch) { matches.Add(result.Index); result = result.Next(); } Assert.IsTrue(matches.Count == 1); Assert.IsTrue(matches[0] == 6); }
public void MultipleMatches() { string target = "CADACADACAABRABRADARCCADAADRCADA"; PatternFinder finder = new PatternFinder("CADA", SearchOptions.Raita); var result = finder.Find(target); List<int> maches = new List<int>(); while (result.IsMatch) { maches.Add(result.Index); result = result.Next(); } Assert.IsTrue(maches.Count == 4); Assert.IsTrue(maches[0] == 0); Assert.IsTrue(maches[1] == 4); Assert.IsTrue(maches[2] == 21); Assert.IsTrue(maches[3] == 28); }
public void FindMatch() { PatternFinder pf = new PatternFinder(new string[] { "a", "ab", "bab", "bc", "bca", "c", "caa" }); ISearchResult results = pf.Find("abccab"); //Assert.IsTrue(results.Length == 7); List<ISearchResult> list = new List<ISearchResult>(); while (results.IsMatch) { list.Add(results); results = results.Next(); } Assert.IsTrue(list.Count() == 7); Assert.IsTrue(list[0].Index == 0); Assert.IsTrue(list[1].Index == 0); Assert.IsTrue(list[2].Index == 1); Assert.IsTrue(list[3].Index == 2); Assert.IsTrue(list[4].Index == 3); Assert.IsTrue(list[5].Index == 4); Assert.IsTrue(list[6].Index == 4); }
public void TargetWithEmptySpaces() { string target = "ACCAD AAABRABRADARCCADA ADRCADA"; PatternFinder finder = new PatternFinder("CADA", SearchOptions.Raita); var result = finder.Find(target); List<int> maches = new List<int>(); while (result.IsMatch) { maches.Add(result.Index); result = result.Next(); } Assert.IsTrue(maches.Count == 2); Assert.IsTrue(maches[0] == 19); Assert.IsTrue(maches[1] == 27); }