Interface FuzzedDataProvider
- All Known Implementing Classes:
CannedFuzzedDataProvider
The methods defined by this interface behave similarly to Random.nextInt()
, with all
returned values depending deterministically on the fuzzer input for the current run.
-
Method Summary
Modifier and TypeMethodDescriptionconsumeAsciiString
(int maxLength) Consumes an ASCII-onlyString
from the fuzzer input.boolean
Consumes aboolean
from the fuzzer input.boolean[]
consumeBooleans
(int maxLength) Consumes aboolean
array from the fuzzer input.byte
Consumes abyte
from the fuzzer input.byte
consumeByte
(byte min, byte max) Consumes abyte
betweenmin
andmax
from the fuzzer input.byte[]
consumeBytes
(int maxLength) Consumes abyte
array from the fuzzer input.char
Consumes achar
from the fuzzer input.char
consumeChar
(char min, char max) Consumes achar
betweenmin
andmax
from the fuzzer input.char
Consumes achar
from the fuzzer input that is never a UTF-16 surrogate character.double
Consumes adouble
from the fuzzer input.float
Consumes afloat
from the fuzzer input.int
Consumes anint
from the fuzzer input.int
consumeInt
(int min, int max) Consumes anint
betweenmin
andmax
from the fuzzer input.int[]
consumeInts
(int maxLength) Consumes anint
array from the fuzzer input.long
Consumes along
from the fuzzer input.long
consumeLong
(long min, long max) Consumes along
betweenmin
andmax
from the fuzzer input.long[]
consumeLongs
(int maxLength) Consumes along
array from the fuzzer input.double
Consumes adouble
between 0.0 and 1.0 (inclusive) from the fuzzer input.float
Consumes afloat
between 0.0 and 1.0 (inclusive) from the fuzzer input.double
Consumes a regulardouble
from the fuzzer input.double
consumeRegularDouble
(double min, double max) Consumes a regulardouble
betweenmin
andmax
from the fuzzer input.float
Consumes a regularfloat
from the fuzzer input.float
consumeRegularFloat
(float min, float max) Consumes a regularfloat
betweenmin
andmax
from the fuzzer input.Consumes the remaining fuzzer input as an ASCII-onlyString
.byte[]
Consumes the remaining fuzzer input as abyte
array.Consumes the remaining fuzzer input as aString
.short
Consumes ashort
from the fuzzer input.short
consumeShort
(short min, short max) Consumes ashort
betweenmin
andmax
from the fuzzer input.short[]
consumeShorts
(int maxLength) Consumes ashort
array from the fuzzer input.consumeString
(int maxLength) Consumes aString
from the fuzzer input.default boolean
pickValue
(boolean[] array) Picks an element fromarray
based on the fuzzer input.default byte
pickValue
(byte[] array) Picks an element fromarray
based on the fuzzer input.default char
pickValue
(char[] array) Picks an element fromarray
based on the fuzzer input.default double
pickValue
(double[] array) Picks an element fromarray
based on the fuzzer input.default float
pickValue
(float[] array) Picks an element fromarray
based on the fuzzer input.default int
pickValue
(int[] array) Picks an element fromarray
based on the fuzzer input.default long
pickValue
(long[] array) Picks an element fromarray
based on the fuzzer input.default short
pickValue
(short[] array) Picks an element fromarray
based on the fuzzer input.default <T> T
pickValue
(Collection<T> collection) Picks an element fromcollection
based on the fuzzer input.default <T> T
pickValue
(T[] array) Picks an element fromarray
based on the fuzzer input.default <T> List<T>
pickValues
(Collection<T> collection, int numOfElements) PicksnumOfElements
elements fromcollection
based on the fuzzer input.default <T> List<T>
pickValues
(T[] array, int numOfElements) PicksnumOfElements
elements fromarray
based on the fuzzer input.int
Returns the number of unconsumed bytes in the fuzzer input.
-
Method Details
-
consumeBoolean
boolean consumeBoolean()Consumes aboolean
from the fuzzer input.- Returns:
- a
boolean
-
consumeBooleans
boolean[] consumeBooleans(int maxLength) Consumes aboolean
array from the fuzzer input.The array will usually have length
length
, but might be shorter if the fuzzer input is not sufficiently long.- Parameters:
maxLength
- the maximum length of the array- Returns:
- a
boolean
array of length at mostlength
-
consumeByte
byte consumeByte()Consumes abyte
from the fuzzer input.- Returns:
- a
byte
-
consumeByte
byte consumeByte(byte min, byte max) Consumes abyte
betweenmin
andmax
from the fuzzer input.- Parameters:
min
- the inclusive lower bound on the returned valuemax
- the inclusive upper bound on the returned value- Returns:
- a
byte
in the range[min, max]
-
consumeBytes
byte[] consumeBytes(int maxLength) Consumes abyte
array from the fuzzer input.The array will usually have length
length
, but might be shorter if the fuzzer input is not sufficiently long.- Parameters:
maxLength
- the maximum length of the array- Returns:
- a
byte
array of length at mostlength
-
consumeRemainingAsBytes
byte[] consumeRemainingAsBytes()Consumes the remaining fuzzer input as abyte
array.Note: After calling this method, further calls to methods of this interface will return fixed values only.
- Returns:
- a
byte
array
-
consumeShort
short consumeShort()Consumes ashort
from the fuzzer input.- Returns:
- a
short
-
consumeShort
short consumeShort(short min, short max) Consumes ashort
betweenmin
andmax
from the fuzzer input.- Parameters:
min
- the inclusive lower bound on the returned valuemax
- the inclusive upper bound on the returned value- Returns:
- a
short
in the range[min, max]
-
consumeShorts
short[] consumeShorts(int maxLength) Consumes ashort
array from the fuzzer input.The array will usually have length
length
, but might be shorter if the fuzzer input is not sufficiently long.- Parameters:
maxLength
- the maximum length of the array- Returns:
- a
short
array of length at mostlength
-
consumeInt
int consumeInt()Consumes anint
from the fuzzer input.- Returns:
- an
int
-
consumeInt
int consumeInt(int min, int max) Consumes anint
betweenmin
andmax
from the fuzzer input.- Parameters:
min
- the inclusive lower bound on the returned valuemax
- the inclusive upper bound on the returned value- Returns:
- an
int
in the range[min, max]
-
consumeInts
int[] consumeInts(int maxLength) Consumes anint
array from the fuzzer input.The array will usually have length
length
, but might be shorter if the fuzzer input is not sufficiently long.- Parameters:
maxLength
- the maximum length of the array- Returns:
- an
int
array of length at mostlength
-
consumeLong
long consumeLong()Consumes along
from the fuzzer input.- Returns:
- a
long
-
consumeLong
long consumeLong(long min, long max) Consumes along
betweenmin
andmax
from the fuzzer input.- Parameters:
min
- the inclusive lower bound on the returned valuemax
- the inclusive upper bound on the returned value- Returns:
- a
long
in the range @{code [min, max]}
-
consumeLongs
long[] consumeLongs(int maxLength) Consumes along
array from the fuzzer input.The array will usually have length
length
, but might be shorter if the fuzzer input is not sufficiently long.- Parameters:
maxLength
- the maximum length of the array- Returns:
- a
long
array of length at mostlength
-
consumeFloat
float consumeFloat()Consumes afloat
from the fuzzer input.- Returns:
- a
float
that may have a special value (e.g. a NaN or infinity)
-
consumeRegularFloat
float consumeRegularFloat()Consumes a regularfloat
from the fuzzer input.- Returns:
- a
float
that is not a special value (e.g. not a NaN or infinity)
-
consumeRegularFloat
float consumeRegularFloat(float min, float max) Consumes a regularfloat
betweenmin
andmax
from the fuzzer input.- Returns:
- a
float
in the range[min, max]
-
consumeProbabilityFloat
float consumeProbabilityFloat()Consumes afloat
between 0.0 and 1.0 (inclusive) from the fuzzer input.- Returns:
- a
float
in the range[0.0, 1.0]
-
consumeDouble
double consumeDouble()Consumes adouble
from the fuzzer input.- Returns:
- a
double
that may have a special value (e.g. a NaN or infinity)
-
consumeRegularDouble
double consumeRegularDouble()Consumes a regulardouble
from the fuzzer input.- Returns:
- a
double
that is not a special value (e.g. not a NaN or infinity)
-
consumeRegularDouble
double consumeRegularDouble(double min, double max) Consumes a regulardouble
betweenmin
andmax
from the fuzzer input.- Returns:
- a
double
in the range[min, max]
-
consumeProbabilityDouble
double consumeProbabilityDouble()Consumes adouble
between 0.0 and 1.0 (inclusive) from the fuzzer input.- Returns:
- a
double
in the range[0.0, 1.0]
-
consumeChar
char consumeChar()Consumes achar
from the fuzzer input. -
consumeChar
char consumeChar(char min, char max) Consumes achar
betweenmin
andmax
from the fuzzer input.- Parameters:
min
- the inclusive lower bound on the returned valuemax
- the inclusive upper bound on the returned value- Returns:
- a
char
in the range[min, max]
-
consumeCharNoSurrogates
char consumeCharNoSurrogates()Consumes achar
from the fuzzer input that is never a UTF-16 surrogate character. -
consumeString
Consumes aString
from the fuzzer input.The returned string may be of any length between 0 and
maxLength
, even if there is more fuzzer input available.- Parameters:
maxLength
- the maximum length of the string- Returns:
- a
String
of length between 0 andmaxLength
(inclusive)
-
consumeRemainingAsString
String consumeRemainingAsString()Consumes the remaining fuzzer input as aString
.Note: After calling this method, further calls to methods of this interface will return fixed values only.
- Returns:
- a
String
-
consumeAsciiString
Consumes an ASCII-onlyString
from the fuzzer input.The returned string may be of any length between 0 and
maxLength
, even if there is more fuzzer input available.- Parameters:
maxLength
- the maximum length of the string- Returns:
- a
String
of length between 0 andmaxLength
(inclusive) that contains only ASCII characters
-
consumeRemainingAsAsciiString
String consumeRemainingAsAsciiString()Consumes the remaining fuzzer input as an ASCII-onlyString
.Note: After calling this method, further calls to methods of this interface will return fixed values only.
- Returns:
- a
String
that contains only ASCII characters
-
remainingBytes
int remainingBytes()Returns the number of unconsumed bytes in the fuzzer input.- Returns:
- the number of unconsumed bytes in the fuzzer input
-
pickValue
Picks an element fromcollection
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Type Parameters:
T
- the type of the collection element- Parameters:
collection
- theCollection
to pick an element from.- Returns:
- an element from
collection
chosen based on the fuzzer input
-
pickValue
default <T> T pickValue(T[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Type Parameters:
T
- the type of the array element- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default boolean pickValue(boolean[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default byte pickValue(byte[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default short pickValue(short[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default int pickValue(int[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default long pickValue(long[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default double pickValue(double[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default float pickValue(float[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValue
default char pickValue(char[] array) Picks an element fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Parameters:
array
- the array to pick an element from.- Returns:
- an element from
array
chosen based on the fuzzer input
-
pickValues
PicksnumOfElements
elements fromcollection
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Type Parameters:
T
- the type of the collection element- Parameters:
collection
- theCollection
to pick an element from.numOfElements
- the number of elements to pick.- Returns:
- an array of size
numOfElements
fromcollection
chosen based on the fuzzer input
-
pickValues
PicksnumOfElements
elements fromarray
based on the fuzzer input.Note: The distribution of picks is not perfectly uniform.
- Type Parameters:
T
- the type of the array element- Parameters:
array
- the array to pick an element from.numOfElements
- the number of elements to pick.- Returns:
- an array of size
numOfElements
fromarray
chosen based on the fuzzer input
-