예제 #1
0
        public virtual void TestMostlySet()
        {
            Directory d       = NewDirectory();
            int       numBits = TestUtil.NextInt(Random(), 30, 1000);

            for (int numClear = 0; numClear < 20; numClear++)
            {
                BitVector bv = new BitVector(numBits);
                bv.InvertAll();
                int count = 0;
                while (count < numClear)
                {
                    int bit = Random().Next(numBits);
                    // Don't use getAndClear, so that count is recomputed
                    if (bv.Get(bit))
                    {
                        bv.Clear(bit);
                        count++;
                        Assert.AreEqual(numBits - count, bv.Count());
                    }
                }
            }

            d.Dispose();
        }
예제 #2
0
        public virtual void TestClearedBitNearEnd()
        {
            Directory d       = NewDirectory();
            int       numBits = TestUtil.NextInt(Random(), 7, 1000);
            BitVector bv      = new BitVector(numBits);

            bv.InvertAll();
            bv.Clear(numBits - TestUtil.NextInt(Random(), 1, 7));
            bv.Write(d, "test", NewIOContext(Random()));
            Assert.AreEqual(numBits - 1, bv.Count());
            d.Dispose();
        }