Class AbstractStringGenerator
- Direct Known Subclasses:
Encoded,StringGenerator
Base class for generators of values of type String.
The generated values will have String.length() decided by
GenerationStatus.size().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTells whether this generator is allowed to participate in theShrinkprocess for the given "larger" value.protected abstract booleancodePointInRange(int codePoint) private booleanprivate StringdoShrink(SourceOfRandomness random, String larger) Gives some objects that are "smaller" than a given "larger" object.generate(SourceOfRandomness random, GenerationStatus status) Generates a value, possibly influenced by a source of randomness and metadata about the generation.Gives a hint to the shrinking process as to the magnitude of the given value.protected abstract intnextCodePoint(SourceOfRandomness random) Methods inherited from class com.pholser.junit.quickcheck.generator.Generator
addComponentGenerators, canGenerateForParametersOfTypes, canRegisterAsType, compatibleWithTypeParameter, configurationAnnotationsOn, configure, configure, copy, gen, gen, hasComponents, narrow, numberOfNeededComponents, provide, shrink, types
-
Constructor Details
-
AbstractStringGenerator
protected AbstractStringGenerator()
-
-
Method Details
-
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
-
canShrink
Description copied from class:GeneratorTells whether this generator is allowed to participate in the
Shrinkprocess for the given "larger" value.Unless overridden, the only criterion for whether a generator is allowed to participate in shrinking a value is if the value can be safely cast to the type of values the generator produces.
-
doShrink
Description copied from class:GeneratorGives some objects that are "smaller" than a given "larger" object.
Unless overridden, a generator will produce an empty list of "smaller" values.
-
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.
-
nextCodePoint
-
codePointInRange
protected abstract boolean codePointInRange(int codePoint) -
codePointsInRange
-
removals
-
convert
-