Ejemplo n.º 1
0
        public virtual void FloatDecode()
        {
            object obj = null;

            byte[] data = new byte[4];
            data[0] = 255;
            data[1] = 255;
            data[2] = 127;
            data[3] = 127;
            obj     = datatype.Decode(data);
            Assert.True(obj is float);
            Assert.True(((float)obj) == float.MaxValue);

            data[0] = 255;
            data[1] = 255;
            data[2] = 127;
            data[3] = 255;
            obj     = datatype.Decode(data);
            Assert.True(obj is float);
            Assert.True(((float)obj) == float.MinValue);

            data[0] = 0;
            data[1] = 0;
            data[2] = 0;
            data[3] = 0;
            obj     = datatype.Decode(data);
            Assert.True(obj is float);
            Assert.True(((float)obj) == 0);

            data[0] = 0;
            data[1] = 0;
            data[2] = 128;
            data[3] = 191;
            obj     = datatype.Decode(data);
            Assert.True(obj is float);
            Assert.True(((float)obj) == -1);
        }