Merge pull request #10267 from eugenp/KTLN-173
simplify random string generation
This commit is contained in:
commit
745ec2b2cf
|
@ -54,7 +54,7 @@ class RandomStringUnitTest {
|
||||||
random.nextBytes(bytes)
|
random.nextBytes(bytes)
|
||||||
|
|
||||||
var randomString = (0..bytes.size - 1).map { i ->
|
var randomString = (0..bytes.size - 1).map { i ->
|
||||||
charPool.get((bytes[i] and 0xFF.toByte() and (charPool.size-1).toByte()).toInt())
|
charPool[random.nextInt(charPool.size)]
|
||||||
}.joinToString("")
|
}.joinToString("")
|
||||||
|
|
||||||
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))
|
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))
|
||||||
|
|
Loading…
Reference in New Issue