Пример #1
0
        public void CtorTest()
        {
            Should.Throw<ArgumentNullException> (() => new RegexMatchOperation (null), "a1");

            var r = new Regex (".*");
            var op = new RegexMatchOperation (r);
            Assert.AreEqual (r, op.Regex, "a2");
        }
Пример #2
0
        public void SetRegexTest()
        {
            var r = new Regex (".*");
            var op = new RegexMatchOperation (r);
            Assert.AreEqual (r, op.Regex, "a1");

            Should.Throw<ArgumentNullException> (() => op.Regex = null, "a2");

            r = new Regex ("foo");
            op.Regex = r;
            Assert.AreEqual (r, op.Regex, "a3");
        }
Пример #3
0
        public void EmptyRegexTest()
        {
            var r = new Regex ("");
            var op = new RegexMatchOperation (r);
            var col = new DataDictionary ();
            int end;

            bool m = op.IsMatch ("", 0, col, out end);

            Assert.IsTrue (m, "a1");
            Assert.AreEqual (0, end, "a2");
        }
Пример #4
0
        public void SimpleGroupTest()
        {
            var r = new Regex ("-(?<foo>.*?)-");
            var op = new RegexMatchOperation (r);
            var col = new DataDictionary ();
            int end;
            bool m;

            m = op.IsMatch ("-manos-", 0, col, out end);
            Assert.IsTrue (m, "a1");
            Assert.AreEqual (1, col.Count, "a2");
            Assert.AreEqual ("manos", col ["foo"], "a3");
            Assert.AreEqual (7, end, "a4");

            col = new DataDictionary ();
            m = op.IsMatch ("manos-", 0, col, out end);
            Assert.IsFalse (m, "a5");
            Assert.AreEqual (0, col.Count, "a6");
            Assert.AreEqual (0, end, "a7");
        }
Пример #5
0
        public void SimpleRegexTest()
        {
            var r = new Regex (".og");
            var op = new RegexMatchOperation (r);
            var col = new DataDictionary ();
            int end;
            bool m;

            m = op.IsMatch ("dog", 0, col, out end);
            Assert.IsTrue (m, "a1");
            Assert.AreEqual (0, col.Count, "a2");
            Assert.AreEqual (3, end, "a3");

            m = op.IsMatch ("log", 0, col, out end);
            Assert.IsTrue (m, "a4");
            Assert.AreEqual (0, col.Count, "a5");
            Assert.AreEqual (3, end, "a6");

            m = op.IsMatch ("fox", 0, col, out end);
            Assert.IsFalse (m, "a7");
            Assert.AreEqual (0, col.Count, "a8");
            Assert.AreEqual (0, end, "a9");
        }