示例#1
0
        public void equals_or_contains()
        {
            const int a = 0;
            const int b = 1;
            const int c = 2;
            const int d = 3;
            const int e = 54;

            var ae = new SourceSpan(new SourceLocation(a, 1, 1), e - a);
            var ac = new SourceSpan(new SourceLocation(a, 1, 1), c - a);
            var ce = new SourceSpan(new SourceLocation(c, 2, 1), e - c);
            var bd = new SourceSpan(new SourceLocation(b, 1, 2), d - b);

            Assert.IsTrue(ae.EqualsOrContains(ae));
            Assert.IsTrue(ae.EqualsOrContains(ac));
            Assert.IsTrue(ae.EqualsOrContains(ce));
            Assert.IsTrue(ae.EqualsOrContains(bd));

            Assert.IsFalse(ac.EqualsOrContains(ae));
            Assert.IsTrue(ac.EqualsOrContains(ac));
            Assert.IsFalse(ac.EqualsOrContains(ce));
            Assert.IsFalse(ac.EqualsOrContains(bd));

            Assert.IsFalse(ce.EqualsOrContains(ae));
            Assert.IsFalse(ce.EqualsOrContains(ac));
            Assert.IsTrue(ce.EqualsOrContains(ce));
            Assert.IsFalse(ce.EqualsOrContains(bd));

            Assert.IsFalse(bd.EqualsOrContains(ae));
            Assert.IsFalse(bd.EqualsOrContains(ac));
            Assert.IsFalse(bd.EqualsOrContains(ce));
            Assert.IsTrue(bd.EqualsOrContains(bd));
        }