mocobeta commented on a change in pull request #2064:
URL: https://github.com/apache/lucene-solr/pull/2064#discussion_r517929357
##########
File path:
lucene/test-framework/src/java/org/apache/lucene/util/fst/FSTTester.java
##########
@@ -95,7 +95,7 @@ private static BytesRef toBytesRef(IntsRef ir) {
return br;
}
- static String getRandomString(Random random) {
+ public static String getRandomString(Random random) {
Review comment:
Yes, they look similar except for that Lucene's TestUtil selects
different codepoint range (`blockStarts` and `blockEnds`) to generate random
String instance each time. I think both one is okay for the test, what do you
think?
o.a.l.util.TestUtil.randomRealisticUnicodeString()
```
/** Returns random string of length between min and max codepoints, all
codepoints within the same unicode block. */
public static String randomRealisticUnicodeString(Random r, int minLength,
int maxLength) {
final int end = nextInt(r, minLength, maxLength);
final int block = r.nextInt(blockStarts.length);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < end; i++)
sb.appendCodePoint(nextInt(r, blockStarts[block], blockEnds[block]));
return sb.toString();
}
```
com.carrotsearch.randomizedtesting.generators.UnicodeGenerator.ofCodePointsLength()
```
public String ofCodePointsLength(Random r, int minCodePoints, int
maxCodePoints) {
int length = RandomNumbers.randomIntBetween(r, minCodePoints,
maxCodePoints);
int [] chars = new int [length];
for (int i = 0; i < chars.length; i++) {
int v = RandomNumbers.randomIntBetween(r, 0, CODEPOINT_RANGE);
if (v >= Character.MIN_SURROGATE)
v += SURROGATE_RANGE;
chars[i] = v;
}
return new String(chars, 0, chars.length);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]