コード例 #1
0
        public void GetMatchesFindsNoMatchesForEmpty()
        {
            LookAheadExpression<char> expression = new LookAheadExpression<char> (m_any);

             var matches = expression.GetMatches (EmptyList, 0);

             Assert.AreEqual (0, matches.Count (), "Count");
        }
コード例 #2
0
        public void GetMatchesFindsOneMatchForA()
        {
            LookAheadExpression<char> expression = new LookAheadExpression<char> (m_a);

             string [] expectedValues = new [] {""};
             int index = 0;
             var list = AList;
             var matches = expression.GetMatches (list, index).ToList ();

             Assert.AreEqual (expectedValues.Length, matches.Count (), "Count");

             for (int i = 0; i < expectedValues.Length; i++)
             {
            var match = matches [i];
            var expected = expectedValues [i];
            Assert.AreEqual (index, match.Index, "match.Index");
            Assert.AreEqual (expected.Length, match.Length, "match.Length");
            Assert.IsTrue (match.Success, "match.Success");
            Assert.AreEqual (expected.Length, match.Items.Count, "match.Items.Count");
            Assert.AreEqual (expected, new string (match.Items.ToArray ()), "match.Items");
             }
        }
コード例 #3
0
 public void ConstructorThrowArgumentNullExceptionForNullArray()
 {
     var expression = new LookAheadExpression<char> ((IExpression<char>) null);
 }
コード例 #4
0
 public void ConstructorSucceeds()
 {
     var expression = new LookAheadExpression<char> (m_a);
      Assert.IsFalse (expression.Negate);
 }
コード例 #5
0
        public void IsMatchAt9Of_LookAhead_Greedy_Any_2_ForDigetsReturnsFalse()
        {
            int index = 9;
             LookAheadExpression<char> expression = new LookAheadExpression<char> (new GreedyRepeatExpression<char> (m_any, 2));
             int length = 0;

             var list = DigetsList;
             var ml = expression.IsMatchAt (list, index);
             Assert.IsFalse (ml.Success, "isMatch");
             Assert.AreEqual (length, ml.Length, "assertionLength");
        }
コード例 #6
0
        public void GetPossibleMatchLengthsReturnsNoneForNone()
        {
            var expression =
            new LookAheadExpression<char> (
               new MockExpression<char> {AnyLength = false, PossibleMatchLengths = new int[0], SupportsLookBack = true});

             var actual = expression.GetPossibleMatchLengths (100).ToList ();
             Assert.AreEqual (0, actual.Count, "Count");
        }
コード例 #7
0
        public void GetPossibleMatchLengthsReturns0ForTwoThreeFive()
        {
            var expression =
            new LookAheadExpression<char> (
               new MockExpression<char> {AnyLength = false, PossibleMatchLengths = new []{2,3,5}, SupportsLookBack = true});

             var actual = expression.GetPossibleMatchLengths (100).ToList ();
             Assert.AreEqual (1, actual.Count, "Count");
             Assert.AreEqual (0, actual[0], "value at [0]");
        }