Esempio n. 1
0
        public void Test_ToSingle_UseNbo()
        {
            var   converter = new DefaultConverter();
            float theDouble = 2.3f;

            var         bytes    = BitConverter.GetBytes(theDouble).Reverse().ToArray();
            var         actual   = converter.ToSingle(bytes, 0, true);
            const float expected = 2.3f;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void Test_ToSingle()
        {
            var   converter = new DefaultConverter();
            float theSingle = 2.3f;

            var         bytes    = BitConverter.GetBytes(theSingle);
            var         actual   = converter.ToSingle(bytes, 0, false);
            const float expected = 2.3f;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void Test_ToSingle(float value, bool useNbo)
        {
            var converter = new DefaultConverter();

            var bytes = BitConverter.GetBytes(value);

            if (useNbo)
            {
                bytes = bytes.Reverse().ToArray();
            }

            var actual = converter.ToSingle(bytes.AsSpan(), useNbo);

            Assert.Equal(value, actual);
        }