Esempio n. 1
0
        public void Enum_BitEncoderHashCode32Test()
        {
            var ss = new Memory.Strings.StringStorage(
                Memory.Strings.StringStorageWidthType.UTF32,
                Memory.Strings.StringStorageType.CharArray,
                Shell.EndianFormat.Big, 16);
            uint bits      = 0;
            int  bit_index = 0;

            TypeExtensions.BitEncoders.StringStorageWidthType.BitEncode(ss.WidthType, ref bits, ref bit_index);
            TypeExtensions.BitEncoders.StringStorageType.BitEncode(ss.Type, ref bits, ref bit_index);
            TypeExtensions.BitEncoders.EndianFormat.BitEncode(ss.ByteOrder, ref bits, ref bit_index);
            Bits.BitEncodeEnum((uint)ss.FixedLength, ref bits, ref bit_index, 0x7FFF);

            bits      = (uint)ss.GetHashCode();
            bit_index = 0;
            var widthType   = TypeExtensions.BitEncoders.StringStorageWidthType.BitDecode(bits, ref bit_index);
            var type        = TypeExtensions.BitEncoders.StringStorageType.BitDecode(bits, ref bit_index);
            var byteOrder   = TypeExtensions.BitEncoders.EndianFormat.BitDecode(bits, ref bit_index);
            var fixedLength = (short)Bits.BitDecode(bits, ref bit_index, 0x7FFF);

            Assert.AreEqual(ss.WidthType, widthType);
            Assert.AreEqual(ss.Type, type);
            Assert.AreEqual(ss.ByteOrder, byteOrder);
            Assert.AreEqual(ss.FixedLength, fixedLength);
        }
Esempio n. 2
0
        /// <summary>Bit decode a value from this handle</summary>
        /// <param name="value">Value decoded from this handle</param>
        /// <param name="traits"></param>
        public void Decode64(out ulong value, Bitwise.BitFieldTraits traits)
        {
            Contract.Requires <ArgumentException>(!traits.IsEmpty);

            value = (ulong)Bits.BitDecode(mBits.u64, ref mBitIndex, traits.Bitmask64);
        }
Esempio n. 3
0
        /// <summary>Bit decode a value from this handle</summary>
        /// <param name="value">Value decoded from this handle</param>
        /// <param name="bitMask">Masking value for <paramref name="value"/></param>
        public void Decode64(out ulong value, ulong bitMask)
        {
            Contract.Requires <ArgumentException>(bitMask != 0);

            value = (ulong)Bits.BitDecode(mBits.u64, ref mBitIndex, bitMask);
        }
Esempio n. 4
0
        /// <summary>Bit decode a value from this handle</summary>
        /// <param name="value">Value decoded from this handle</param>
        /// <param name="traits"></param>
        public void Decode32(out uint value, Bitwise.BitFieldTraits traits)
        {
            Contract.Requires <ArgumentException>(!traits.IsEmpty);

            value = (uint)Bits.BitDecode(mBits.u64, ref mBitIndex, traits.Bitmask32);
        }
Esempio n. 5
0
        /// <summary>Bit decode a value from this handle</summary>
        /// <param name="value">Value decoded from this handle</param>
        /// <param name="bitMask">Masking value for <paramref name="value"/></param>
        public void Decode32(out uint value, uint bitMask)
        {
            Contract.Requires <ArgumentException>(bitMask != 0);

            value = (uint)Bits.BitDecode(mBits.u64, ref mBitIndex, bitMask);
        }