public void TryWriteChar(byte[] expected, char input)
        {
            var insufficientBuffer = new byte[expected.Length - 1];

            Assert.False(PolyfillBitConverter.TryWriteBytes(insufficientBuffer.AsSpan(), input));
            var buffer = new byte[expected.Length];

            Assert.True(PolyfillBitConverter.TryWriteBytes(buffer.AsSpan(), input));
            Assert.True(expected.SequenceEqual(buffer));
        }
 public void InsufficientTo()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToInt16(new byte[sizeof(short) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToInt32(new byte[sizeof(int) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToInt64(new byte[sizeof(long) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToUInt16(new byte[sizeof(ushort) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToUInt32(new byte[sizeof(uint) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToUInt64(new byte[sizeof(ulong) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToSingle(new byte[sizeof(float) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToDouble(new byte[sizeof(double) - 1].AsSpan()));
     Assert.Throws <ArgumentOutOfRangeException>(() => PolyfillBitConverter.ToChar(new byte[sizeof(char) - 1].AsSpan()));
 }
 public void ToChar(byte[] input, char expected)
 {
     Assert.Equal(expected, PolyfillBitConverter.ToChar(input.AsSpan()));
 }
 public void ToDouble(byte[] input, double expected)
 {
     Assert.Equal(expected, PolyfillBitConverter.ToDouble(input.AsSpan()));
 }
 public void ToSingle(byte[] input, float expected)
 {
     Assert.Equal(expected, PolyfillBitConverter.ToSingle(input.AsSpan()));
 }
 public void ToUInt64(byte[] input, ulong expected)
 {
     Assert.Equal(expected, PolyfillBitConverter.ToUInt64(input.AsSpan()));
 }
 public void ToUInt16(byte[] input, ushort expected)
 {
     Assert.Equal(expected, PolyfillBitConverter.ToUInt16(input.AsSpan()));
 }
 public void ToInt32(byte[] input, int expected)
 {
     Assert.Equal(expected, PolyfillBitConverter.ToInt32(input.AsSpan()));
 }