Class CodepointSetGenerator
java.lang.Object
com.carrotsearch.randomizedtesting.generators.StringGenerator
com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator
- Direct Known Subclasses:
AsciiAlphanumGenerator
,AsciiLettersGenerator
A string generator from a predefined set of codepoints or characters.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int[]
(package private) final int[]
(package private) final int[]
-
Constructor Summary
ConstructorsConstructorDescriptionCodepointSetGenerator
(char[] chars) All characters must be from BMP (no parts of surrogate pairs allowed).Parse the givenString
and split into BMP and supplementary codepoints. -
Method Summary
Modifier and TypeMethodDescriptionprivate int[]
concat
(int[]... arrays) private boolean
isOdd
(int v) Is a given number odd?private boolean
isSurrogate
(char chr) ofCodePointsLength
(Random r, int minCodePoints, int maxCodePoints) ofCodeUnitsLength
(Random r, int minCodeUnits, int maxCodeUnits) Methods inherited from class com.carrotsearch.randomizedtesting.generators.StringGenerator
ofStringLength
-
Field Details
-
bmp
final int[] bmp -
supplementary
final int[] supplementary -
all
final int[] all
-
-
Constructor Details
-
CodepointSetGenerator
public CodepointSetGenerator(char[] chars) All characters must be from BMP (no parts of surrogate pairs allowed). -
CodepointSetGenerator
Parse the givenString
and split into BMP and supplementary codepoints.
-
-
Method Details
-
ofCodeUnitsLength
- Specified by:
ofCodeUnitsLength
in classStringGenerator
- 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 ofchar
type, seeString
class for explanation.
-
ofCodePointsLength
- Specified by:
ofCodePointsLength
in classStringGenerator
- 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 ofint
type, seeString
class for explanation. The returnedString.length()
may exceedmaxCodeUnits
because certain code points may be encoded as surrogate pairs.
-
isOdd
private boolean isOdd(int v) Is a given number odd? -
concat
private int[] concat(int[]... arrays) -
isSurrogate
private boolean isSurrogate(char chr)
-