public void testEquals()
        {
            // This test can't handle numBits==0:
            int         numBits = rnd.Next(2000) + 1;
            FixedBitSet b1      = new FixedBitSet(numBits);
            FixedBitSet b2      = new FixedBitSet(numBits);

            Assert.IsTrue(b1.Equals(b2));
            Assert.IsTrue(b2.Equals(b1));
            for (int iter = 0; iter < 10 * rnd.Next(500); iter++)
            {
                int idx = rnd.Next(numBits);
                if (!b1.Get(idx))
                {
                    b1.Set(idx);
                    Assert.IsFalse(b1.Equals(b2));
                    Assert.IsFalse(b2.Equals(b1));
                    b2.Set(idx);
                    Assert.IsTrue(b1.Equals(b2));
                    Assert.IsTrue(b2.Equals(b1));
                }
            }

            // try different type of object
            Assert.IsFalse(b1.Equals(new Object()));
        }
        public void testHashCodeEquals()
        {
            // This test can't handle numBits==0:
            int         numBits = rnd.Next(2000) + 1;
            FixedBitSet b1      = new FixedBitSet(numBits);
            FixedBitSet b2      = new FixedBitSet(numBits);

            Assert.IsTrue(b1.Equals(b2));
            Assert.IsTrue(b2.Equals(b1));
            for (int iter = 0; iter < 10 * rnd.Next(500); iter++)
            {
                int idx = rnd.Next(numBits);
                if (!b1.Get(idx))
                {
                    b1.Set(idx);
                    Assert.IsFalse(b1.Equals(b2));
                    Assert.AreNotEqual(b1.GetHashCode(), b2.GetHashCode());
                    b2.Set(idx);
                    Assert.AreEqual(b1, b2);
                    Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());
                }
            }
        }
 public void testSmallBitSets()
 {
     // Make sure size 0-10 bit sets are OK:
     for (int numBits = 0; numBits < 10; numBits++)
     {
         FixedBitSet b1 = new FixedBitSet(numBits);
         FixedBitSet b2 = new FixedBitSet(numBits);
         Assert.IsTrue(b1.Equals(b2));
         Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());
         Assert.AreEqual(0, b1.Cardinality());
         if (numBits > 0)
         {
             b1.Set(0, numBits);
             Assert.AreEqual(numBits, b1.Cardinality());
             //b1.Flip(0, numBits);
             //Assert.AreEqual(0, b1.Cardinality());
         }
     }
 }
		public void testSmallBitSets()
		{
			// Make sure size 0-10 bit sets are OK:
			for (int numBits = 0; numBits < 10; numBits++)
			{
				FixedBitSet b1 = new FixedBitSet(numBits);
				FixedBitSet b2 = new FixedBitSet(numBits);
				Assert.IsTrue(b1.Equals(b2));
				Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());
				Assert.AreEqual(0, b1.Cardinality());
				if (numBits > 0)
				{
					b1.Set(0, numBits);
					Assert.AreEqual(numBits, b1.Cardinality());
					//b1.Flip(0, numBits);
					//Assert.AreEqual(0, b1.Cardinality());
				}
			}
		}
		public void testHashCodeEquals()
		{
			// This test can't handle numBits==0:
			int numBits = rnd.Next(2000) + 1;
			FixedBitSet b1 = new FixedBitSet(numBits);
			FixedBitSet b2 = new FixedBitSet(numBits);
			Assert.IsTrue(b1.Equals(b2));
			Assert.IsTrue(b2.Equals(b1));
			for (int iter = 0; iter < 10 * rnd.Next(500); iter++)
			{
				int idx = rnd.Next(numBits);
				if (!b1.Get(idx))
				{
					b1.Set(idx);
					Assert.IsFalse(b1.Equals(b2));
					Assert.AreNotEqual(b1.GetHashCode(), b2.GetHashCode());
					b2.Set(idx);
					Assert.AreEqual(b1, b2);
					Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());
				}
			}
		}
		public void testEquals()
		{
			// This test can't handle numBits==0:
			int numBits = rnd.Next(2000) + 1;
			FixedBitSet b1 = new FixedBitSet(numBits);
			FixedBitSet b2 = new FixedBitSet(numBits);
			Assert.IsTrue(b1.Equals(b2));
			Assert.IsTrue(b2.Equals(b1));
			for (int iter = 0; iter < 10 * rnd.Next(500); iter++)
			{
				int idx = rnd.Next(numBits);
				if (!b1.Get(idx))
				{
					b1.Set(idx);
					Assert.IsFalse(b1.Equals(b2));
					Assert.IsFalse(b2.Equals(b1));
					b2.Set(idx);
					Assert.IsTrue(b1.Equals(b2));
					Assert.IsTrue(b2.Equals(b1));
				}
			}

			// try different type of object
			Assert.IsFalse(b1.Equals(new Object()));
		}