Esempio n. 1
0
        public void MatchCaseInsensitive_StringOverLongStringToMatch()
        {
            var value = new ValueCursor("x");

            Assert.True(value.MoveNext());
            Assert.False(value.MatchCaseInsensitive("long string", CultureInfo.InvariantCulture.CompareInfo, true));
            ValidateCurrentCharacter(value, 0, 'x');
        }
Esempio n. 2
0
        public void MatchCaseInsensitive_StringNotMatched()
        {
            var value = new ValueCursor("xabcdef");

            Assert.True(value.MoveNext(), "GetNext() 1");
            Assert.False(value.MatchCaseInsensitive("abc", CultureInfo.InvariantCulture.CompareInfo, true));
            ValidateCurrentCharacter(value, 0, 'x');
        }
Esempio n. 3
0
        public void MatchCaseInsensitive_MatchAndMove()
        {
            var value = new ValueCursor("abcd");

            Assert.True(value.MoveNext(), "GetNext() 1");
            Assert.True(value.MatchCaseInsensitive("AbC", CultureInfo.InvariantCulture.CompareInfo, true));
            ValidateCurrentCharacter(value, 3, 'd');
        }
Esempio n. 4
0
        public void MatchCaseInsensitive_MatchWithoutMoving()
        {
            var value = new ValueCursor("abcd");

            Assert.True(value.MoveNext(), "GetNext() 1");
            Assert.True(value.MatchCaseInsensitive("AbC", CultureInfo.InvariantCulture.CompareInfo, false));
            // We're still looking at the start
            ValidateCurrentCharacter(value, 0, 'a');
        }
Esempio n. 5
0
 /// <summary>
 /// Find the longest match from a given set of candidate strings, updating the index/length of the best value
 /// accordingly.
 /// </summary>
 private static void FindLongestMatch(CompareInfo compareInfo, ValueCursor cursor, IReadOnlyList <string> values, ref int bestIndex, ref int longestMatch)
 {
     for (int i = 0; i < values.Count; i++)
     {
         string candidate = values[i];
         if (candidate is null || candidate.Length <= longestMatch)
         {
             continue;
         }
         if (cursor.MatchCaseInsensitive(candidate, compareInfo, false))
         {
             bestIndex    = i;
             longestMatch = candidate.Length;
         }
     }
 }