Merge pull request #5711 from nnhai1991/master

BAEL-1913 Generate a random alphanumeric string in Kotlin
This commit is contained in:
Loredana Crusoveanu 2018-11-17 20:46:00 +02:00 committed by GitHub
commit 5f91423fcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -52,7 +52,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.toByte()).toInt()) charPool.get((bytes[i] and 0xFF.toByte() and (charPool.size-1).toByte()).toInt())
}.joinToString("") }.joinToString("")
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX))) assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))