Example #1
0
        private void  DoTestDgaps(int size, int count1, int count2)
        {
            Directory d  = new RAMDirectory();
            BitVector bv = new BitVector(size);

            for (int i = 0; i < count1; i++)
            {
                bv.Set(i);
                Assert.AreEqual(i + 1, bv.Count());
            }
            bv.Write(d, "TESTBV", null);
            // gradually increase number of set bits
            for (int i = count1; i < count2; i++)
            {
                BitVector bv2 = new BitVector(d, "TESTBV", null);
                Assert.IsTrue(DoCompare(bv, bv2));
                bv = bv2;
                bv.Set(i);
                Assert.AreEqual(i + 1, bv.Count());
                bv.Write(d, "TESTBV", null);
            }
            // now start decreasing number of set bits
            for (int i = count2 - 1; i >= count1; i--)
            {
                BitVector bv2 = new BitVector(d, "TESTBV", null);
                Assert.IsTrue(DoCompare(bv, bv2));
                bv = bv2;
                bv.Clear(i);
                Assert.AreEqual(i, bv.Count());
                bv.Write(d, "TESTBV", null);
            }
        }
Example #2
0
        private void  DoTestWriteRead(int n)
        {
            Directory d = new RAMDirectory();

            BitVector bv = new BitVector(n);

            // test count when incrementally setting bits
            for (int i = 0; i < bv.Size(); i++)
            {
                Assert.IsFalse(bv.Get(i));
                Assert.AreEqual(i, bv.Count());
                bv.Set(i);
                Assert.IsTrue(bv.Get(i));
                Assert.AreEqual(i + 1, bv.Count());
                bv.Write(d, "TESTBV", null);
                BitVector compare = new BitVector(d, "TESTBV", null);
                // compare bit vectors with bits set incrementally
                Assert.IsTrue(DoCompare(bv, compare));
            }
        }
Example #3
0
		private void  DoTestDgaps(int size, int count1, int count2)
		{
			Directory d = new RAMDirectory();
			BitVector bv = new BitVector(size);
			for (int i = 0; i < count1; i++)
			{
				bv.Set(i);
				Assert.AreEqual(i + 1, bv.Count());
			}
			bv.Write(d, "TESTBV");
			// gradually increase number of set bits
			for (int i = count1; i < count2; i++)
			{
				BitVector bv2 = new BitVector(d, "TESTBV");
				Assert.IsTrue(DoCompare(bv, bv2));
				bv = bv2;
				bv.Set(i);
				Assert.AreEqual(i + 1, bv.Count());
				bv.Write(d, "TESTBV");
			}
			// now start decreasing number of set bits
			for (int i = count2 - 1; i >= count1; i--)
			{
				BitVector bv2 = new BitVector(d, "TESTBV");
				Assert.IsTrue(DoCompare(bv, bv2));
				bv = bv2;
				bv.Clear(i);
				Assert.AreEqual(i, bv.Count());
				bv.Write(d, "TESTBV");
			}
		}
Example #4
0
		private void  DoTestWriteRead(int n)
		{
			Directory d = new RAMDirectory();
			
			BitVector bv = new BitVector(n);
			// test count when incrementally setting bits
			for (int i = 0; i < bv.Size(); i++)
			{
				Assert.IsFalse(bv.Get(i));
				Assert.AreEqual(i, bv.Count());
				bv.Set(i);
				Assert.IsTrue(bv.Get(i));
				Assert.AreEqual(i + 1, bv.Count());
				bv.Write(d, "TESTBV");
				BitVector compare = new BitVector(d, "TESTBV");
				// compare bit vectors with bits set incrementally
				Assert.IsTrue(DoCompare(bv, compare));
			}
		}