Ejemplo n.º 1
0
        public void ShouldSetBit(int index, byte[] leftBits, byte[] expectedResult)
        {
            dba.SetLeftBits(leftBits, 0, 0, leftBits.Length * 8);
            dba.SetBit(index);
            var actualResult = dba.ToByteArray();

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets a range of bits from the given source bits array to the 0-based index in the destination "left"
        /// bit array.
        /// </summary>
        /// <param name="sourceBits">The source data to set to the "left" bit array.</param>
        /// <param name="sourceArrayBitIndex">The 0-based bit index within the source array where copying starts.
        /// </param>
        /// <param name="destinationBitIndex">The 0-based bit index within the "right" bit array that starts to
        /// received the copied bits.</param>
        /// <param name="numBits">The number of bits to copy from the source bit array to the "left" bit array.
        /// </param>
        /// <returns>A reference to the invoked object for a "fluent" interface.</returns>
        public IWriteableDuoBitArray SetLeftBits(byte[] sourceBits, int sourceArrayBitIndex,
                                                 int destinationBitIndex, int numBits)
        {
            duoBitArray.SetLeftBits(sourceBits, sourceArrayBitIndex, destinationBitIndex, numBits);

            var sourceBitsMask = GetMaskForConsecutiveLeftBits(numBits);

            mask.SetLeftBits(sourceBitsMask, sourceArrayBitIndex, destinationBitIndex, numBits);
            return(this);
        }