Пример #1
0
        public void TryParseRangeTest0()
        {
            int    pos = 0;
            string characters;

            Assert.IsTrue(RegexParser.TryParseRange("[A]", ref pos, out characters));
            Assert.AreEqual(3, pos);
            Assert.AreEqual("A", characters);

            pos = 0;
            Assert.IsTrue(RegexParser.TryParseRange("[A-C]", ref pos, out characters));
            Assert.AreEqual(5, pos);
            Assert.AreEqual("ABC", characters);

            pos = 0;
            Assert.IsTrue(RegexParser.TryParseRange("[0A-C9]", ref pos, out characters));
            Assert.AreEqual(7, pos);
            Assert.AreEqual("09ABC", characters);

            pos = 0;
            Assert.IsTrue(RegexParser.TryParseRange("[0A-]", ref pos, out characters));
            Assert.AreEqual(5, pos);
            Assert.AreEqual("-0A", characters);

            pos = 0;
            Assert.IsTrue(RegexParser.TryParseRange(@"[\]]", ref pos, out characters));
            Assert.AreEqual(4, pos);
            Assert.AreEqual("]", characters);
        }
Пример #2
0
        public void TryParseRangeTest1()
        {
            int    pos = 0;
            string characters;

            Assert.IsFalse(RegexParser.TryParseRange(null, ref pos, out characters));
            Assert.AreEqual(0, pos);

            Assert.IsFalse(RegexParser.TryParseRange(string.Empty, ref pos, out characters));
            Assert.AreEqual(0, pos);

            Assert.IsFalse(RegexParser.TryParseRange("A", ref pos, out characters));
            Assert.AreEqual(0, pos);
        }
Пример #3
0
 public void TryParseRangeTest5()
 {
     try
     {
         int    pos = 0;
         string characters;
         Assert.IsFalse(RegexParser.TryParseRange("[]", ref pos, out characters));
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual(
             new ArgumentException(string.Format(
                                       CultureInfo.InvariantCulture,
                                       Properties.Resources.E_InvalidRegex_RangeIsEmpty,
                                       "[]",
                                       1)).Message,
             e.Message);
         throw;
     }
 }