Esempio n. 1
0
        private void DoTestSetUnSetAroundWindow(int dataSize, int window)
        {
            BitArrayBin toTest = new BitArrayBin(window);

            for (int i = 0; i <= dataSize; i++)
            {
                Assert.IsTrue(!toTest.SetBit(i, true), "not already set");
            }

            int windowOfValidData = RoundWindow(dataSize, window);

            for (int i = dataSize; i >= 0 && i >= dataSize - windowOfValidData; i--)
            {
                Assert.IsTrue(toTest.SetBit(i, false), "was already set, id=" + i);
            }

            for (int i = 0; i <= dataSize; i++)
            {
                Assert.IsTrue(!toTest.SetBit(i, false), "not already set, id:" + i);
            }

            for (int j = 2 * dataSize; j < 4 * dataSize; j++)
            {
                Assert.IsTrue(!toTest.SetBit(j, true), "not already set: id=" + j);
            }
        }
Esempio n. 2
0
        private void DoTestSetAroundWindow(int window, int dataSize)
        {
            BitArrayBin toTest = new BitArrayBin(window);

            for (int ix = 0; ix <= dataSize; ix++)
            {
                Assert.IsTrue(!toTest.SetBit(ix, true), "not already set");
                Assert.AreEqual(ix, toTest.GetLastSetIndex(), "current is max");
            }

            Assert.AreEqual(dataSize, toTest.GetLastSetIndex(), "last is max");

            int windowOfValidData = RoundWindow(dataSize, window);
            int i = dataSize;

            for (; i >= dataSize - windowOfValidData; i--)
            {
                Assert.IsTrue(toTest.SetBit(i, true), "was already set, id=" + i);
            }

            Assert.AreEqual(dataSize, toTest.GetLastSetIndex(), "last is still max");

            for (; i >= 0; i--)
            {
                Assert.IsTrue(!toTest.SetBit(i, true), "was not already set, id=" + i);
            }

            for (int j = dataSize + 1; j <= (2 * dataSize); j++)
            {
                Assert.IsTrue(!toTest.SetBit(j, true), "not already set: id=" + j);
            }

            Assert.AreEqual(2 * dataSize, toTest.GetLastSetIndex(), "last still max*2");
        }
Esempio n. 3
0
        public void TestSetHiLo()
        {
            BitArrayBin toTest = new BitArrayBin(50);

            toTest.SetBit(0, true);
            toTest.SetBit(100, true);
            toTest.SetBit(150, true);
            Assert.IsTrue(toTest.GetBit(0));

            toTest.SetBit(0, true);
            Assert.IsTrue(toTest.GetBit(0));
        }
Esempio n. 4
0
        private void DoTestLargeGapInData(int window)
        {
            BitArrayBin toTest = new BitArrayBin(window);

            int instance = BitArray.LONG_SIZE;

            Assert.IsTrue(!toTest.SetBit(instance, true), "not already set: id=" + instance);

            instance = 12 * BitArray.LONG_SIZE;
            Assert.IsTrue(!toTest.SetBit(instance, true), "not already set: id=" + instance);

            instance = 9 * BitArray.LONG_SIZE;
            Assert.IsTrue(!toTest.SetBit(instance, true), "not already set: id=" + instance);
        }
Esempio n. 5
0
        public void TestLastSeq()
        {
            BitArrayBin toTest = new BitArrayBin(512);

            Assert.AreEqual(-1, toTest.GetLastSetIndex(), "last not set");

            toTest.SetBit(1, true);
            Assert.AreEqual(1, toTest.GetLastSetIndex(), "last not correct");

            toTest.SetBit(64, true);
            Assert.AreEqual(64, toTest.GetLastSetIndex(), "last not correct");

            toTest.SetBit(68, true);
            Assert.AreEqual(68, toTest.GetLastSetIndex(), "last not correct");
        }
Esempio n. 6
0
        public void TestSetAroundLongSizeMultiplier()
        {
            int window   = 512;
            int dataSize = 1000;

            for (int muliplier = 1; muliplier < 8; muliplier++)
            {
                for (int i = 0; i < dataSize; i++)
                {
                    BitArrayBin toTest = new BitArrayBin(window);

                    int instance = i + muliplier * BitArray.LONG_SIZE;
                    Assert.IsTrue(!toTest.SetBit(instance, true), "not already set: id=" + instance);
                    Assert.IsTrue(!toTest.SetBit(i, true), "not already set: id=" + i);
                    Assert.AreEqual(instance, toTest.GetLastSetIndex(), "max set correct");
                }
            }
        }