Exemplo n.º 1
0
        private static void TestOnDemand(string input, string pattern, bool shouldPass, bool caseSensitive)
        {
            string because = string.Format(
                "\"{0}\" -{1}{2}like \"{3}\" (OnDemand)",
                input,
                caseSensitive ? 'c' : 'i',
                shouldPass ? "" : "not",
                pattern);

            ValueWildcardOptions options = caseSensitive
                ? ValueWildcardOptions.Ordinal
                : ValueWildcardOptions.InvariantIgnoreCase;

            if (shouldPass)
            {
                Assert.True(
                    ValueWildcardPattern.IsMatch(
                        input,
                        pattern,
                        options),
                    because);
                return;
            }

            Assert.False(
                ValueWildcardPattern.IsMatch(
                    input,
                    pattern,
                    options),
                because);
        }
        public void LongAnyOfPart()
        {
            // When combining partial instructions, a very large AnyOf that
            // must be broken up due to escapes can cause allocation.
            var pattern = "[a`" + new string('c', 0x200) + "]";

            Assert.True(ValueWildcardPattern.IsMatch("c", pattern));
        }
 public void MoreInstructionsThanEstimated()
 {
     // A stackalloc buffer is pass to the parser based on an estimate
     // of characters per instruction. If there are more instructions
     // than the average, StackLoadedValueList will allocate.
     Assert.True(
         ValueWildcardPattern.IsMatch(
             "testing",
             "???????"));
 }