public void SignedIntegersConversionOfTwoWithSignExtensionTest() { object[] withSignExtension = new object[] { CompileUncheckedConverter <sbyte, byte>(extendSign: true)(2), CompileUncheckedConverter <sbyte, ushort>(extendSign: true)(2), CompileUncheckedConverter <short, ushort>(extendSign: true)(2), CompileUncheckedConverter <sbyte, uint>(extendSign: true)(2), CompileUncheckedConverter <short, uint>(extendSign: true)(2), CompileUncheckedConverter <int, uint>(extendSign: true)(2), CompileUncheckedConverter <sbyte, ulong>(extendSign: true)(2), CompileUncheckedConverter <short, ulong>(extendSign: true)(2), CompileUncheckedConverter <int, ulong>(extendSign: true)(2), CompileUncheckedConverter <long, ulong>(extendSign: true)(2) }; object[] withoutSignExtension = new object[] { CompileUncheckedConverter <sbyte, byte>(extendSign: false)(2), CompileUncheckedConverter <sbyte, ushort>(extendSign: false)(2), CompileUncheckedConverter <short, ushort>(extendSign: false)(2), CompileUncheckedConverter <sbyte, uint>(extendSign: false)(2), CompileUncheckedConverter <short, uint>(extendSign: false)(2), CompileUncheckedConverter <int, uint>(extendSign: false)(2), CompileUncheckedConverter <sbyte, ulong>(extendSign: false)(2), CompileUncheckedConverter <short, ulong>(extendSign: false)(2), CompileUncheckedConverter <int, ulong>(extendSign: false)(2), CompileUncheckedConverter <long, ulong>(extendSign: false)(2) }; for (var i = 0; i < withSignExtension.Length; i++) { Assert.Equal(2UL, Convert.ToUInt64(withSignExtension[i])); Assert.Equal(withSignExtension[i], withoutSignExtension[i]); } }
public void SignedIntegersConversionOfMinusOneWithSignExtensionTest() { object[] withSignExtension = new object[] { CompileUncheckedConverter <sbyte, byte>(extendSign: true)(-1), CompileUncheckedConverter <sbyte, ushort>(extendSign: true)(-1), CompileUncheckedConverter <short, ushort>(extendSign: true)(-1), CompileUncheckedConverter <sbyte, uint>(extendSign: true)(-1), CompileUncheckedConverter <short, uint>(extendSign: true)(-1), CompileUncheckedConverter <int, uint>(extendSign: true)(-1), CompileUncheckedConverter <sbyte, ulong>(extendSign: true)(-1), CompileUncheckedConverter <short, ulong>(extendSign: true)(-1), CompileUncheckedConverter <int, ulong>(extendSign: true)(-1), CompileUncheckedConverter <long, ulong>(extendSign: true)(-1) }; object[] withoutSignExtension = new object[] { CompileUncheckedConverter <sbyte, byte>(extendSign: false)(-1), CompileUncheckedConverter <sbyte, ushort>(extendSign: false)(-1), CompileUncheckedConverter <short, ushort>(extendSign: false)(-1), CompileUncheckedConverter <sbyte, uint>(extendSign: false)(-1), CompileUncheckedConverter <short, uint>(extendSign: false)(-1), CompileUncheckedConverter <int, uint>(extendSign: false)(-1), CompileUncheckedConverter <sbyte, ulong>(extendSign: false)(-1), CompileUncheckedConverter <short, ulong>(extendSign: false)(-1), CompileUncheckedConverter <int, ulong>(extendSign: false)(-1), CompileUncheckedConverter <long, ulong>(extendSign: false)(-1) }; var i = 0; Assert.Equal((byte)255, (byte)withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal((ushort)65535, (ushort)withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal((ushort)65535, (ushort)withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(4294967295, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(4294967295, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(4294967295, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(18446744073709551615, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(18446744073709551615, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(18446744073709551615, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(18446744073709551615, withSignExtension[i]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); }
public void UnsignedIntegersConversionWithSignExtensionTest() { object[] withSignExtension = new object[] { CompileUncheckedConverter <byte, sbyte>(extendSign: true)(128), CompileUncheckedConverter <byte, short>(extendSign: true)(128), CompileUncheckedConverter <ushort, short>(extendSign: true)(32768), CompileUncheckedConverter <byte, int>(extendSign: true)(128), CompileUncheckedConverter <ushort, int>(extendSign: true)(32768), CompileUncheckedConverter <uint, int>(extendSign: true)(2147483648), CompileUncheckedConverter <byte, long>(extendSign: true)(128), CompileUncheckedConverter <ushort, long>(extendSign: true)(32768), CompileUncheckedConverter <uint, long>(extendSign: true)(2147483648), CompileUncheckedConverter <ulong, long>(extendSign: true)(9223372036854775808) }; object[] withoutSignExtension = new object[] { CompileUncheckedConverter <byte, sbyte>(extendSign: false)(128), CompileUncheckedConverter <byte, short>(extendSign: false)(128), CompileUncheckedConverter <ushort, short>(extendSign: false)(32768), CompileUncheckedConverter <byte, int>(extendSign: false)(128), CompileUncheckedConverter <ushort, int>(extendSign: false)(32768), CompileUncheckedConverter <uint, int>(extendSign: false)(2147483648), CompileUncheckedConverter <byte, long>(extendSign: false)(128), CompileUncheckedConverter <ushort, long>(extendSign: false)(32768), CompileUncheckedConverter <uint, long>(extendSign: false)(2147483648), CompileUncheckedConverter <ulong, long>(extendSign: false)(9223372036854775808) }; var i = 0; Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.NotEqual(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.NotEqual(withSignExtension[i], withoutSignExtension[i++]); Assert.NotEqual(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); Assert.NotEqual(withSignExtension[i], withoutSignExtension[i++]); Assert.NotEqual(withSignExtension[i], withoutSignExtension[i++]); Assert.NotEqual(withSignExtension[i], withoutSignExtension[i++]); Assert.Equal(withSignExtension[i], withoutSignExtension[i++]); }