コード例 #1
0
        public void TestIntervalRelation(int first2, int last2)
        {
            const int first1    = 1;
            const int last1     = 4;
            var       interval1 = new IntInterval(first1, last1);
            var       interval2 = new IntInterval(first2, last2);

            IntIntervalRelation relation = interval1.RelationTo(interval2);

            switch (relation)
            {
            case IntIntervalRelation.Less:
                Assert.IsTrue(last1 < first2);
                break;

            case IntIntervalRelation.Greater:
                Assert.IsTrue(last2 < first1);
                break;

            case IntIntervalRelation.Equal:
                Assert.IsTrue(first1 == first2 && last1 == last2);
                break;

            case IntIntervalRelation.Contained:
                Assert.IsTrue(first2 <= first1 && last1 <= last2);
                break;

            case IntIntervalRelation.Contains:
                Assert.IsTrue(first1 <= first2 && last2 <= last1);
                break;

            case IntIntervalRelation.OverlapFirst:
                Assert.IsTrue(first1 <= first2 && first2 <= last1 && last2 > last1);
                break;

            case IntIntervalRelation.OverlapLast:
                Assert.IsTrue(first1 <= last2 && last2 <= last1 && last1 > last2);
                break;

            default:
                Assert.Fail("Unsupported relation");
                break;
            }
        }