Ejemplo n.º 1
0
        public void CompareTo()
        {
            Assert.AreEqual(-1, Range.StartsWith(1).CompareTo(Range.StartsWith(1, false)));
            Assert.AreEqual(0, Range.StartsWith(1).CompareTo(Range.StartsWith(1)));
            Assert.AreEqual(0, Range.StartsWith(1, false).CompareTo(Range.StartsWith(1, false)));
            Assert.AreEqual(1, Range.StartsWith(1, false).CompareTo(Range.StartsWith(1, true)));

            Assert.AreEqual(0, Range.Create(1, 3, true).CompareTo(Range.Create(1, 3, true)));
            Assert.AreEqual(0, Range.Create(1, 3, false).CompareTo(Range.Create(1, 3, false)));

            Assert.AreEqual(1, Range.Create(1, 3, true, true).CompareTo(Range.Create(1, 3, true, false)));
            Assert.AreEqual(-1, Range.Create(1, 3, true, false).CompareTo(Range.Create(1, 3, true, true)));
        }
Ejemplo n.º 2
0
        public void Exclude()
        {
            CheckExclude(Range.EndsWith(5, true), Range.Create(2, 3, true, true), "..(2)", "(3)..5");
            CheckExclude(Range.EndsWith(5, true), Range.Create(2, 5, true, false), "..(2)", "5");
            CheckExclude(Range.EndsWith(5, true), Range.Create(2, 5, true, true), "..(2)");
            CheckExclude(Range.EndsWith(5, false), Range.Create(2, 5, true, true), "..(2)");
            CheckExclude(Range.EndsWith(5, false), Range.Create(2, 5, true, false), "..(2)");

            CheckExclude(Range.Create(0, 5, true, true), Range.Create(2, 5, true, true), "0..(2)");
            CheckExclude(Range.Create(0, 5, true, true), Range.Create(2, 10, true, true), "0..(2)");
            CheckExclude(Range.Create(0, 5, true, true), Range.StartsWith(2, true), "0..(2)");
            CheckExclude(Range.Create(0, 5, true, true), Range.StartsWith(5, false), "0..5");
            CheckExclude(Range.Create(0, 5, true, true), Range.StartsWith(5, true), "0..(5)");
        }
Ejemplo n.º 3
0
        public void Union()
        {
            CheckUnion(Range <int> .Empty, Range <int> .Full, "...");

            CheckUnion(Range <int> .Empty, Range.StartsWith(5, true), "5..");
            CheckUnion(Range <int> .Empty, Range.StartsWith(5, false), "(5)..");

            CheckUnion(Range.StartsWith(5, false), Range.EndsWith(10, true), "...");
            CheckUnion(Range.StartsWith(5, false), Range.EndsWith(10, false), "...");

            CheckUnion(Range.StartsWith(5, true), Range.StartsWith(10, true), "5..");
            CheckUnion(Range.StartsWith(5, false), Range.StartsWith(10, true), "(5)..");

            CheckUnion(Range.EndsWith(5, true), Range.EndsWith(10, true), "..10");
            CheckUnion(Range.EndsWith(5, false), Range.EndsWith(10, false), "..(10)");
        }
Ejemplo n.º 4
0
        public void Intersect()
        {
            CheckIntersect(Range.Full <int>(), Range.Full <int>(), Range.Full <int>());
            CheckIntersect(Range.Full <int>(), Range.Empty <int>(), Range.Empty <int>());
            CheckIntersect(Range.Full <int>(), Range.StartsWith(10), Range.StartsWith(10));
            CheckIntersect(Range.Empty <int>(), Range.Empty <int>(), Range.Empty <int>());

            CheckIntersect(Range.EndsWith(10, true), Range.Create(0, 10, true, true), Range.Create(0, 10, true));
            CheckIntersect(Range.EndsWith(10, false), Range.Create(0, 10, true, true), Range.Create(0, 10, true, false));

            CheckIntersect(Range.EndsWith(10, false), Range.StartsWith(10, true));
            CheckIntersect(Range.EndsWith(10, false), Range.StartsWith(10, false));

            CheckIntersect(Range.EndsWith(10, true), Range.StartsWith(10, true), Range.Simple(10));

            CheckIntersect(Range.EndsWith(10, true), Range.Create(0, 9, true), Range.Create(0, 9, true));
            CheckIntersect(Range.EndsWith(10, true), Range.Create(0, 9, true, false), Range.Create(0, 9, true, false));

            CheckIntersect(Range.Create(0, 10, true), Range.Create(0, 2, false, false), Range.Create(0, 2, false, false));
        }
Ejemplo n.º 5
0
        public void IntersectsWith()
        {
            var range1 = Range.Create(0, 3);

            Assert.IsTrue(range1.IntersectsWith(Range.Create(1, 5)));
            Assert.IsTrue(range1.IntersectsWith(Range.Create(1, 3)));
            Assert.IsTrue(range1.IntersectsWith(Range.Create(3, 5)));
            Assert.IsTrue(range1.IntersectsWith(Range.Create(0, 0)));
            Assert.IsFalse(range1.IntersectsWith(Range.Create(-2, -1)));

            range1 = Range.Create(0, 3, false);

            Assert.IsTrue(range1.IntersectsWith(Range.Create(1, 5, false)));
            Assert.IsTrue(range1.IntersectsWith(Range.Create(1, 3, false)));
            Assert.IsFalse(range1.IntersectsWith(Range.Create(3, 5, false)));
            Assert.IsFalse(range1.IntersectsWith(Range.Create(0, 0, false)));
            Assert.IsFalse(range1.IntersectsWith(Range.Create(-2, -1, false)));

            Assert.IsFalse(range1.IntersectsWith(Range.Empty <int>()));
            Assert.IsTrue(Range.StartsWith(0, false).IntersectsWith(Range.StartsWith(-2, false)));
        }