/// <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)); } }
/// <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)); } }
/// <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)); } }