Beispiel #1
0
        public void IsDisjointFrom()
        {
            var bag1 = new Bag <int>(new[] { 3, 6, 7, 1, 1, 11, 9, 3, 8 });
            var bag2 = new Bag <int>();
            var bag3 = new Bag <int>();
            var bag4 = new Bag <int>(new[] { 8, 9, 1, 8, 3, 7, 6, 11, 7 });
            var bag5 = new Bag <int>(new int[] { 17, 3, 12, 10, 22 });
            var bag6 = new Bag <int>(new int[] { 14, 19, 14, 0, 2, 14 });

            Assert.IsFalse(bag1.IsDisjointFrom(bag1));
            Assert.IsTrue(bag2.IsDisjointFrom(bag2));

            Assert.IsTrue(bag1.IsDisjointFrom(bag2));
            Assert.IsTrue(bag2.IsDisjointFrom(bag1));

            Assert.IsTrue(bag2.IsDisjointFrom(bag3));
            Assert.IsTrue(bag3.IsDisjointFrom(bag2));

            Assert.IsFalse(bag1.IsDisjointFrom(bag4));
            Assert.IsFalse(bag4.IsDisjointFrom(bag1));

            Assert.IsFalse(bag1.IsDisjointFrom(bag5));
            Assert.IsFalse(bag5.IsDisjointFrom(bag1));

            Assert.IsTrue(bag1.IsDisjointFrom(bag6));
            Assert.IsTrue(bag6.IsDisjointFrom(bag1));

            Assert.IsTrue(bag5.IsDisjointFrom(bag6));
            Assert.IsTrue(bag6.IsDisjointFrom(bag5));
        }