Beispiel #1
0
        public void NonNullableDouble()
        {
            var dist = Uniform.New(1.0d, 2.0d);

            Assert.Throws <ArgumentNullException>(() => dist.Sample <StepRng>(null));
        }
Beispiel #2
0
 public void BadExclusiveRangeInt64(Int64 high, Int64 low)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(high, low));
 }
Beispiel #3
0
        public void BadRange()
        {
            // Equal
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(0f, 0f));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(Single.MaxValue, Single.MaxValue));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(Single.MinValue, Single.MinValue));
            // Reversed
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(10.0f, 10.0f));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(9001.0f, -666.0f));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(Single.MaxValue, Single.MinValue));
            // Infinities
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.New(Single.NegativeInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(0, Single.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.PositiveInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(0, Single.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.PositiveInfinity, Single.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.NegativeInfinity, Single.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.NegativeInfinity, Single.PositiveInfinity));
            // NaNs
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.New(Single.NaN, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(0, Single.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.NaN, Single.NaN));
            // Mixed NaN / Infinity
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.NaN, Single.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.PositiveInfinity, Single.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.NaN, Single.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Single.NegativeInfinity, Single.NaN));

            // Reversed
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(10.0f, 9.0f));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(9001.0f, -666.0f));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(Single.MaxValue, Single.MinValue));
            // Infinities
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.NewInclusive(Single.NegativeInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(0, Single.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.PositiveInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(0, Single.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.PositiveInfinity, Single.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.NegativeInfinity, Single.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.NegativeInfinity, Single.PositiveInfinity));
            // NaNs
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.NewInclusive(Single.NaN, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(0, Single.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.NaN, Single.NaN));
            // Mixed NaN / Infinity
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.NaN, Single.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.PositiveInfinity, Single.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.NaN, Single.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Single.NegativeInfinity, Single.NaN));

            // Equal
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(0d, 0d));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(Double.MaxValue, Double.MaxValue));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(Double.MinValue, Double.MinValue));
            // Reversed
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(10.0d, 10.0d));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(9001.0d, -666.0d));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(Double.MaxValue, Double.MinValue));
            // Infinities
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.New(Double.NegativeInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(0, Double.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.PositiveInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(0, Double.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.PositiveInfinity, Double.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.NegativeInfinity, Double.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.NegativeInfinity, Double.PositiveInfinity));
            // NaNs
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.New(Double.NaN, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.New(0, Double.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.NaN, Double.NaN));
            // Mixed NaN / Infinity
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.NaN, Double.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.PositiveInfinity, Double.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.NaN, Double.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(Double.NegativeInfinity, Double.NaN));

            // Reversed
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(10.0d, 9.0d));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(9001.0d, -666.0d));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(Double.MaxValue, Double.MinValue));
            // Infinities
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.NewInclusive(Double.NegativeInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(0, Double.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.PositiveInfinity, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(0, Double.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.PositiveInfinity, Double.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.NegativeInfinity, Double.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.NegativeInfinity, Double.PositiveInfinity));
            // NaNs
            Assert.Throws <ArgumentOutOfRangeException>("low", () => Uniform.NewInclusive(Double.NaN, 0));
            Assert.Throws <ArgumentOutOfRangeException>("high", () => Uniform.NewInclusive(0, Double.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.NaN, Double.NaN));
            // Mixed NaN / Infinity
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.NaN, Double.PositiveInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.PositiveInfinity, Double.NaN));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.NaN, Double.NegativeInfinity));
            Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(Double.NegativeInfinity, Double.NaN));
        }
Beispiel #4
0
 public void BadInclusiveRangeInt32(Int32 high, Int32 low)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(high, low));
 }
Beispiel #5
0
 public void BadExclusiveRangeSByte(SByte high, SByte low)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(high, low));
 }
Beispiel #6
0
 public void BadInclusiveRangeUInt64(UInt64 high, UInt64 low)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(high, low));
 }
Beispiel #7
0
 public void BadExclusiveRangeUInt32(UInt32 high, UInt32 low)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.New(high, low));
 }
Beispiel #8
0
 public void BadInclusiveRangeByte(Byte high, Byte low)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Uniform.NewInclusive(high, low));
 }