Class StringGenerator
java.lang.Object
com.carrotsearch.randomizedtesting.generators.StringGenerator
- Direct Known Subclasses:
CodepointSetGenerator, RealisticUnicodeGenerator, UnicodeGenerator
A
StringGenerator generates random strings composed of characters. What these characters
are and their distribution depends on a subclass.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringofCodePointsLength(Random r, int minCodePoints, int maxCodePoints) abstract StringofCodeUnitsLength(Random r, int minCodeUnits, int maxCodeUnits) ofStringLength(Random r, int minCodeUnits, int maxCodeUnits) An alias forofCodeUnitsLength(Random, int, int).
-
Constructor Details
-
StringGenerator
public StringGenerator()
-
-
Method Details
-
ofStringLength
An alias forofCodeUnitsLength(Random, int, int). -
ofCodeUnitsLength
- Parameters:
minCodeUnits- Minimum number of code units (inclusive).maxCodeUnits- Maximum number of code units (inclusive).- Returns:
- Returns a string of variable length between
minCodeUnits(inclusive) andmaxCodeUnits(inclusive) length. Code units are essentially an equivalent ofchartype, seeStringclass for explanation. - Throws:
IllegalArgumentException- Thrown if the generator cannot emit random string of the given unit length. For example a generator emitting only extended unicodeGenerator plane characters (encoded as surrogate pairs) will not be able to emit an odd number of code units.
-
ofCodePointsLength
- Parameters:
minCodePoints- Minimum number of code points (inclusive).maxCodePoints- Maximum number of code points (inclusive).- Returns:
- Returns a string of variable length between
minCodePoints(inclusive) andmaxCodePoints(inclusive) length. Code points are full unicodeGenerator codepoints or an equivalent ofinttype, seeStringclass for explanation. The returnedString.length()may exceedmaxCodeUnitsbecause certain code points may be encoded as surrogate pairs.
-