Beispiel #1
0
        public void GetUInt32_Be()
        {
            UInt32[] values =
            {
                0x00000055,
                0x000000aa,

                0x000055aa,
                0x0000aa55,

                0x0055aa55,
                0x00aa55aa,

                0x55aa55aa,
                0xaa55aa55,

                0x01234567,
                0x89abcdef,

                0xfedcba98,
                0x76543210
            };
            byte[] buffer    = new byte[values.Length * 4];
            int    destIndex = 0;

            for (int i = 0; i < values.Length; i++)
            {
                buffer[destIndex++] = (byte)((values[i] >> 24) & 0xff);
                buffer[destIndex++] = (byte)((values[i] >> 16) & 0xff);
                buffer[destIndex++] = (byte)((values[i] >> 8) & 0xff);
                buffer[destIndex++] = (byte)((values[i] >> 0) & 0xff);
            }
            BitPack bitPack = new BitPack(buffer);

            for (int i = 0; i < values.Length; i++)
            {
                UInt32 v = bitPack.GetUInt32_Be();
                Assert.AreEqual(values[i], v);
            }
        }