Ejemplo n.º 1
0
        public void Operations_Bits()
        {
            Assert.Equal(0x0000000000000001UL, BitVector.BitInWord(63));
            Assert.Equal(0x0000000000000002UL, BitVector.BitInWord(62));
            Assert.Equal(0x0000000000000004UL, BitVector.BitInWord(61));
            Assert.Equal(0x0000000000000008UL, BitVector.BitInWord(60));
            Assert.Equal(0x8000000000000000UL, BitVector.BitInWord(0));

            for (int i = 0; i < BitVector.BitsPerWord; i++)
            {
                Assert.Equal(BitVector.BitInWord(i), BitVector.BitInWord(i + BitVector.BitsPerWord));
            }

            Assert.Equal(0U, BitVector.WordForBit(0));
            Assert.Equal(0U, BitVector.WordForBit(1));
            Assert.Equal(0U, BitVector.WordForBit(63));
            Assert.Equal(1U, BitVector.WordForBit(64));
            Assert.Equal(1U, BitVector.WordForBit(127));
            Assert.Equal(2U, BitVector.WordForBit(128));

            Assert.Equal(0, BitVector.NumberOfWordsForBits(0));
            Assert.Equal(1, BitVector.NumberOfWordsForBits(1));
            Assert.Equal(2, BitVector.NumberOfWordsForBits(128));
            Assert.Equal(3, BitVector.NumberOfWordsForBits(129));
        }