Пример #1
0
        public void TestDifference_Int_3A()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();
            PowerSet <int> ps3;

            for (int i = 1; i <= 5; i++)
            {
                ps1.Put(i);
            }

            for (int i = 7; i <= 11; i++)
            {
                ps2.Put(i);
            }

            ps3 = ps1.Difference(ps2);

            Assert.AreEqual(5, ps3.Size());

            for (int i = 1; i <= 11; i++)
            {
                if (!(i > 5))
                {
                    Assert.AreEqual(true, ps3.Get(i));
                }
                else
                {
                    Assert.AreEqual(false, ps3.Get(i));
                }
            }
        }
Пример #2
0
        public void TestDifference_Int_2()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();
            PowerSet <int> ps3;

            for (int i = 1; i <= 10000; i++)
            {
                ps1.Put(i);
            }

            for (int i = 9981; i <= 20000; i++)
            {
                ps2.Put(i);
            }

            ps3 = ps1.Difference(ps2);

            Assert.AreEqual(9980, ps3.Size());

            for (int i = 1; i <= 19980; i++)
            {
                if (i < 9981)
                {
                    Assert.AreEqual(true, ps3.Get(i));
                }
                else
                {
                    Assert.AreEqual(false, ps3.Get(i));
                }
            }
        }
Пример #3
0
        public static void TestsPowerSetDifference()
        {
            var testPowerSet1 = new PowerSet <int>();
            var testPowerSet2 = new PowerSet <int>();

            Assert.AreEqual(0, testPowerSet1.Size());
            Assert.AreEqual(0, testPowerSet2.Size());

            testPowerSet1.Put(1);
            Assert.AreEqual(1, testPowerSet1.Size());
            Assert.IsTrue(testPowerSet1.Get(1));
            testPowerSet1.Put(2);
            Assert.AreEqual(2, testPowerSet1.Size());
            Assert.IsTrue(testPowerSet1.Get(1));
            Assert.IsTrue(testPowerSet1.Get(2));
            testPowerSet1.Put(3);
            Assert.AreEqual(3, testPowerSet1.Size());
            Assert.IsTrue(testPowerSet1.Get(1));
            Assert.IsTrue(testPowerSet1.Get(2));
            Assert.IsTrue(testPowerSet1.Get(3));

            testPowerSet2.Put(1);
            Assert.AreEqual(1, testPowerSet2.Size());
            Assert.IsTrue(testPowerSet2.Get(1));
            testPowerSet2.Put(3);
            Assert.AreEqual(2, testPowerSet2.Size());
            Assert.IsTrue(testPowerSet2.Get(1));
            Assert.IsTrue(testPowerSet2.Get(3));

            var result = testPowerSet1.Difference(testPowerSet2);

            Assert.AreEqual(1, result.Size());
            Assert.IsTrue(result.Get(2));
        }
Пример #4
0
        public void TestDifference_Int_1A()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();
            PowerSet <int> ps3;

            for (int i = 1; i <= 10; i++)
            {
                ps1.Put(i);
            }

            ps2.Put(3);
            ps2.Put(6);
            ps2.Put(7);
            ps2.Put(10);

            ps3 = ps1.Difference(ps2);

            Assert.AreEqual(6, ps3.Size());
            Assert.AreEqual(true, ps3.Get(1));
            Assert.AreEqual(true, ps3.Get(2));
            Assert.AreEqual(true, ps3.Get(4));
            Assert.AreEqual(true, ps3.Get(5));
            Assert.AreEqual(true, ps3.Get(8));
            Assert.AreEqual(true, ps3.Get(9));
            Assert.AreEqual(false, ps3.Get(3));
            Assert.AreEqual(false, ps3.Get(6));
            Assert.AreEqual(false, ps3.Get(7));
            Assert.AreEqual(false, ps3.Get(10));

            for (int i = 11; i < 20000; i++)
            {
                Assert.AreEqual(false, ps3.Get(i));
            }
        }
Пример #5
0
        public void Difference_Both_Sets_Are_Empty()
        {
            PowerSet <int> testSet = new PowerSet <int>();
            PowerSet <int> set2    = new PowerSet <int>();

            PowerSet <int> interSet = testSet.Difference(set2);

            Assert.IsTrue(interSet.Size() == 0);
        }
        public void Test_Difference_WhenBothSetsAreEmpty()
        {
            // возвращает true если value удалено
            // иначе false
            var set1   = new PowerSet <int>();
            var set2   = new PowerSet <int>();
            var result = set1.Difference(set2);

            Assert.AreEqual(0, result.Size());
        }
        public void Test_Difference_WhenSecondSetIsEmpty()
        {
            // возвращает true если value удалено
            // иначе false
            var set1 = new PowerSet <int>();
            var set2 = new PowerSet <int>();

            set1.Put(1);
            set1.Put(3);

            var result = set1.Difference(set2);

            Assert.AreEqual(2, result.Size());
        }
