コード例 #1
0
        public void TestWireEncoderWriteDouble()
        {
            int off = BUFSIZE - 8;
            WireEncoder e = new WireEncoder();
            for (int i = 0; i < off; i++)
            {
                e.Write8(0);
            }
            e.WriteDouble(0.0);
            e.WriteDouble(2.3e5);
            e.WriteDouble(double.PositiveInfinity);
            e.WriteDouble(2.2250738585072014e-308);//Minimum double size
            e.WriteDouble(double.MaxValue);

            Assert.That(e.Buffer.Length - off, Is.EqualTo(40));
            byte[] checkArray =
            {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x41, 0x0c, 0x13, 0x80, 0x00, 0x00, 0x00, 0x00,
                0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
            };
            byte[] bufferArray = new byte[checkArray.Length];
            Array.Copy(e.Buffer, off, bufferArray, 0, checkArray.Length);
            Assert.That(bufferArray, Is.EquivalentTo(checkArray));
        }