Class ShortGenerator
java.lang.Object
com.pholser.junit.quickcheck.generator.Generator<T>
com.pholser.junit.quickcheck.generator.IntegralGenerator<Short>
com.pholser.junit.quickcheck.generator.java.lang.ShortGenerator
Produces values of type
short or Short.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidTells this generator to produce values within a specified minimum and/or maximum, inclusive, with uniform distribution.generate(SourceOfRandomness random, GenerationStatus status) Generates a value, possibly influenced by a source of randomness and metadata about the generation.inRange()protected ShortGives a hint to the shrinking process as to the magnitude of the given value.protected Function<BigInteger,Short> narrow()protected ShortUsed when shrinking negative numbers to add the positive equivalent value at the top of shrinks list.protected booleanMethods inherited from class com.pholser.junit.quickcheck.generator.IntegralGenerator
doShrink, widenMethods inherited from class com.pholser.junit.quickcheck.generator.Generator
addComponentGenerators, canGenerateForParametersOfTypes, canRegisterAsType, canShrink, compatibleWithTypeParameter, configurationAnnotationsOn, configure, configure, copy, gen, gen, hasComponents, narrow, numberOfNeededComponents, provide, shrink, types
-
Field Details
-
min
private short min -
max
private short max
-
-
Constructor Details
-
ShortGenerator
public ShortGenerator()
-
-
Method Details
-
configure
Tells this generator to produce values within a specified minimum and/or maximum, inclusive, with uniform distribution.InRange.min()andInRange.max()take precedence overInRange.minShort()andInRange.maxShort(), if non-empty.- Parameters:
range- annotation that gives the range's constraints
-
generate
Description copied from interface:GenGenerates a value, possibly influenced by a source of randomness and metadata about the generation.- Parameters:
random- source of randomness to be used when generating the valuestatus- an object that can be used to influence the generated value. For example, generating lists can use thesizemethod to generate lists with a given number of elements.- Returns:
- the generated value
-
narrow
- Specified by:
narrowin classIntegralGenerator<Short>- Returns:
- a function converting a
BigIntegerinto the equivalent value in the base type
-
inRange
- Specified by:
inRangein classIntegralGenerator<Short>- Returns:
- a predicate checking whether its input is in the configured range
-
leastMagnitude
- Specified by:
leastMagnitudein classIntegralGenerator<Short>- Returns:
- the lowest magnitude number, respecting the configured range. The ideal shrink value is always this value (i.e. this value cannot be shrunk any further).
-
negative
- Specified by:
negativein classIntegralGenerator<Short>- Returns:
- whether the given number is negative or not
-
negate
Description copied from class:IntegralGeneratorUsed when shrinking negative numbers to add the positive equivalent value at the top of shrinks list.- Specified by:
negatein classIntegralGenerator<Short>- Parameters:
target- always a negative number- Returns:
- the positive equivalent to target
-
magnitude
Description copied from class:GeneratorGives a hint to the shrinking process as to the magnitude of the given value. The shrinking process will prefer trying values of greater magnitude before values of lesser magnitude. If not overridden, this implementation returns "one".
Note to generator writers: Do not worry about normalizing a magnitude to a positive value; the shrinking mechanism will take care of it.
-