public void TestIntersection_Int_1()
        {
            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 = 3; i <= 7; i++)
            {
                ps2.Put(i);
            }

            ps3 = ps1.Intersection(ps2);

            for (int i = 3; i <= 5; i++)
            {
                Assert.AreEqual(true, ps3.Get(i));
            }

            Assert.AreEqual(3, ps3.Size());
            Assert.AreEqual(false, ps3.Get(6));
            Assert.AreEqual(false, ps3.Get(2));
        }
        public void TestIntersection_Int_2()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();
            PowerSet <int> ps3;

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

            for (int i = 19981; i <= 39980; i++)
            {
                ps2.Put(i);
            }

            ps3 = ps1.Intersection(ps2);

            for (int i = 19981; i <= 20000; i++)
            {
                Assert.AreEqual(true, ps3.Get(i));
            }

            Assert.AreEqual(20, ps3.Size());
            Assert.AreEqual(false, ps3.Get(20005));
            Assert.AreEqual(false, ps3.Get(16050));
        }
        public void TestIntersection_String_2()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();
            PowerSet <string> ps3;

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

            for (int i = 19981; i <= 39980; i++)
            {
                ps2.Put("" + i);
            }

            ps3 = ps1.Intersection(ps2);

            for (int i = 19981; i <= 20000; i++)
            {
                Assert.AreEqual(true, ps3.Get("" + i));
            }

            Assert.AreEqual(20, ps3.Size());
            Assert.AreEqual(false, ps3.Get("f"));
            Assert.AreEqual(false, ps3.Get("222"));
        }
        public void TestEBit_2()
        {
            PowerSet <int>    ps1 = new PowerSet <int>();
            PowerSet <int>    ps2 = new PowerSet <int>();
            PowerSet <string> ps3 = new PowerSet <string>();
            PowerSet <string> ps4 = new PowerSet <string>();

            ps1.Put(1);
            ps1.Put(83);
            ps1.Put(923);
            ps1.Put(44);
            ps1.Put(9410);
            ps1.Put(642);
            ps1.Put(5);

            ps2.Put(3);
            ps2.Put(5);
            ps2.Put(44);
            ps2.Put(187);
            ps2.Put(500);
            ps2.Put(923);
            ps2.Put(601);

            PowerSet <int> psi = ps1.Intersection(ps2);

            Assert.AreEqual(true, psi.Get(5));
            Assert.AreEqual(true, psi.Get(923));
            Assert.AreEqual(true, psi.Get(44));
        }
        public void TestIntersection_Node_2()
        {
            PowerSet <Node> ps1 = new PowerSet <Node>();
            PowerSet <Node> ps2 = new PowerSet <Node>();
            PowerSet <Node> ps3;

            Node[] nodes = new Node[39980];

            for (int i = 0; i < nodes.Length; i++)
            {
                nodes[i] = new Node(i);
            }

            for (int i = 0; i < 20000; i++)
            {
                ps1.Put(nodes[i]);
            }

            for (int i = 19980; i < 39980; i++)
            {
                ps2.Put(nodes[i]);
            }

            ps3 = ps1.Intersection(ps2);

            Assert.AreEqual(20, ps3.Size());
            for (int i = 19980; i < 20000; i++)
            {
                Assert.AreEqual(true, ps3.Get(nodes[i]));
            }
        }
        public void TestIntersection_String_1()
        {
            PowerSet <string> ps1 = new PowerSet <string>();
            PowerSet <string> ps2 = new PowerSet <string>();
            PowerSet <string> ps3;

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

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

            ps3 = ps1.Intersection(ps2);

            for (int i = 3; i <= 5; i++)
            {
                Assert.AreEqual(true, ps3.Get("" + i));
            }

            Assert.AreEqual(3, ps3.Size());
            Assert.AreEqual(false, ps3.Get("1"));
            Assert.AreEqual(false, ps3.Get("33"));
        }
        public void TestIntersection_Char_1()
        {
            PowerSet <char> ps1 = new PowerSet <char>();
            PowerSet <char> ps2 = new PowerSet <char>();
            PowerSet <char> ps3;

            for (int i = 1; i <= 20000; i++)
            {
                ps1.Put(Convert.ToChar(i));
            }

            for (int i = 19981; i <= 39980; i++)
            {
                ps2.Put(Convert.ToChar(i));
            }

            ps3 = ps1.Intersection(ps2);

            for (int i = 19981; i <= 20000; i++)
            {
                Assert.AreEqual(true, ps3.Get(Convert.ToChar(i)));
            }

            Assert.AreEqual(20, ps3.Size());
            Assert.AreEqual(false, ps3.Get(Convert.ToChar(30382)));
            Assert.AreEqual(false, ps3.Get(Convert.ToChar(10382)));
        }
