Beispiel #1
0
        public void ByteSwap_SwapIntegersTest()
        {
            ulong value_before = kBeforeValue;
            ulong value_after  = kAfterValue;

            // UInt64
            Assert.AreEqual(value_after, ByteSwap.SwapUInt64(value_before));
            Assert.AreEqual((long)value_after, ByteSwap.SwapInt64((long)value_before));

            // UInt32
            value_before >>= 32;
            value_after  >>= 32;
            Assert.AreEqual((uint)value_after, ByteSwap.SwapUInt32((uint)value_before));
            Assert.AreEqual((int)value_after, ByteSwap.SwapInt32((int)value_before));

            // UInt16
            value_before >>= 16;
            value_after  >>= 16;
            Assert.AreEqual((ushort)value_after, ByteSwap.SwapUInt16((ushort)value_before));
            Assert.AreEqual((short)value_after, ByteSwap.SwapInt16((short)value_before));

            // UInt40
            value_before = kBeforeValueUInt40;
            value_after  = kAfterValueUInt40;
            Assert.AreEqual(value_after, ByteSwap.SwapUInt40(value_before));
            Assert.AreEqual((long)value_after, ByteSwap.SwapInt40((long)value_before));

            // UInt24
            value_before = kBeforeValueUInt24;
            value_after  = kAfterValueUInt24;
            Assert.AreEqual((uint)value_after, ByteSwap.SwapUInt24((uint)value_before));
            Assert.AreEqual((int)value_after, ByteSwap.SwapInt24((int)value_before));
        }