public void Match_Wildcard_WithIgnoreWhitespace() { RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = false; model.FindOptions.IgnorePunctuationCharacters = false; model.FindOptions.IgnoreWhitespaceCharacters = true; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = false; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = true; model.FindOptions.UseRegularExpressions = false; Hit match; string testText = "this was some text"; match = model.GetNextMatch_FOR_TESTING("th*s was", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(12, match.Length); testText = "this was some text"; match = model.GetNextMatch_FOR_TESTING("this w*s", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(10, match.Length); }
public void Match_Wildcard_WithIgnorePunctuation()//problem is ignore punct will destroy the wildacard in the query, could just not strip it in query?? { RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = false; model.FindOptions.IgnorePunctuationCharacters = true; model.FindOptions.IgnoreWhitespaceCharacters = false; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = false; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = true; model.FindOptions.UseRegularExpressions = false; Hit match; string testText = "this 'was some text"; //Because we cannot remove punct from the query when the match is wildcard or regex, we have to search without it. match = model.GetNextMatch_FOR_TESTING("th*s was", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(9, match.Length); //Because we cannot remove punct from the query when the match is wildcard or regex, we have to search without it. match = model.GetNextMatch_FOR_TESTING("this was", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(9, match.Length); }
public void Match_Blend_WholeWords_Wildcards() { //should essentially match whole words only RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = true; model.FindOptions.IgnorePunctuationCharacters = false; model.FindOptions.IgnoreWhitespaceCharacters = false; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = false; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = true; Hit match; string testText = "this was some text"; match = model.GetNextMatch_FOR_TESTING("th*as", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(8, match.Length); match = model.GetNextMatch_FOR_TESTING("th*a", 0, testText); Assert.AreEqual(-1, match.Start); Assert.AreEqual(0, match.Length); }
public void PunctuationIgnorer_FromModel() { RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = false; model.FindOptions.IgnorePunctuationCharacters = true; Hit match; string testText = "this was-nt some text"; match = model.GetNextMatch_FOR_TESTING("was-nt", 0, testText); Assert.AreEqual(5, match.Start); Assert.AreEqual(6, match.Length); }
public void Match_Regex_WithIgnorePunctuation()//problem is ignore punct will destroy the regex in the query, could just not strip it in query?? { RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = false; model.FindOptions.IgnorePunctuationCharacters = true; model.FindOptions.IgnoreWhitespaceCharacters = false; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = false; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = false; model.FindOptions.UseRegularExpressions = true; Hit match; string testText = "this 'was some text"; match = model.GetNextMatch_FOR_TESTING("th.* was", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(9, match.Length); }
public void Match_Simple_NoOptions() { RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = false; model.FindOptions.IgnorePunctuationCharacters = false; model.FindOptions.IgnoreWhitespaceCharacters = false; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = false; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = false; Assert.AreEqual(-1, model.GetNextMatch_FOR_TESTING("xxx", 0, "this is some text").Start); Assert.AreEqual(13, model.GetNextMatch_FOR_TESTING("text", 0, "this is some text").Start); Assert.AreEqual(13, model.GetNextMatch_FOR_TESTING("tex", 0, "this is some text").Start); Assert.AreEqual(13, model.GetNextMatch_FOR_TESTING("te", 0, "this is some text").Start); Assert.AreEqual(0, model.GetNextMatch_FOR_TESTING("t", 0, "this is some text").Start); Assert.AreEqual(13, model.GetNextMatch_FOR_TESTING("t", 1, "this is some text").Start); Assert.AreEqual(0, model.GetNextMatch_FOR_TESTING("this", 0, "this is some text").Start); Assert.AreEqual(0, model.GetNextMatch_FOR_TESTING("this is some text", 0, "this is some text").Start); }
public void Match_Blend_WholeWords_Prefix() { //should essentially match whole words only RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = true; model.FindOptions.IgnorePunctuationCharacters = false; model.FindOptions.IgnoreWhitespaceCharacters = false; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = true; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = false; Assert.AreEqual(-1, model.GetNextMatch_FOR_TESTING("xxx", 0, "this is some text").Start); Assert.AreEqual(13, model.GetNextMatch_FOR_TESTING("text", 0, "this is some text").Start); Assert.AreEqual(13, model.GetNextMatch_FOR_TESTING("Text", 0, "this is some text").Start); Assert.AreEqual(0, model.GetNextMatch_FOR_TESTING("this", 0, "this is some text").Start); Assert.AreEqual(-1, model.GetNextMatch_FOR_TESTING("thi", 0, "this is some text").Start); Assert.AreEqual(8, model.GetNextMatch_FOR_TESTING("thi", 0, "this is thi thi").Start); Assert.AreEqual(12, model.GetNextMatch_FOR_TESTING("thi", 9, "this is thi thi").Start); Assert.AreEqual(0, model.GetNextMatch_FOR_TESTING("this is some text", 0, "this is some text").Start); }
public void Match_Regex() { RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.FindWholeWordsOnly = false; model.FindOptions.IgnorePunctuationCharacters = false; model.FindOptions.IgnoreWhitespaceCharacters = false; model.FindOptions.MatchCase = false; model.FindOptions.MatchPrefix = false; model.FindOptions.MatchSuffix = false; model.FindOptions.UseWildcards = false; model.FindOptions.UseRegularExpressions = true; Hit match; string testText = "this was some text"; match = model.GetNextMatch_FOR_TESTING("th.*as", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(8, match.Length); match = model.GetNextMatch_FOR_TESTING("th.*", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(18, match.Length); match = model.GetNextMatch_FOR_TESTING("th.*xt", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(18, match.Length); match = model.GetNextMatch_FOR_TESTING("t.*xt", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(18, match.Length); match = model.GetNextMatch_FOR_TESTING("th.*as", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(8, match.Length); match = model.GetNextMatch_FOR_TESTING("xt.*a", 0, testText); Assert.AreEqual(-1, match.Start); Assert.AreEqual(0, match.Length); match = model.GetNextMatch_FOR_TESTING(".*as", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(8, match.Length); match = model.GetNextMatch_FOR_TESTING(".*.*.*", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(18, match.Length); testText = "this was some text\r\nxxxx yyy"; //Go with VS behaviour, which is !SingleLine mode (ie . cannot eat \n) match = model.GetNextMatch_FOR_TESTING("text.*yyy", 0, testText); Assert.AreEqual(-1, match.Start); Assert.AreEqual(0, match.Length); testText = "This was SOME text\r\nxxxx yyy"; model.FindOptions.MatchCase = true; match = model.GetNextMatch_FOR_TESTING("th[a-z]s", 0, testText); Assert.AreEqual(-1, match.Start); Assert.AreEqual(0, match.Length); model.FindOptions.MatchCase = true; match = model.GetNextMatch_FOR_TESTING("Th[a-z]s", 0, testText); Assert.AreEqual(0, match.Start); Assert.AreEqual(4, match.Length); model.FindOptions.MatchCase = true; match = model.GetNextMatch_FOR_TESTING("S.*E", 0, testText); Assert.AreEqual(9, match.Start); Assert.AreEqual(4, match.Length); }