Пример #1
0
        private void StrictSetSubset <S1, S2>()
            where S1 : IStrictSet <int>, new()
            where S2 : IStrictSet <int>, new()
        {
            var s1 = new S1();
            var s2 = new S2();

            Fill(s1, 0, 5000);
            Fill(s2, 4000, 5000);
            Assert.False(s1.IsSubsetOf(s2));
            Assert.False(s2.IsSubsetOf(s1));
            Assert.False(s1.IsProperSubsetOf(s2));
            Assert.False(s2.IsProperSubsetOf(s1));


            var s3 = new S1();
            var s4 = new S2();

            Fill(s3, 0, 5000);
            Fill(s4, 1000, 2000);
            Assert.False(s3.IsSubsetOf(s4));
            Assert.True(s4.IsSubsetOf(s3));
            Assert.False(s3.IsProperSubsetOf(s4));
            Assert.True(s4.IsProperSubsetOf(s3));

            var s5 = new S1();
            var s6 = new S2();

            Fill(s5, 1000, 2000);
            Fill(s6, 0, 5000);
            Assert.True(s5.IsSubsetOf(s6));
            Assert.False(s6.IsSubsetOf(s5));
            Assert.True(s5.IsProperSubsetOf(s6));
            Assert.False(s6.IsProperSubsetOf(s5));

            var s7 = new S1();
            var s8 = new S2();

            Fill(s7, 0, 1000);
            Fill(s8, 2000, 1000);
            Assert.False(s7.IsSubsetOf(s8));
            Assert.False(s8.IsSubsetOf(s7));
            Assert.False(s7.IsProperSubsetOf(s8));
            Assert.False(s8.IsProperSubsetOf(s7));

            var s9 = new S2();

            Fill(s9, 0, 1000);
            Assert.True(s7.IsSubsetOf(s9));
            Assert.True(s9.IsSubsetOf(s7));
            Assert.False(s7.IsProperSubsetOf(s9));
            Assert.False(s9.IsProperSubsetOf(s7));
            Assert.True(s7.IsSubsetOf(s7));
            Assert.False(s7.IsProperSubsetOf(s7));

            var s10 = new S1();
            var s11 = new S2();

            Assert.True(s10.IsSubsetOf(s11));
            Assert.True(s11.IsSubsetOf(s10));
            Assert.False(s10.IsProperSubsetOf(s11));
            Assert.False(s11.IsProperSubsetOf(s10));
        }