Skip to content

Commit 5f91423

Browse files
authored
Merge pull request eugenp#5711 from nnhai1991/master
BAEL-1913 Generate a random alphanumeric string in Kotlin
2 parents 301ffdb + d2d77c5 commit 5f91423

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core-kotlin/src/test/kotlin/com/baeldung/random/RandomStringUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class RandomStringUnitTest {
5252
random.nextBytes(bytes)
5353

5454
var randomString = (0..bytes.size - 1).map { i ->
55-
charPool.get((bytes[i] and 0xFF.toByte() and charPool.size.toByte()).toInt())
55+
charPool.get((bytes[i] and 0xFF.toByte() and (charPool.size-1).toByte()).toInt())
5656
}.joinToString("")
5757

5858
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))

0 commit comments

Comments
 (0)