Module de.cuioss.test.generator
Class PrimitiveGenerators
java.lang.Object
de.cuioss.test.generator.internal.net.java.quickcheck.generator.PrimitiveGenerators
PrimitiveGenerators contains factory methods for primitive value
generators. These can be used to build custom test case generators.
The default distribution for generators is Distribution.UNIFORM.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a new character generator which generates latin characters.booleans()Create a generator for boolean values.bytes()Create a new byte generator which creates byte values ranging fromByte.MIN_VALUEtoByte.MAX_VALUE.bytes(byte lo, byte hi) Create a new byte generator which creates byte values ranging from lo to hi.bytes(byte lo, byte hi, Distribution distribution) Create a new integer generator which creates integers ranging from lo to hi based on the givenDistribution.Create a new character generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks.characters(char lo, char hi) Create a new character generator which generates characters ranging from lo to hi.characters(Character... chars) Create a new character generator which generates characters from the given character array.characters(Iterable<Character> chars) Create a new character generator which generates characters from the given characters.characters(String string) Create a new character generator which generates characters from the given string.static <T> Generator<T>clonedValues(T prototype) A cloning generator which uses object serialization to create clones of the prototype object.dates()Create a generator for date values.dates(long low, long high) Create a generator for date values from low to high.Create a generator for date values from low to high with the given precision.Create a generator for date values with the given precision.Create a generator for date values from low to high.static <T> ObjectGenerator<T>defaultObjects(Class<T> objectType) Create a generator from adeclarative object generator definition.doubles()Create a new double generator which creates doubles ranging fromDouble.MIN_VALUEtoDouble.MAX_VALUE.doubles(double lo, double hi) Create a new double generator which creates doubles ranging from lo to hi.doubles(double lo, double hi, Distribution distribution) Create a new double generator which creates doubles ranging from lo to hi based on the givenDistribution.enumValues(Class<T> enumClass) Create a generator of enumeration values.enumValues(Class<T> enumClass, Iterable<T> excludedValues) Create a generator of enumeration values.enumValues(Class<T> enumClass, T... excluded) Create a generator of enumeration values.static <T> Generator<T>fixedValues(Iterable<T> values) Create a fixed value generator return values.static <T> Generator<T>fixedValues(T value) Create a generator for fixed value generator.static <T> Generator<T>fixedValues(T... values) Create a fixed value generator return values array.integers()Create a new integer generator which creates integers ranging fromInteger.MIN_VALUEtoInteger.MAX_VALUE.integers(int low) Create a new integer generator which creates integers that are at equal or greater than low.integers(int lo, int hi) Create a new integer generator which creates integers ranging from lo to hi.integers(int lo, int hi, Distribution distribution) Create a new integer generator which creates integers ranging fromlotohibased on the givenDistribution.Create a new character generator which generates latin-1 supplement characters.static ExtendibleGenerator<Character,String> Create a new string generator which creates strings of characters from a-z and A-Z.static ExtendibleGenerator<Character,String> letterStrings(int min, int max) Create a new string generator which creates strings with sizes ranging from loLengh to hiLength of characters from a-z and A-Z.longs()Create a new long generator which creates longs ranging fromLong.MIN_VALUEtoLong.MAX_VALUE.longs(long lo, long hi) Create a new long generator which creates longs ranging from lo to hi.longs(long lo, long hi, Distribution distribution) Create a new long generator which creates longs ranging from lo to hi based on the givenDistribution.static ExtendibleGenerator<Character,String> Create a new string generator for strings that are not empty.static <T> Generator<T>nulls()Create a generator for null values.objects()Create a generator forjava.lang.Objectinstances.static <T> ObjectGenerator<T>Create a generator from adeclarative object generator definition.Create a new integer generator which creates integers ranging from1toInteger.MAX_VALUE.positiveIntegers(int hi) Create a new integer generator which creates integers ranging from1tomax(which must be at least 1).Create a new long generator which creates long values ranging from 1 toLong.MAX_VALUE.positiveLongs(long hi) Create a new long generator which creates long values ranging from 1 to hi.static ExtendibleGenerator<Character,String> Create a new string generator which creates strings of characters generated bybasicLatinCharacters()andlatin1SupplementCharacters().static ExtendibleGenerator<Character,String> strings()Create a new string generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks.static ExtendibleGenerator<Character,String> strings(char lo, char hi) Create a new string generator which generates strings of characters ranging from lo to hi.static ExtendibleGenerator<Character,String> strings(int max) Creates a new String genearator which generates strings whose length ranges from zero to given length.static ExtendibleGenerator<Character,String> strings(int min, int max) Create a new string generator which generates strings of sizes ranging from loLength to hiLength.static ExtendibleGenerator<Character,String> Create a new string generator which creates strings of characters generated by the given character generator.static ExtendibleGenerator<Character,String> Create a new string generator which creates strings of characters generated by the given character generator with a length generated by the length generator.static ExtendibleGenerator<Character,String> Create a new string generator which generates strings of characters from the given string.static ExtendibleGenerator<Character,String> Create a new string generator which generates strings of characters from the given string with a length between min and max.substrings(String base) Create a new string generator for substrings of a base string.substrings(String base, int size) Create a new string generator for substrings of a base string.substrings(String base, int minSize, int maxSize) Create a new string generator for substrings of a base string.
-
Field Details
-
DEFAULT_STRING_MAX_LENGTH
- See Also:
-
-
Constructor Details
-
PrimitiveGenerators
public PrimitiveGenerators()
-
-
Method Details
-
strings
Create a new string generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks. -
strings
Create a new string generator which generates strings of characters ranging from lo to hi.- Parameters:
lo- lower boundary characterhi- upper boundary character
-
strings
Create a new string generator which generates strings of characters from the given string. -
strings
public static ExtendibleGenerator<Character,String> strings(String allowedCharacters, int min, int max) Create a new string generator which generates strings of characters from the given string with a length between min and max. -
strings
Creates a new String genearator which generates strings whose length ranges from zero to given length. -
strings
Create a new string generator which generates strings of sizes ranging from loLength to hiLength.- Parameters:
min- lower size boundarymax- upper size boundary
-
strings
public static ExtendibleGenerator<Character,String> strings(Generator<Integer> length, Generator<Character> characters) Create a new string generator which creates strings of characters generated by the given character generator with a length generated by the length generator. -
strings
public static ExtendibleGenerator<Character,String> strings(Generator<Character> characterGenerator) Create a new string generator which creates strings of characters generated by the given character generator. -
letterStrings
Create a new string generator which creates strings of characters from a-z and A-Z. -
letterStrings
Create a new string generator which creates strings with sizes ranging from loLengh to hiLength of characters from a-z and A-Z. -
printableStrings
Create a new string generator which creates strings of characters generated bybasicLatinCharacters()andlatin1SupplementCharacters(). -
nonEmptyStrings
Create a new string generator for strings that are not empty. -
substrings
Create a new string generator for substrings of a base string.base.contains(generated string) will always be true.
-
substrings
Create a new string generator for substrings of a base string.base.contains(generated string) will always be true.
- Parameters:
size- of the generated string
-
substrings
Create a new string generator for substrings of a base string.base.contains(generated string) will always be true.
- Parameters:
minSize- is the minimum size of the generated stringmaxSize- is the maximum size of the generated string
-
characters
Create a new character generator which generates characters ranging from lo to hi. -
characters
Create a new character generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks. -
characters
Create a new character generator which generates characters from the given character array. -
characters
Create a new character generator which generates characters from the given string. -
characters
Create a new character generator which generates characters from the given characters. -
latin1SupplementCharacters
Create a new character generator which generates latin-1 supplement characters. -
basicLatinCharacters
Create a new character generator which generates latin characters. -
integers
Create a new integer generator which creates integers ranging fromInteger.MIN_VALUEtoInteger.MAX_VALUE. -
integers
Create a new integer generator which creates integers that are at equal or greater than low. -
integers
Create a new integer generator which creates integers ranging from lo to hi. -
integers
Create a new integer generator which creates integers ranging fromlotohibased on the givenDistribution. -
positiveIntegers
Create a new integer generator which creates integers ranging from1toInteger.MAX_VALUE. -
positiveIntegers
Create a new integer generator which creates integers ranging from1tomax(which must be at least 1). -
bytes
Create a new byte generator which creates byte values ranging fromByte.MIN_VALUEtoByte.MAX_VALUE. -
bytes
Create a new byte generator which creates byte values ranging from lo to hi. -
bytes
Create a new integer generator which creates integers ranging from lo to hi based on the givenDistribution. -
longs
Create a new long generator which creates longs ranging fromLong.MIN_VALUEtoLong.MAX_VALUE. -
longs
Create a new long generator which creates longs ranging from lo to hi. -
longs
Create a new long generator which creates longs ranging from lo to hi based on the givenDistribution. -
positiveLongs
Create a new long generator which creates long values ranging from 1 toLong.MAX_VALUE. -
positiveLongs
Create a new long generator which creates long values ranging from 1 to hi. -
doubles
Create a new double generator which creates doubles ranging fromDouble.MIN_VALUEtoDouble.MAX_VALUE. -
doubles
Create a new double generator which creates doubles ranging from lo to hi. -
doubles
Create a new double generator which creates doubles ranging from lo to hi based on the givenDistribution. -
booleans
Create a generator for boolean values. -
nulls
Create a generator for null values. -
dates
Create a generator for date values. -
dates
Create a generator for date values with the given precision. -
dates
Create a generator for date values from low to high. -
dates
Create a generator for date values from low to high. -
dates
Create a generator for date values from low to high with the given precision. -
fixedValues
Create a generator for fixed value generator. -
fixedValues
Create a fixed value generator return values array. -
fixedValues
Create a fixed value generator return values. -
clonedValues
A cloning generator which uses object serialization to create clones of the prototype object. For each call a new copy of the prototype will be generated. -
enumValues
Create a generator of enumeration values.- Type Parameters:
T- Type of enumerations- Parameters:
enumClass- class of enumeration- Returns:
- generator of enum values
-
enumValues
@SafeVarargs public static <T extends Enum<T>> Generator<T> enumValues(Class<T> enumClass, T... excluded) Create a generator of enumeration values.- Type Parameters:
T- Type of enumerations- Parameters:
enumClass- class of enumerationexcluded- excluded values of enumeration- Returns:
- generator of enum values
-
enumValues
public static <T extends Enum<T>> Generator<T> enumValues(Class<T> enumClass, Iterable<T> excludedValues) Create a generator of enumeration values.- Type Parameters:
T- Type of enumerations- Parameters:
enumClass- class of enumerationexcludedValues- excluded values of enumeration- Returns:
- generator of enum values
-
objects
Create a generator forjava.lang.Objectinstances.Note: every invocation of
Generator.next()creates a new instance. -
objects
Create a generator from adeclarative object generator definition. -
defaultObjects
Create a generator from adeclarative object generator definition.Default values will be used for all
undefined methods.
-