Example #1
0
        static void TestLimitedIntegerRange(BigInteger value, BitWidthAndSignPair signAndBitwidth)
        {
            var ltdInt = LimitedIntegerType.CreateLimitedIntegerType(value, null);

            ltdInt.Value.Should().Be(value);
            ltdInt.IsSigned.Should().Be(signAndBitwidth.IsSigned);
            ltdInt.BitWidth.Should().Be(signAndBitwidth.BitWidth);
        }
Example #2
0
        protected override TNewType InternalCastTo <TNewType>(IConfiguration configuration)
        {
            switch (typeof(TNewType).Name)
            {
            case nameof(TimespanType):
                return(new TimespanType(TimeSpan.FromSeconds((double)Value)) as TNewType);

            case nameof(FloatType):
                return(new FloatType((double)Value) as TNewType);

            case nameof(LimitedIntegerType):
                return(LimitedIntegerType.CreateLimitedIntegerType(Value, configuration) as TNewType);
            }
            return(null);
        }
Example #3
0
 public void OutOfRangeLimitedIntegers(string value)
 => new Action(() => LimitedIntegerType.CreateLimitedIntegerType(BigInteger.Parse(value), null)).Should().Throw <TypeConversionException>();