Example #1
0
        public void NumberRangeTest()
        {
            new Regex($"^(?:{RegexUtility.NumberRange(1, 100)})$").Then(_ =>
            {
                AssertNumberRangeTrue(_, new[] { 1, 9, 10, 19, 20, 29, 99 });
                AssertNumberRangeFalse(_, new[] { 0, 101 });
            });

            new Regex($"^(?:{RegexUtility.NumberRange(12, 23)})$").Then(_ =>
            {
                AssertNumberRangeTrue(_, new[] { 12, 19, 21, 22, 23 });
                AssertNumberRangeFalse(_, new[] { 0, 101 });
            });

            new Regex($"^(?:{RegexUtility.NumberRange(123, 123)})$").Then(_ =>
            {
                AssertNumberRangeTrue(_, new[] { 123 });
                AssertNumberRangeFalse(_, new[] { 122, 124, 12, 2000 });
            });

            new Regex($"^(?:{RegexUtility.NumberRange(124, 123)})$").Then(_ =>
            {
                AssertNumberRangeFalse(_, new[] { 122, 123, 124, 12, 2000 });
            });
        }