Exemplo n.º 1
0
        public void reg_regex_match()
        {
            string src = @"$(\\[^\n\r\t]|[^\n\r\t$\\])*$";
            Dictionary <string, bool> tests = new Dictionary <string, bool> {
                { "$\\\\$", true },
                { "$\\\n$", false },
                { "$\n$", false },
                { "$\\\r\n$", false }
            };

            RegEx.RegEx regex = new RegEx.RegEx(src);

            foreach (var test in tests)
            {
                Assert.AreEqual(regex.Match(test.Key), test.Value);
            }
        }
Exemplo n.º 2
0
        public void reg_plus_match()
        {
            string src = "a+b";
            Dictionary <string, bool> tests = new Dictionary <string, bool> {
                { "b", false },
                { "a", false },
                { "ab", true },
                { "ac", false },
                { "aaabc", false },
                { "aaaab", true }
            };

            RegEx.RegEx regex = new RegEx.RegEx(src);

            foreach (var test in tests)
            {
                Assert.AreEqual(regex.Match(test.Key), test.Value);
            }
        }
Exemplo n.º 3
0
        public void reg_str_match()
        {
            string src = @"L?""(\\(.|\r\n)|[^\n""\\])*""";
            Dictionary <string, bool> tests = new Dictionary <string, bool> {
                { "\"abc\"", true },
                { "\"abc", false },
                { "abc\"", false },
                { "\"\n\"", false },
                { "\"\\\n\"", true },
                { "\"\\\r\n\"", true },
                { "\"ab\r\n\"", false }
            };

            RegEx.RegEx regex = new RegEx.RegEx(src);

            foreach (var test in tests)
            {
                Assert.AreEqual(regex.Match(test.Key), test.Value);
            }
        }
Exemplo n.º 4
0
        public void reg_charset_match()
        {
            string src = "[a-zA-Z_][a-zA-Z0-9_]*";
            Dictionary <string, bool> tests = new Dictionary <string, bool> {
                { "reg_charset_match", true },
                { "src", true },
                { "_Assert", true },
                { "/**/", false },
                { "\\n\\t\\r", false },
                { "0_wrong", false },
                { "__init__", true },
                { "a", true }
            };

            RegEx.RegEx regex = new RegEx.RegEx(src);

            foreach (var test in tests)
            {
                Assert.AreEqual(regex.Match(test.Key), test.Value);
            }
        }
Exemplo n.º 5
0
        public void reg_wild_match()
        {
            string src = "(\\\\.|[^$\\\\])*";
            Dictionary <string, bool> tests = new Dictionary <string, bool> {
                { "\\a", true },
                { "abc", true },
                { "\\\n", true },
                { "\\1", true },
                { "\\,", true },
                { "\\&", true },
                { "\\(", true },
                { "\\ad", true },
                { "\\acc", true }
            };

            RegEx.RegEx regex = new RegEx.RegEx(src);

            foreach (var test in tests)
            {
                Assert.AreEqual(regex.Match(test.Key), test.Value);
            }
        }