Interface FuzzedDataProvider

All Known Implementing Classes:
CannedFuzzedDataProvider

public interface FuzzedDataProvider
A convenience wrapper turning the raw fuzzer input bytes into Java primitive types.

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 Type
    Method
    Description
    consumeAsciiString(int maxLength)
    Consumes an ASCII-only String from the fuzzer input.
    boolean
    Consumes a boolean from the fuzzer input.
    boolean[]
    consumeBooleans(int maxLength)
    Consumes a boolean array from the fuzzer input.
    byte
    Consumes a byte from the fuzzer input.
    byte
    consumeByte(byte min, byte max)
    Consumes a byte between min and max from the fuzzer input.
    byte[]
    consumeBytes(int maxLength)
    Consumes a byte array from the fuzzer input.
    char
    Consumes a char from the fuzzer input.
    char
    consumeChar(char min, char max)
    Consumes a char between min and max from the fuzzer input.
    char
    Consumes a char from the fuzzer input that is never a UTF-16 surrogate character.
    double
    Consumes a double from the fuzzer input.
    float
    Consumes a float from the fuzzer input.
    int
    Consumes an int from the fuzzer input.
    int
    consumeInt(int min, int max)
    Consumes an int between min and max from the fuzzer input.
    int[]
    consumeInts(int maxLength)
    Consumes an int array from the fuzzer input.
    long
    Consumes a long from the fuzzer input.
    long
    consumeLong(long min, long max)
    Consumes a long between min and max from the fuzzer input.
    long[]
    consumeLongs(int maxLength)
    Consumes a long array from the fuzzer input.
    double
    Consumes a double between 0.0 and 1.0 (inclusive) from the fuzzer input.
    float
    Consumes a float between 0.0 and 1.0 (inclusive) from the fuzzer input.
    double
    Consumes a regular double from the fuzzer input.
    double
    consumeRegularDouble(double min, double max)
    Consumes a regular double between min and max from the fuzzer input.
    float
    Consumes a regular float from the fuzzer input.
    float
    consumeRegularFloat(float min, float max)
    Consumes a regular float between min and max from the fuzzer input.
    Consumes the remaining fuzzer input as an ASCII-only String.
    byte[]
    Consumes the remaining fuzzer input as a byte array.
    Consumes the remaining fuzzer input as a String.
    short
    Consumes a short from the fuzzer input.
    short
    consumeShort(short min, short max)
    Consumes a short between min and max from the fuzzer input.
    short[]
    consumeShorts(int maxLength)
    Consumes a short array from the fuzzer input.
    consumeString(int maxLength)
    Consumes a String from the fuzzer input.
    default boolean
    pickValue(boolean[] array)
    Picks an element from array based on the fuzzer input.
    default byte
    pickValue(byte[] array)
    Picks an element from array based on the fuzzer input.
    default char
    pickValue(char[] array)
    Picks an element from array based on the fuzzer input.
    default double
    pickValue(double[] array)
    Picks an element from array based on the fuzzer input.
    default float
    pickValue(float[] array)
    Picks an element from array based on the fuzzer input.
    default int
    pickValue(int[] array)
    Picks an element from array based on the fuzzer input.
    default long
    pickValue(long[] array)
    Picks an element from array based on the fuzzer input.
    default short
    pickValue(short[] array)
    Picks an element from array based on the fuzzer input.
    default <T> T
    pickValue(Collection<T> collection)
    Picks an element from collection based on the fuzzer input.
    default <T> T
    pickValue(T[] array)
    Picks an element from array based on the fuzzer input.
    default <T> List<T>
    pickValues(Collection<T> collection, int numOfElements)
    Picks numOfElements elements from collection based on the fuzzer input.
    default <T> List<T>
    pickValues(T[] array, int numOfElements)
    Picks numOfElements elements from array based on the fuzzer input.
    int
    Returns the number of unconsumed bytes in the fuzzer input.
  • Method Details

    • consumeBoolean

      boolean consumeBoolean()
      Consumes a boolean from the fuzzer input.
      Returns:
      a boolean
    • consumeBooleans

      boolean[] consumeBooleans(int maxLength)
      Consumes a boolean 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 most length
    • consumeByte

      byte consumeByte()
      Consumes a byte from the fuzzer input.
      Returns:
      a byte
    • consumeByte

      byte consumeByte(byte min, byte max)
      Consumes a byte between min and max from the fuzzer input.
      Parameters:
      min - the inclusive lower bound on the returned value
      max - the inclusive upper bound on the returned value
      Returns:
      a byte in the range [min, max]
    • consumeBytes

      byte[] consumeBytes(int maxLength)
      Consumes a byte 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 most length
    • consumeRemainingAsBytes

      byte[] consumeRemainingAsBytes()
      Consumes the remaining fuzzer input as a byte 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 a short from the fuzzer input.
      Returns:
      a short
    • consumeShort

      short consumeShort(short min, short max)
      Consumes a short between min and max from the fuzzer input.
      Parameters:
      min - the inclusive lower bound on the returned value
      max - the inclusive upper bound on the returned value
      Returns:
      a short in the range [min, max]
    • consumeShorts

      short[] consumeShorts(int maxLength)
      Consumes a short 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 most length
    • consumeInt

      int consumeInt()
      Consumes an int from the fuzzer input.
      Returns:
      an int
    • consumeInt

      int consumeInt(int min, int max)
      Consumes an int between min and max from the fuzzer input.
      Parameters:
      min - the inclusive lower bound on the returned value
      max - the inclusive upper bound on the returned value
      Returns:
      an int in the range [min, max]
    • consumeInts

      int[] consumeInts(int maxLength)
      Consumes an int 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 most length
    • consumeLong

      long consumeLong()
      Consumes a long from the fuzzer input.
      Returns:
      a long
    • consumeLong

      long consumeLong(long min, long max)
      Consumes a long between min and max from the fuzzer input.
      Parameters:
      min - the inclusive lower bound on the returned value
      max - the inclusive upper bound on the returned value
      Returns:
      a long in the range @{code [min, max]}
    • consumeLongs

      long[] consumeLongs(int maxLength)
      Consumes a long 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 most length
    • consumeFloat

      float consumeFloat()
      Consumes a float from the fuzzer input.
      Returns:
      a float that may have a special value (e.g. a NaN or infinity)
    • consumeRegularFloat

      float consumeRegularFloat()
      Consumes a regular float 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 regular float between min and max from the fuzzer input.
      Returns:
      a float in the range [min, max]
    • consumeProbabilityFloat

      float consumeProbabilityFloat()
      Consumes a float 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 a double from the fuzzer input.
      Returns:
      a double that may have a special value (e.g. a NaN or infinity)
    • consumeRegularDouble

      double consumeRegularDouble()
      Consumes a regular double 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 regular double between min and max from the fuzzer input.
      Returns:
      a double in the range [min, max]
    • consumeProbabilityDouble

      double consumeProbabilityDouble()
      Consumes a double 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 a char from the fuzzer input.
    • consumeChar

      char consumeChar(char min, char max)
      Consumes a char between min and max from the fuzzer input.
      Parameters:
      min - the inclusive lower bound on the returned value
      max - the inclusive upper bound on the returned value
      Returns:
      a char in the range [min, max]
    • consumeCharNoSurrogates

      char consumeCharNoSurrogates()
      Consumes a char from the fuzzer input that is never a UTF-16 surrogate character.
    • consumeString

      String consumeString(int maxLength)
      Consumes a String 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 and maxLength (inclusive)
    • consumeRemainingAsString

      String consumeRemainingAsString()
      Consumes the remaining fuzzer input as a String.

      Note: After calling this method, further calls to methods of this interface will return fixed values only.

      Returns:
      a String
    • consumeAsciiString

      String consumeAsciiString(int maxLength)
      Consumes an ASCII-only String 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 and maxLength (inclusive) that contains only ASCII characters
    • consumeRemainingAsAsciiString

      String consumeRemainingAsAsciiString()
      Consumes the remaining fuzzer input as an ASCII-only String.

      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

      default <T> T pickValue(Collection<T> collection)
      Picks an element from collection 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 - the Collection 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 from array 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 from array 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 from array 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 from array 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 from array 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 from array 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 from array 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 from array 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 from array 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

      default <T> List<T> pickValues(Collection<T> collection, int numOfElements)
      Picks numOfElements elements from collection 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 - the Collection to pick an element from.
      numOfElements - the number of elements to pick.
      Returns:
      an array of size numOfElements from collection chosen based on the fuzzer input
    • pickValues

      default <T> List<T> pickValues(T[] array, int numOfElements)
      Picks numOfElements elements from array 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 from array chosen based on the fuzzer input