Ejemplo n.º 1
0
        public void IPRangeTest()
        {
            new Regex($"^{RegexUtility.IPRange("192.168.1~2.23~34")}$").Then(_ =>
            {
                AssertIPRangeTrue(_, new[] { "192.168.1.23", "192.168.1.29", "192.168.1.30", "192.168.1.34" });
                AssertIPRangeFalse(_, new[] { "192.168.1.22", "192.168.1.35", "192.168.3.30", "192.168.3.34" });
            });

            new Regex($"^{RegexUtility.IPRange("192.*.1~2.23~34")}$").Then(_ =>
            {
                AssertIPRangeTrue(_, new[] { "192.1.1.23", "192.100.1.29", "192.200.1.30", "192.255.1.34" });
                AssertIPRangeFalse(_, new[] { "192.168.1.22", "192.168.1.35", "192.168.3.30", "192.168.3.34" });
            });

            Assert.Throws <FormatException>(() => RegexUtility.IPRange("192.168.1~2"));
            Assert.Throws <FormatException>(() => RegexUtility.IPRange("192.168.256.1"));
            Assert.Throws <FormatException>(() => RegexUtility.IPRange("192.168.1~2.23~256"));
        }