public void Ok() { MyConvert.GetValue <int>("0").Should().Be(0); MyConvert.GetValue <int>("123").Should().Be(123); MyConvert.GetValue <int>("-123").Should().Be(-123); MyConvert.GetValue <int>("-0").Should().Be(0); }
public void GetValueMinMax() { MyConvert.GetValue <sbyte>(sbyte.MinValue.ToString()).Should().Be(sbyte.MinValue); MyConvert.GetValue <sbyte>(sbyte.MaxValue.ToString()).Should().Be(sbyte.MaxValue); MyConvert.GetValue <byte>(byte.MinValue.ToString()).Should().Be(byte.MinValue); MyConvert.GetValue <byte>(byte.MaxValue.ToString()).Should().Be(byte.MaxValue); MyConvert.GetValue <short>(short.MinValue.ToString()).Should().Be(short.MinValue); MyConvert.GetValue <short>(short.MaxValue.ToString()).Should().Be(short.MaxValue); MyConvert.GetValue <int>(int.MinValue.ToString()).Should().Be(int.MinValue); MyConvert.GetValue <int>(int.MaxValue.ToString()).Should().Be(int.MaxValue); MyConvert.GetValue <long>(long.MinValue.ToString()).Should().Be(long.MinValue); MyConvert.GetValue <long>(long.MaxValue.ToString()).Should().Be(long.MaxValue); MyConvert.GetValue <ushort>(ushort.MinValue.ToString()).Should().Be(ushort.MinValue); MyConvert.GetValue <ushort>(ushort.MaxValue.ToString()).Should().Be(ushort.MaxValue); MyConvert.GetValue <uint>(uint.MinValue.ToString()).Should().Be(uint.MinValue); MyConvert.GetValue <uint>(uint.MaxValue.ToString()).Should().Be(uint.MaxValue); MyConvert.GetValue <ulong>(ulong.MinValue.ToString()).Should().Be(ulong.MinValue); MyConvert.GetValue <ulong>(ulong.MaxValue.ToString()).Should().Be(ulong.MaxValue); MyConvert.GetValue <float>(float.MinValue.ToString()).Should().Be(float.MinValue); MyConvert.GetValue <float>(float.MaxValue.ToString()).Should().Be(float.MaxValue); MyConvert.GetValue <double>(double.MinValue.ToString()).Should().Be(double.MinValue); MyConvert.GetValue <double>(double.MaxValue.ToString()).Should().Be(double.MaxValue); }
public void Ok() { MyConvert.GetValueFromHex <int>("0").Should().Be(0); MyConvert.GetValueFromHex <int>("123").Should().Be(0x123); MyConvert.GetValueFromHex <int>("ff").Should().Be(0xff); MyConvert.GetValueFromHex <int>("FF").Should().Be(0xff); MyConvert.GetValueFromHex <int>("0xff").Should().Be(0xff); MyConvert.GetValueFromHex <int>("0XFF").Should().Be(0xff); MyConvert.GetValueFromHex <int>("0ff").Should().Be(0xff); MyConvert.GetValueFromHex <int>("0x0ff").Should().Be(0xff); }
public void GetValueMinMax() { MyConvert.GetValueFromHex <short>(short.MinValue.ToString("X")).Should().Be(short.MinValue); MyConvert.GetValueFromHex <short>(short.MaxValue.ToString("X")).Should().Be(short.MaxValue); MyConvert.GetValueFromHex <int>(int.MinValue.ToString("X")).Should().Be(int.MinValue); MyConvert.GetValueFromHex <int>(int.MaxValue.ToString("X")).Should().Be(int.MaxValue); MyConvert.GetValueFromHex <long>(long.MinValue.ToString("X")).Should().Be(long.MinValue); MyConvert.GetValueFromHex <long>(long.MaxValue.ToString("X")).Should().Be(long.MaxValue); MyConvert.GetValueFromHex <ushort>(ushort.MinValue.ToString("X")).Should().Be(ushort.MinValue); MyConvert.GetValueFromHex <ushort>(ushort.MaxValue.ToString("X")).Should().Be(ushort.MaxValue); MyConvert.GetValueFromHex <uint>(uint.MinValue.ToString("X")).Should().Be(uint.MinValue); MyConvert.GetValueFromHex <uint>(uint.MaxValue.ToString("X")).Should().Be(uint.MaxValue); MyConvert.GetValueFromHex <ulong>(ulong.MinValue.ToString("X")).Should().Be(ulong.MinValue); MyConvert.GetValueFromHex <ulong>(ulong.MaxValue.ToString("X")).Should().Be(ulong.MaxValue); }
public void OverflowExceptionUnsigned() { Func <ushort> func0 = () => MyConvert.GetValue <ushort>("-1"); func0.Should().Throw <OverflowException>(); Func <ushort> func1 = () => MyConvert.GetValue <ushort>(uint.MaxValue.ToString()); func1.Should().Throw <OverflowException>(); Func <uint> func2 = () => MyConvert.GetValue <uint>("-1"); func2.Should().Throw <OverflowException>(); Func <uint> func3 = () => MyConvert.GetValue <uint>(ulong.MaxValue.ToString()); func3.Should().Throw <OverflowException>(); }
public void FormatException() { // Exception発生しなければテストNGになる //Func<int> funcOk = () => MyConvert.GetValue<int>("0"); //funcOk.Should().Throw<FormatException>(); Func <int> func0 = () => MyConvert.GetValue <int>("123"); func0.Should().Throw <FormatException>(); Func <int> func1 = () => MyConvert.GetValue <int>("-123"); func1.Should().Throw <FormatException>(); Func <int> func2 = () => MyConvert.GetValue <int>("ff"); func2.Should().Throw <FormatException>(); }
public void OverflowException() { Func <short> func0 = () => MyConvert.GetValueFromHex <short>(int.MinValue.ToString("X")); func0.Should().Throw <OverflowException>(); Func <short> func1 = () => MyConvert.GetValueFromHex <short>(int.MaxValue.ToString("X")); func1.Should().Throw <OverflowException>(); Func <int> func2 = () => MyConvert.GetValueFromHex <int>(long.MinValue.ToString("X")); func2.Should().Throw <OverflowException>(); Func <int> func3 = () => MyConvert.GetValueFromHex <int>(long.MaxValue.ToString("X")); func3.Should().Throw <OverflowException>(); }
public void OverflowExceptionSigned() { // Exception発生しなければテストNGになる //Func<int> funcOk = () => MyConvert.GetValue<int>("0"); //funcOk.Should().Throw<OverflowException>(); Func <short> func0 = () => MyConvert.GetValue <short>(int.MinValue.ToString()); func0.Should().Throw <OverflowException>(); Func <short> func1 = () => MyConvert.GetValue <short>(int.MaxValue.ToString()); func1.Should().Throw <OverflowException>(); Func <int> func2 = () => MyConvert.GetValue <int>(long.MinValue.ToString()); func2.Should().Throw <OverflowException>(); Func <int> func3 = () => MyConvert.GetValue <int>(long.MaxValue.ToString()); func3.Should().Throw <OverflowException>(); }
public void ArgumentException() { Func <int> func0 = () => MyConvert.GetValueFromHex <int>("-1"); func0.Should().Throw <ArgumentException>(); }