예제 #1
0
        public void Negate(char from1, char to1, char from2, char to2)
        {
            var range1 = Range <char> .Create(from1, to1);

            var range2 = Range <char> .Create(from2, to2);

            RangeSet <char> positive = new[] { range1, range2 };
            var             negative = RangeOperations <char> .Negate(positive);

            this.output.WriteLine(string.Join(", ", positive.Expand()));
            this.output.WriteLine(negative.Expand().Count().ToString());
            Assert.NotEqual(positive, negative);
            Assert.Equal(RangeSet <char> .All, positive ^ negative);
            Assert.Equal(RangeSet <char> .All, positive | negative);
            Assert.Equal(RangeSet <char> .Empty, positive & negative);
            Assert.Equal(positive, positive - negative);
            Assert.Equal(negative, negative - positive);
            var negative2 = (range1 == range2) ? ~range1 : ~positive;

            Assert.Equal(negative, negative2);
        }
예제 #2
0
 public static RangeSet <T> operator ~(RangeSet <T> set)
 {
     return(RangeOperations <T> .Negate(set));
 }
예제 #3
0
 public static RangeSet <T> operator ~(Range <T> range)
 {
     return(RangeOperations <T> .Negate(new RangeSet <T>(range)));
 }