Пример #1
0
        /// <summary>
        /// Constrains the generator so that it only produces values between the supplied range (inclusive).
        /// </summary>
        /// <param name="x">The first bound of the range.</param>
        /// <param name="y">The second bound of the range.</param>
        /// <returns>A new generator with the constraint applied.</returns>
        public static IIntGen <long> Between(this IIntGen <long> gen, long x, long y)
        {
            var min = x > y ? y : x;
            var max = x > y ? x : y;

            return(gen.GreaterThanEqual(min).LessThanEqual(max));
        }
Пример #2
0
        /// <summary>
        /// Constrains the generator so that it only produces values between the supplied range (inclusive).
        /// </summary>
        /// <param name="x">The first bound of the range.</param>
        /// <param name="y">The second bound of the range.</param>
        /// <returns>A new generator with the constraint applied.</returns>
        public static IIntGen <short> Between(this IIntGen <short> gen, short x, short y)
        {
            var min = x > y ? y : x;
            var max = x > y ? x : y;

            return(gen.GreaterThanEqual(min).LessThanEqual(max));
        }
Пример #3
0
        /// <summary>
        /// Constrains the generator so that it only produces values between the supplied range (inclusive).
        /// </summary>
        /// <param name="x">The first bound of the range.</param>
        /// <param name="y">The second bound of the range.</param>
        /// <returns>A new generator with the constraint applied.</returns>
        public static IIntGen <byte> Between(this IIntGen <byte> gen, byte x, byte y)
        {
            var min = x > y ? y : x;
            var max = x > y ? x : y;

            return(gen.GreaterThanEqual(min).LessThanEqual(max));
        }
Пример #4
0
 /// <summary>
 /// Constrains the generator so that it only produces values greater than the supplied minimum.
 /// </summary>
 /// <param name="minExclusive">The minimum integer to generate (exclusive).</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IIntGen <long> GreaterThan(this IIntGen <long> gen, long minExclusive)
 {
     try
     {
         checked
         {
             return(gen.GreaterThanEqual((long)(minExclusive + 1)));
         }
     }
     catch (OverflowException ex)
     {
         return(new FatalIntGen <long>($"{nameof(Gen.Int64)}().{nameof(GreaterThan)}({minExclusive})", ex));
     }
 }
Пример #5
0
 /// <summary>
 /// Constrains the generator so that it only produces values greater than the supplied minimum.
 /// </summary>
 /// <param name="minExclusive">The minimum integer to generate (exclusive).</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IIntGen <short> GreaterThan(this IIntGen <short> gen, short minExclusive)
 {
     try
     {
         checked
         {
             return(gen.GreaterThanEqual((short)(minExclusive + 1)));
         }
     }
     catch (OverflowException ex)
     {
         return(new FatalIntGen <short>($"{nameof(Gen.Int16)}().{nameof(GreaterThan)}({minExclusive})", ex));
     }
 }
Пример #6
0
 /// <summary>
 /// Constrains the generator so that it only produces values greater than the supplied minimum.
 /// </summary>
 /// <param name="minExclusive">The minimum byte to generate (exclusive).</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IIntGen <byte> GreaterThan(this IIntGen <byte> gen, byte minExclusive)
 {
     try
     {
         checked
         {
             return(gen.GreaterThanEqual((byte)(minExclusive + 1)));
         }
     }
     catch (OverflowException ex)
     {
         return(new FatalIntGen <byte>($"{nameof(Gen.Byte)}().{nameof(GreaterThan)}({minExclusive})", ex));
     }
 }