예제 #1
0
        public void GetBytesFromDoubleTest()
        {
            var bc    = new StraightBitConverter();
            var bytes = new byte[8];

            bc.GetBytes(1.0, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-F0-3F", ByteArrayToString(bytes));

            bc.GetBytes(-1.0, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-F0-BF", ByteArrayToString(bytes));
        }
예제 #2
0
        public void GetBytesFromBooleanTest()
        {
            var bc    = new StraightBitConverter();
            var bytes = new byte[1];

            bc.GetBytes(true, bytes, 0);
            Assert.AreEqual("01", ByteArrayToString(bytes));

            bc.GetBytes(false, bytes, 0);
            Assert.AreEqual("00", ByteArrayToString(bytes));
        }
예제 #3
0
        public void GetBytesFromDoubleTest()
        {
            var bc = new StraightBitConverter();
            var bytes = new byte[8];

            bc.GetBytes(1.0, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-F0-3F", ByteArrayToString(bytes));

            bc.GetBytes(-1.0, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-F0-BF", ByteArrayToString(bytes));
        }
예제 #4
0
        public void GetBytesFromBooleanTest()
        {
            var bc = new StraightBitConverter();
            var bytes = new byte[1];

            bc.GetBytes(true, bytes, 0);
            Assert.AreEqual("01", ByteArrayToString(bytes));

            bc.GetBytes(false, bytes, 0);
            Assert.AreEqual("00", ByteArrayToString(bytes));
        }
예제 #5
0
        public void GetBytesFromUInt64Test()
        {
            var bc    = new StraightBitConverter();
            var bytes = new byte[8];

            bc.GetBytes(0UL, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes(1UL, bytes, 0);
            Assert.AreEqual("01-00-00-00-00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes(UInt64.MinValue, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes(UInt64.MaxValue, bytes, 0);
            Assert.AreEqual("FF-FF-FF-FF-FF-FF-FF-FF", ByteArrayToString(bytes));
        }
예제 #6
0
        public void GetBytesFromInt32Test()
        {
            var bc    = new StraightBitConverter();
            var bytes = new byte[4];

            bc.GetBytes((Int32)0, bytes, 0);
            Assert.AreEqual("00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes((Int32)1, bytes, 0);
            Assert.AreEqual("01-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes((Int32)(-1), bytes, 0);
            Assert.AreEqual("FF-FF-FF-FF", ByteArrayToString(bytes));

            bc.GetBytes(Int32.MinValue, bytes, 0);
            Assert.AreEqual("00-00-00-80", ByteArrayToString(bytes));

            bc.GetBytes(Int32.MaxValue, bytes, 0);
            Assert.AreEqual("FF-FF-FF-7F", ByteArrayToString(bytes));
        }
예제 #7
0
        public void GetBytesFromInt32Test()
        {
            var bc = new StraightBitConverter();
            var bytes = new byte[4];

            bc.GetBytes((Int32)0, bytes, 0);
            Assert.AreEqual("00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes((Int32)1, bytes, 0);
            Assert.AreEqual("01-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes((Int32)(-1), bytes, 0);
            Assert.AreEqual("FF-FF-FF-FF", ByteArrayToString(bytes));

            bc.GetBytes(Int32.MinValue, bytes, 0);
            Assert.AreEqual("00-00-00-80", ByteArrayToString(bytes));

            bc.GetBytes(Int32.MaxValue, bytes, 0);
            Assert.AreEqual("FF-FF-FF-7F", ByteArrayToString(bytes));
        }
예제 #8
0
        public void GetBytesFromUInt64Test()
        {
            var bc = new StraightBitConverter();
            var bytes = new byte[8];

            bc.GetBytes(0UL, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes(1UL, bytes, 0);
            Assert.AreEqual("01-00-00-00-00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes(UInt64.MinValue, bytes, 0);
            Assert.AreEqual("00-00-00-00-00-00-00-00", ByteArrayToString(bytes));

            bc.GetBytes(UInt64.MaxValue, bytes, 0);
            Assert.AreEqual("FF-FF-FF-FF-FF-FF-FF-FF", ByteArrayToString(bytes));
        }