コード例 #1
0
ファイル: Int16Gen.cs プロジェクト: nth-commit/GalaxyCheck
 /// <summary>
 /// Constrains the generator so that it only produces values less than the supplied maximum.
 /// </summary>
 /// <param name="maxExclusive">The maximum int to generate (exclusive).</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IIntGen <short> LessThan(this IIntGen <short> gen, short maxExclusive)
 {
     try
     {
         checked
         {
             return(gen.LessThanEqual((short)(maxExclusive - 1)));
         }
     }
     catch (OverflowException ex)
     {
         return(new FatalIntGen <short>($"{nameof(Gen.Int16)}().{nameof(LessThan)}({maxExclusive})", ex));
     }
 }
コード例 #2
0
ファイル: Int64Gen.cs プロジェクト: nth-commit/GalaxyCheck
 /// <summary>
 /// Constrains the generator so that it only produces values less than the supplied maximum.
 /// </summary>
 /// <param name="maxExclusive">The maximum int to generate (exclusive).</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IIntGen <long> LessThan(this IIntGen <long> gen, long maxExclusive)
 {
     try
     {
         checked
         {
             return(gen.LessThanEqual((long)(maxExclusive - 1)));
         }
     }
     catch (OverflowException ex)
     {
         return(new FatalIntGen <long>($"{nameof(Gen.Int64)}().{nameof(LessThan)}({maxExclusive})", ex));
     }
 }
コード例 #3
0
 /// <summary>
 /// Constrains the generator so that it only produces values less than the supplied maximum.
 /// </summary>
 /// <param name="maxExclusive">The maximum byte to generate (exclusive).</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IIntGen <byte> LessThan(this IIntGen <byte> gen, byte maxExclusive)
 {
     try
     {
         checked
         {
             return(gen.LessThanEqual((byte)(maxExclusive - 1)));
         }
     }
     catch (OverflowException ex)
     {
         return(new FatalIntGen <byte>($"{nameof(Gen.Byte)}().{nameof(LessThan)}({maxExclusive})", ex));
     }
 }