Ejemplo n.º 1
0
 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));
     }
 }
Ejemplo n.º 2
0
        private void VerifyReplace(VimRegexOptions options, string pattern, string input, string replace, string result)
        {
            var regex = VimRegexFactory.Create(pattern, options);

            Assert.IsTrue(regex.IsSome());

            var noMagic     = VimRegexOptions.NoMagic == (options & VimRegexOptions.NoMagic);
            var replaceData = new ReplaceData(Environment.NewLine, !noMagic, 1);

            Assert.AreEqual(result, regex.Value.ReplaceAll(input, replace, replaceData));
        }
Ejemplo n.º 3
0
        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));
            }
        }
Ejemplo n.º 4
0
            private void VerifyReplace(VimRegexOptions options, string pattern, string input, string replace, string result, VimRegexReplaceCount count = null)
            {
                count = count ?? VimRegexReplaceCount.All;
                var regex = VimRegexFactory.Create(pattern, options);

                Assert.True(regex.IsSome());

                var noMagic     = VimRegexOptions.NoMagic == (options & VimRegexOptions.NoMagic);
                var replaceData = new VimRegexReplaceData(Environment.NewLine, !noMagic, count);

                Assert.Equal(result, regex.Value.Replace(input, replace, replaceData, _registerMap));
            }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        private static void VerifyRegex(VimRegexOptions options, string vimPattern, string regexPattern)
        {
            var vimRegex = VimRegexFactory.Create(vimPattern, options).AssertSome();

            Assert.Equal(regexPattern, vimRegex.RegexPattern);
        }
Ejemplo n.º 7
0
            private void VerifyReplace(VimRegexOptions options, string pattern, string input, string replace, string result, VimRegexReplaceCount count = null)
            {
                count = count ?? VimRegexReplaceCount.All;
                var regex = VimRegexFactory.Create(pattern, options);
                Assert.True(regex.IsSome());

                var noMagic = VimRegexOptions.NoMagic == (options & VimRegexOptions.NoMagic);
                var replaceData = new VimRegexReplaceData(Environment.NewLine, !noMagic, count);
                Assert.Equal(result, regex.Value.Replace(input, replace, replaceData, _registerMap));
            }
Ejemplo n.º 8
0
        private void VerifyReplace(VimRegexOptions options, string pattern, string input, string replace, string result)
        {
            var regex = VimRegexFactory.Create(pattern, options);
            Assert.IsTrue(regex.IsSome());

            var noMagic = VimRegexOptions.NoMagic == (options & VimRegexOptions.NoMagic);
            var replaceData = new ReplaceData(Environment.NewLine, !noMagic, 1);
            Assert.AreEqual(result, regex.Value.ReplaceAll(input, replace, replaceData));
        }