public void IsSubSet()
        {
            // IsSubSet with PowerSet2 contains 5 items (expected false)
            Assert.AreEqual(false, testPowerSet1.IsSubset(testPowerSet2));
            Assert.AreEqual(false, testPowerSet2.IsSubset(testPowerSet1));

            // IsSubSet with empty set (0 isSubset(A) = false)
            Assert.AreEqual(false, testPowerSet0.IsSubset(testPowerSet1));

            // IsSubSet with empty set (A isSubset(0) = true)
            Assert.AreEqual(true, testPowerSet1.IsSubset(testPowerSet0));

            // empty set with empty set (0 isSubset(0) = true)
            Assert.AreEqual(true, testPowerSet0.IsSubset(testPowerSet0));

            // Putting 3 items to the empty set
            testPowerSet0.Put(10);
            testPowerSet0.Put(12);
            testPowerSet0.Put(14);
            Assert.AreEqual(3, testPowerSet0.capacity);

            // IsSubSet with PowerSet0 contains 3 items (expected true)
            Assert.AreEqual(true, testPowerSet1.IsSubset(testPowerSet0));
            // IsSubSet with PowerSet1 contains 5 items from PowerSet0 contains 3 items (expected false)
            Assert.AreEqual(false, testPowerSet0.IsSubset(testPowerSet1));
        }
Esempio n. 2
0
        static void TestIsSubset(PowerSet <int> set1, PowerSet <int> set2)
        {
            if (set1.Size() == 0)
            {
                Console.Write("set1 is empty");
            }
            else
            {
                Console.WriteLine("set1");
                for (int i = 0; i < set1._values.Length; i++)
                {
                    if (set1._slotsStatus[i] == PowerSet <int> .SlotStatus.Fill)
                    {
                        Console.Write(set1._values[i] + " ");
                    }
                }
            }

            Console.WriteLine();

            if (set2.Size() == 0)
            {
                Console.Write("set2 is empty");
            }
            else
            {
                Console.WriteLine("set2");
                for (int i = 0; i < set2._values.Length; i++)
                {
                    if (set2._slotsStatus[i] == PowerSet <int> .SlotStatus.Fill)
                    {
                        Console.Write(set2._values[i] + " ");
                    }
                }
            }

            Console.WriteLine();

            bool result = set1.IsSubset(set2);

            Console.WriteLine("result is subset = " + result);

            Console.WriteLine(new string('=', 50));
        }