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