Exemple #1
0
        public void Subset_if_One_Set_Includes_Second_Set_Incompletely()
        {
            PowerSet <int> testSet = new PowerSet <int>();

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

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

            set2.Put(1);
            set2.Put(3);
            set2.Put(4);
            set2.Put(5);
            set2.Put(6);
            set2.Put(7);

            bool isSubset = testSet.IsSubset(set2);

            Assert.IsTrue(testSet.Size() == 6);
            Assert.IsFalse(isSubset);
            Assert.IsTrue(set2.Size() == 6);
        }
Exemple #2
0
        public void IsSubsetBothEmpty()
        {
            PowerSet <int> s1  = new PowerSet <int>();
            PowerSet <int> s2  = new PowerSet <int>();
            bool           res = s1.IsSubset(s2);

            if (res)
            {
                Assert.Fail();
            }
        }
        public void TestIsSubset_Int_1B()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();

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

            Assert.AreEqual(true, ps1.IsSubset(ps2));
        }
Exemple #4
0
        public static void TestsPowerSetIssubset()
        {
            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(2);
            Assert.AreEqual(1, testPowerSet2.Size());
            Assert.IsTrue(testPowerSet2.Get(2));
            testPowerSet2.Put(3);
            Assert.AreEqual(2, testPowerSet2.Size());
            Assert.IsTrue(testPowerSet2.Get(2));
            Assert.IsTrue(testPowerSet2.Get(3));

            Assert.IsTrue(testPowerSet1.IsSubset(testPowerSet2));
            Assert.IsFalse(testPowerSet2.IsSubset(testPowerSet1));

            testPowerSet2.Put(1);
            Assert.AreEqual(3, testPowerSet2.Size());
            Assert.IsTrue(testPowerSet2.Get(2));
            Assert.IsTrue(testPowerSet2.Get(3));
            Assert.IsTrue(testPowerSet2.Get(1));
            Assert.IsTrue(testPowerSet1.IsSubset(testPowerSet2));
            Assert.IsTrue(testPowerSet2.IsSubset(testPowerSet1));
        }
Exemple #5
0
        public void IsSubsetDifferent()
        {
            var s1 = new PowerSet <int>();
            var s2 = new PowerSet <int>();

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

            s2.Put(3);
            s2.Put(4);


            Assert.True(!s1.IsSubset(s2));
        }
        public void TestBitTest_6()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();
            PowerSet <string> ps3 = new PowerSet <string>();
            PowerSet <string> ps4 = new PowerSet <string>();

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

            ps2.Put("mag");
            ps2.Put("tab");
            ps2.Put("tap");

            Assert.AreEqual(true, ps1.IsSubset(ps2));
            Assert.AreEqual(true, ps1.IsSubset(ps3));
            Assert.AreEqual(false, ps2.IsSubset(ps1));
            Assert.AreEqual(false, ps3.IsSubset(ps1));
            Assert.AreEqual(true, ps3.IsSubset(ps4));
            Assert.AreEqual(true, ps4.IsSubset(ps3));
        }
Exemple #7
0
        public void IsSubsetInternal()
        {
            var s1 = new PowerSet <int>();
            var s2 = new PowerSet <int>();

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

            s2.Put(3);
            s2.Put(4);

            Assert.True(s1.IsSubset(s2));
        }
Exemple #8
0
        public void IsSubsetTwoEmpty()
        {
            PowerSet <int> s1 = new PowerSet <int>();
            PowerSet <int> s2 = new PowerSet <int>();

            s1.Put(1);
            s1.Put(2);
            s1.Put(3);
            s1.Put(4);
            bool res = s1.IsSubset(s2);

            if (!res)
            {
                Assert.Fail();
            }
        }
Exemple #9
0
        public void IsSubsetOneEmpty()
        {
            PowerSet <int> s1 = new PowerSet <int>();
            PowerSet <int> s2 = new PowerSet <int>();

            s2.Put(1);
            s2.Put(2);
            s2.Put(4);
            s2.Put(6);
            bool res = s1.IsSubset(s2);

            if (res)
            {
                Assert.Fail();
            }
        }
        public void Test_IsSubset_WhenFalse()
        {
            // возвращает 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.IsSubset(set2);

            Assert.AreEqual(false, result);
        }
        public void TestIsSubset_String_2B()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();

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

            for (int i = 1000; i <= 1356; i++)
            {
                ps2.Put("" + i);
            }

            Assert.AreEqual(true, ps1.IsSubset(ps2));
        }
        public void TestIsSubset_String_1A()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();

            ps1.Put("Goat");
            ps1.Put("Bear");
            ps1.Put("Raccoon");
            ps1.Put("Bird");
            ps1.Put("Squid");

            ps2.Put("Raccoon");
            ps2.Put("Bird");
            ps2.Put("Turtle");

            Assert.AreEqual(false, ps1.IsSubset(ps2));
        }
        public void TestEBit_5()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();

            ps1.Put(1);
            ps1.Put(2);
            ps1.Put(3);
            ps1.Put(6);
            ps1.Put(7);
            ps1.Put(8);
            ps1.Put(9);

            ps2.Put(1);
            ps2.Put(2);
            ps2.Put(3);
            ps2.Put(8);

            Assert.AreEqual(true, ps1.IsSubset(ps2));
        }
Exemple #14
0
        public void IsSubsetS2Bigger()
        {
            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(5);
            s2.Put(1);
            s2.Put(2);
            s2.Put(3);
            s2.Put(4);
            bool res = s1.IsSubset(s2);

            if (res)
            {
                Assert.Fail();
            }
        }
        public void TestEIsSubset_2()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();

            ps1.Put("j1");
            ps1.Put("j2");
            ps1.Put("car");
            ps1.Put("check");
            ps1.Put("bleach");
            ps1.Put("far1");
            ps1.Put("Pop");

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

            Assert.AreEqual(false, ps1.IsSubset(ps2));
        }
Exemple #16
0
        public void Subset_if_One_Set_Has_Second_Set()
        {
            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(1);
            set2.Put(2);
            set2.Put(3);

            bool isSubset = testSet.IsSubset(set2);

            Assert.IsTrue(testSet.Size() == 4);
            Assert.IsTrue(isSubset);
            Assert.IsTrue(set2.Size() == 3);
        }