private void VerifyReplace(VimRegexOptions options, string pattern, string input, string replace, string result) { var regex = VimRegexFactory.Create(pattern, options); Assert.True(regex.IsSome()); var noMagic = VimRegexOptions.NoMagic == (options & VimRegexOptions.NoMagic); var replaceData = new VimRegexReplaceData(Environment.NewLine, !noMagic, VimRegexReplaceCount.All); Assert.Equal(result, regex.Value.Replace(input, replace, replaceData)); }
private void VerifyNotMatches(VimRegexOptions options, string pattern, params string[] inputArray) { var opt = VimRegexFactory.Create(pattern, options); Assert.True(opt.IsSome()); var regex = opt.Value; foreach (var cur in inputArray) { Assert.False(regex.IsMatch(cur)); } }
private void VerifyMatchesAt(VimRegexOptions options, string pattern, string input, params Tuple <int, int>[] spans) { var opt = VimRegexFactory.Create(pattern, options); Assert.True(opt.IsSome()); var regex = opt.Value; var matches = regex.Regex.Matches(input); var count = matches.Cast <object>().Count(); Assert.Equal(count, spans.Length); for (int i = 0; i < count; i++) { var position = spans[i].Item1; var length = spans[i].Item2; var match = matches[i]; Assert.Equal(position, match.Index); Assert.Equal(length, match.Length); } }
private static void VerifyRegex(VimRegexOptions options, string vimPattern, string regexPattern) { var vimRegex = VimRegexFactory.Create(vimPattern, options).AssertSome(); Assert.Equal(regexPattern, vimRegex.RegexPattern); }
private FSharpOption <VimRegex> Create(string pattern) { return(VimRegexFactory.CreateForSettings(pattern, _globalSettings)); }
public void Setup() { _settings = new Vim.GlobalSettings(); _settings.IgnoreCase = true; _settings.SmartCase = false; _factory = new VimRegexFactory(_settings); }