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 ToInt16(byte[] input, short expected) { Assert.Equal(expected, PolyfillBitConverter.ToInt16(input.AsSpan())); }