예제 #1
0
        public void TestDoubleWBESToW()
        {
            byte[] result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((double)1));
            ArrayAssertion.AssertByteArrayEquals("converted wbe double", new byte[] { 0x3F, 0xF0, 0, 0, 0, 0, 0, 0 }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((double)0.01));
            ArrayAssertion.AssertByteArrayEquals("converted wbe double (2)", new byte[] { 0x3F, 0x84, 0x7A, 0xE1, 0x47, 0xAE, 0x14, 0x7B }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(Double.MaxValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe double (3)", new byte[] { 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(Double.MinValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe double (4)", new byte[] { 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, result);
        }
예제 #2
0
        public void TestDoubleWBEWToS()
        {
            System.Double result =
                BitConverterUtils.Reverse(BitConverter.ToDouble(new byte[] { 0x3F, 0xF0, 0, 0, 0, 0, 0, 0 }, 0));
            Assert.AreEqual(1.0, result, "converted wbe double");

            result =
                BitConverterUtils.Reverse(BitConverter.ToDouble(new byte[] { 0x3F, 0x84, 0x7A, 0xE1, 0x47, 0xAE, 0x14, 0x7B }, 0));
            Assert.AreEqual(0.01, result, "converted wbe double (2)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToDouble(new byte[] { 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, 0));
            Assert.AreEqual(Double.MaxValue, result, "converted wbe double (3)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToDouble(new byte[] { 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, 0));
            Assert.AreEqual(Double.MinValue, result, "converted wbe double (4)");
        }
예제 #3
0
        public void TestSingleWBESToW()
        {
            byte[] result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((float)1));
            ArrayAssertion.AssertByteArrayEquals("converted wbe single", new byte[] { 0x3F, 0x80, 0x00, 0x00 }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((float)0.01));
            ArrayAssertion.AssertByteArrayEquals("converted wbe single (2)", new byte[] { 0x3C, 0x23, 0xD7, 0x0A }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(Single.MaxValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe single (3)", new byte[] { 0x7F, 0x7F, 0xFF, 0xFF }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(Single.MinValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe single (4)", new byte[] { 0xFF, 0x7F, 0xFF, 0xFF }, result);
        }
예제 #4
0
        public void TestSingleWBEWToS()
        {
            System.Single result =
                BitConverterUtils.Reverse(BitConverter.ToSingle(new byte[] { 0x3F, 0x80, 0x00, 0x00 }, 0));
            Assert.AreEqual((float)1.0f, result, "converted wbe single");

            result =
                BitConverterUtils.Reverse(BitConverter.ToSingle(new byte[] { 0x3C, 0x23, 0xD7, 0x0A }, 0));
            Assert.AreEqual((float)0.01f, result, "converted wbe single (2)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToSingle(new byte[] { 0x7F, 0x7F, 0xFF, 0xFF }, 0));
            Assert.AreEqual(Single.MaxValue, result, "converted wbe single (3)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToSingle(new byte[] { 0xFF, 0x7F, 0xFF, 0xFF }, 0));
            Assert.AreEqual(Single.MinValue, result, "converted wbe single (4)");
        }
예제 #5
0
        public void TestUInt64WBESToW()
        {
            byte[] result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((ulong)1));
            ArrayAssertion.AssertByteArrayEquals("converted wbe uint 64", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((ulong)258));
            ArrayAssertion.AssertByteArrayEquals("converted wbe uint 64 (2)", new byte[] { 0, 0, 0, 0, 0, 0, 1, 2 }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(UInt64.MaxValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe uint 64 (3)", new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(UInt64.MinValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe uint 64 (4)", new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, result);
        }
예제 #6
0
        public void TestInt32WBESToW()
        {
            byte[] result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((int)1));
            ArrayAssertion.AssertByteArrayEquals("converted wbe int 32", new byte[] { 0, 0, 0, 1 }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse((int)258));
            ArrayAssertion.AssertByteArrayEquals("converted wbe int 32 (2)", new byte[] { 0, 0, 1, 2 }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(Int32.MaxValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe int 32 (3)", new byte[] { 0x7F, 0xFF, 0xFF, 0xFF }, result);

            result =
                BitConverter.GetBytes(BitConverterUtils.Reverse(Int32.MinValue));
            ArrayAssertion.AssertByteArrayEquals("converted wbe int 32 (4)", new byte[] { 0x80, 0x00, 0x00, 0x00 }, result);
        }
예제 #7
0
        public void TestUInt64WBEWToS()
        {
            System.UInt64 result =
                BitConverterUtils.Reverse(BitConverter.ToUInt64(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, 0));
            Assert.AreEqual(1, result, "converted wbe uint 64");

            result =
                BitConverterUtils.Reverse(BitConverter.ToUInt64(new byte[] { 0, 0, 0, 0, 0, 0, 1, 2 }, 0));
            Assert.AreEqual(258, result, "converted wbe uint 64 (2)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToUInt64(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, 0));
            Assert.AreEqual(UInt64.MaxValue, result, "converted wbe uint 64 (3)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToUInt64(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0));
            Assert.AreEqual(UInt64.MinValue, result, "converted wbe uint 64 (4)");
        }
예제 #8
0
        public void TestInt32WBEWToS()
        {
            System.Int32 result =
                BitConverterUtils.Reverse(BitConverter.ToInt32(new byte[] { 0, 0, 0, 1 }, 0));
            Assert.AreEqual(1, result, "converted wbe int 32");

            result =
                BitConverterUtils.Reverse(BitConverter.ToInt32(new byte[] { 0, 0, 1, 2 }, 0));
            Assert.AreEqual(258, result, "converted wbe int 32 (2)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToInt32(new byte[] { 0x7F, 0xFF, 0xFF, 0xFF }, 0));
            Assert.AreEqual(Int32.MaxValue, result, "converted wbe int 32 (3)");

            result =
                BitConverterUtils.Reverse(BitConverter.ToInt32(new byte[] { 0x80, 0x00, 0x00, 0x00 }, 0));
            Assert.AreEqual(Int32.MinValue, result, "converted wbe int 32 (4)");
        }