Пример #1
0
        public void TestSubtractOfOverlappingRangeFromRight() /*throws Exception*/
        {
            IntervalSet s         = IntervalSet.Of(10, 20);
            IntervalSet s2        = IntervalSet.Of(15, 25);
            string      expecting = "10..14";
            string      result    = (s.Subtract(s2)).ToString();

            Assert.AreEqual(result, expecting);

            IntervalSet s3 = IntervalSet.Of(20, 25);

            expecting = "10..19";
            result    = (s.Subtract(s3)).ToString();
            Assert.AreEqual(result, expecting);
        }
Пример #2
0
        public void TestSubtractOfOverlappingRangeFromLeft() /*throws Exception*/
        {
            IntervalSet s         = IntervalSet.Of(10, 20);
            IntervalSet s2        = IntervalSet.Of(5, 11);
            string      expecting = "12..20";
            string      result    = (s.Subtract(s2)).ToString();

            Assert.AreEqual(result, expecting);

            IntervalSet s3 = IntervalSet.Of(5, 10);

            expecting = "11..20";
            result    = (s.Subtract(s3)).ToString();
            Assert.AreEqual(result, expecting);
        }
Пример #3
0
        public void TestSubtractOfRangeSpanningMultipleRanges() /*throws Exception*/
        {
            IntervalSet s = IntervalSet.Of(10, 20);

            s.Add(30, 40);
            s.Add(50, 60);                                 // s has 3 ranges now: 10..20, 30..40, 50..60
            IntervalSet s2        = IntervalSet.Of(5, 55); // covers one and touches 2nd range
            string      expecting = "56..60";
            string      result    = (s.Subtract(s2)).ToString();

            Assert.AreEqual(result, expecting);

            IntervalSet s3 = IntervalSet.Of(15, 55);   // touches both

            expecting = "{10..14, 56..60}";
            result    = (s.Subtract(s3)).ToString();
            Assert.AreEqual(result, expecting);
        }
Пример #4
0
        public void TestSubtractOfCompletelyCoveredRange() /*throws Exception*/
        {
            IntervalSet s         = IntervalSet.Of(10, 20);
            IntervalSet s2        = IntervalSet.Of(1, 25);
            string      expecting = "{}";
            string      result    = (s.Subtract(s2)).ToString();

            Assert.AreEqual(result, expecting);
        }
Пример #5
0
        public void TestSubtractOfCompletelyContainedRange() /*throws Exception*/
        {
            IntervalSet s         = IntervalSet.Of(10, 20);
            IntervalSet s2        = IntervalSet.Of(12, 15);
            string      expecting = "{10..11, 16..20}";
            string      result    = (s.Subtract(s2)).ToString();

            assertEquals(result, expecting);
        }
Пример #6
0
        public void TestSingleElementMinusDisjointSet() /*throws Exception*/
        {
            IntervalSet s  = IntervalSet.Of(15, 15);
            IntervalSet s2 = IntervalSet.Of(1, 5);

            s2.Add(10, 20);
            string expecting = "{}"; // 15 - {1..5, 10..20} = {}
            string result    = s.Subtract(s2).ToString();

            Assert.AreEqual(result, expecting);
        }
Пример #7
0
        public void TestSubtractOfWackyRange() /*throws Exception*/
        {
            IntervalSet s = IntervalSet.Of(0, 113);

            s.Add(115, 200);
            IntervalSet s2 = IntervalSet.Of(0, 115);

            s2.Add(117, 200);
            string expecting = "116";
            string result    = (s.Subtract(s2)).ToString();

            Assert.AreEqual(result, expecting);
        }
Пример #8
0
 public virtual void Remove(int a)
 {
     tokenTypeSet = (IntervalSet)tokenTypeSet.Subtract(IntervalSet.Of(a));
 }