Пример #8
0
        public void DifferenceSame()
        {
            var s1 = new PowerSet <int>();
            var s2 = new PowerSet <int>();

            s1.Put(2);
            s1.Put(3);

            s2.Put(2);
            s2.Put(3);

            var union = s1.Difference(s2);

            Assert.True(union.Size() == 0);
        }
Пример #9
0
        public void DifferenceEmptryTwo()
        {
            PowerSet <int> s1 = new PowerSet <int>();
            PowerSet <int> s2 = new PowerSet <int>();

            s1.Put(1);
            s1.Put(2);
            s1.Put(3);
            s1.Put(4);
            PowerSet <int> s3 = s1.Difference(s2);

            if (s3.Size() != 4)
            {
                Assert.Fail();
            }
        }
Пример #10
0
        public void DifferenceInternal()
        {
            var s1 = new PowerSet <int>();
            var s2 = new PowerSet <int>();

            s1.Put(1);
            s1.Put(2);
            s1.Put(3);
            s1.Put(4);

            s2.Put(2);
            s2.Put(3);

            var union = s1.Difference(s2);

            Assert.True(union.Size() == 2);
        }
        public void Test_Difference()
        {
            // возвращает true если value удалено
            // иначе false
            var set1 = new PowerSet <int>();
            var set2 = new PowerSet <int>();

            set1.Put(1);
            set1.Put(2);
            set2.Put(1);
            set2.Put(3);

            var result = set1.Difference(set2);

            Assert.AreEqual(1, result.Size());
            Assert.AreEqual(true, result.Get(2));
            Assert.AreEqual(false, result.Get(1));
        }
Пример #12
0
        public void DifferenceTest()
        {
            PowerSet <int> s1 = new PowerSet <int>();
            PowerSet <int> s2 = new PowerSet <int>();

            s1.Put(1);
            s1.Put(2);
            s1.Put(3);
            s1.Put(4);
            //s2.Put(1);
            s2.Put(2);
            s2.Put(4);
            s2.Put(6);
            PowerSet <int> s3 = s1.Difference(s2);

            if (s3.Size() != 2)
            {
                Assert.Fail();
            }
        }
Пример #13
0
        public void TestDifference_Int_3()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();
            PowerSet <int> ps3;

            for (int i = 1; i <= 5; i++)
            {
                ps1.Put(i);
            }

            for (int i = 1; i <= 5; i++)
            {
                ps2.Put(i);
            }

            ps3 = ps1.Difference(ps2);

            Assert.AreEqual(0, ps3.Size());
        }
Пример #14
0
        public void Difference_if_Both_Sets_Have_Cross()
        {
            PowerSet <int> testSet = new PowerSet <int>();

            testSet.Put(1);
            testSet.Put(2);
            testSet.Put(3);
            testSet.Put(4);

            PowerSet <int> set2 = new PowerSet <int>();

            set2.Put(2);
            set2.Put(3);
            set2.Put(7);
            set2.Put(8);

            PowerSet <int> interSet = testSet.Difference(set2);

            Assert.IsTrue(interSet.Size() == 2);
            Assert.IsTrue(interSet.Get(1));
            Assert.IsTrue(interSet.Get(4));
        }
Пример #15
0
        public void TestEDifference_1()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();

            ps1.Put("j1");
            ps1.Put("j2");
            ps1.Put("car");
            ps1.Put("far");

            ps2.Put("Pop");
            ps2.Put("far");
            ps2.Put("j2");
            ps2.Put("trust");
            ps2.Put("bleach");

            PowerSet <string> ps3 = ps1.Difference(ps2);

            Assert.AreEqual(2, ps3.Size());

            Assert.AreEqual(true, ps3.Get("car"));
            Assert.AreEqual(true, ps3.Get("j1"));
        }
Пример #16
0
        public void TestBitTest_5()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();

            ps1.Put("sad");
            ps1.Put("mag");
            ps1.Put("tap");
            ps1.Put("tab");
            ps1.Put("tas");

            ps2.Put("pop");
            ps2.Put("tap");
            ps2.Put("tab");
            ps2.Put("tas");

            PowerSet <string> ps3 = ps1.Difference(ps2);

            Assert.AreEqual(2, ps3.Size());
            Assert.AreEqual(true, ps3.Get("sad"));
            Assert.AreEqual(true, ps3.Get("mag"));
            Assert.AreEqual(false, ps3.Get("pop"));
        }
Пример #17
0
        public void Difference_Both_Sets_Has_Different_Values()
        {
            PowerSet <int> testSet = new PowerSet <int>();

            testSet.Put(1);
            testSet.Put(2);
            testSet.Put(3);
            testSet.Put(4);

            PowerSet <int> set2 = new PowerSet <int>();

            set2.Put(5);
            set2.Put(6);
            set2.Put(7);
            set2.Put(8);

            PowerSet <int> interSet = testSet.Difference(set2);

            Assert.IsTrue(interSet.Size() == 4);
            Assert.IsTrue(interSet.Get(1));
            Assert.IsTrue(interSet.Get(2));
            Assert.IsTrue(interSet.Get(3));
            Assert.IsTrue(interSet.Get(4));
        }