diff --git a/core-kotlin/src/test/kotlin/com/baeldung/random/RandomStringUnitTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/random/RandomStringUnitTest.kt index 74085367e8..62e8dfe720 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/random/RandomStringUnitTest.kt +++ b/core-kotlin/src/test/kotlin/com/baeldung/random/RandomStringUnitTest.kt @@ -52,7 +52,7 @@ class RandomStringUnitTest { random.nextBytes(bytes) 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("") assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))