예제 #1
0
        public void Test_ToBoolean_UseNbo()
        {
            var        converter = new DefaultConverter();
            bool       theBool   = true;
            var        bytes     = BitConverter.GetBytes(theBool).Reverse().ToArray();
            var        actual    = converter.ToBoolean(bytes, 0, true);
            const bool expected  = true;

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void Test_ToBoolean()
        {
            var        converter = new DefaultConverter();
            bool       theBool   = true;
            var        bytes     = BitConverter.GetBytes(theBool);
            var        actual    = converter.ToBoolean(bytes, 0, false);
            const bool expected  = true;

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void Test_ToBoolean(bool value, bool useNbo)
        {
            var converter = new DefaultConverter();
            var bytes     = BitConverter.GetBytes(value);

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

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

            Assert.Equal(value, actual);
        }