Beispiel #8
0
        public void Intersection_Is_Both_Sets_has_not_values()
        {
            PowerSet <int> testSet = new PowerSet <int>();
            PowerSet <int> set2    = new PowerSet <int>();

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

            Assert.IsTrue(interSet.Size() == 0);
        }
        public void TestIntersection_Int_3()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();
            PowerSet <int> ps3;

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

            ps3 = ps1.Intersection(ps2);

            Assert.AreEqual(0, ps3.Size());
        }
        public void TestIntersection_Char_3()
        {
            PowerSet <char> ps1 = new PowerSet <char>();
            PowerSet <char> ps2 = new PowerSet <char>();
            PowerSet <char> ps3;

            for (int i = 1; i <= 200; i++)
            {
                ps1.Put(Convert.ToChar(i));
            }

            ps3 = ps1.Intersection(ps2);

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

            set2.Put(1);
            set2.Put(2);
            var result = set1.Intersection(set2);

            Assert.AreEqual(0, result.Size());
            Assert.AreEqual(false, result.Get(1));
            Assert.AreEqual(false, result.Get(2));
        }
Beispiel #12
0
        public void IntersectionDifferent()
        {
            var s1 = new PowerSet <int>();
            var s2 = new PowerSet <int>();

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

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

            var union = s1.Intersection(s2);

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

            set1.Put(1);
            set1.Put(3);
            set2.Put(1);
            set2.Put(2);
            var result = set2.Intersection(set1);

            Assert.AreEqual(1, result.Size());
            Assert.AreEqual(true, result.Get(1));
        }
Beispiel #14
0
        public void intersectionTestEmptyOne()
        {
            PowerSet <int> s1 = new PowerSet <int>();
            PowerSet <int> s2 = new PowerSet <int>();

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

            if ((s3.Size() != 0))
            {
                Assert.Fail();
            }
        }
Beispiel #15
0
        public void Intersection_has_not_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.Intersection(set2);

            Assert.IsTrue(interSet.Size() == 0);
        }
Beispiel #16
0
        public void intersectionTest()
        {
            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.Intersection(s2);

            if (s3.Size() != 2)
            {
                Assert.Fail();
            }
        }
        public void TestEIntersection_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");

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

            Assert.AreEqual(true, ps3.Get("far"));
            Assert.AreEqual(true, ps3.Get("j2"));
            Assert.AreEqual(false, ps3.Get("car"));
            Assert.AreEqual(2, ps3.Size());
        }
Beispiel #18
0
        public static void TestsPowerSetIntersection()
        {
            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));
            testPowerSet2.Put(4);
            Assert.AreEqual(3, testPowerSet2.Size());
            Assert.IsTrue(testPowerSet2.Get(4));
            Assert.IsTrue(testPowerSet2.Get(2));
            Assert.IsTrue(testPowerSet2.Get(3));

            var result = testPowerSet1.Intersection(testPowerSet2);

            Assert.AreEqual(2, result.Size());
            Assert.IsTrue(result.Get(2));
            Assert.IsTrue(result.Get(3));
        }