@@ -15,6 +15,7 @@ import tests.distinctStringValues
1515import tests.stress.ExecutionTimeMeasuringTest
1616import tests.testOn
1717import kotlin.random.Random
18+ import kotlin.random.nextInt
1819import kotlin.test.*
1920import kotlin.time.ExperimentalTime
2021
@@ -319,7 +320,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() {
319320 maxIterationCount : Int ,
320321 afterIteration : () -> Unit ) {
321322 val towardStart = Random .nextBoolean()
322- val iterationCount = Random .nextInt(maxIterationCount)
323+ val iterationCount = Random .nextInt(0 .. maxIterationCount)
323324
324325 if (towardStart) {
325326 repeat(iterationCount) {
@@ -449,7 +450,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() {
449450 repeat(times = 100 ) {
450451 val createNew = Random .nextDouble() < 0.1
451452 if (createNew) {
452- val index = Random .nextInt(expected.size)
453+ val index = Random .nextInt(0 .. expected.size)
453454 builderIterator = builder.listIterator(index)
454455 expectedIterator = expected.listIterator(index)
455456 compare(expectedIterator, builderIterator) { listIteratorProperties() }
@@ -475,7 +476,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() {
475476 }
476477 }
477478 } else {
478- val maxIterationCount = expected.size / 3
479+ val maxIterationCount = expected.size / 3 + 1
479480 iterateWith(expectedIterator, builderIterator, maxIterationCount) { /* Do nothing after iteration */ }
480481 }
481482 }
0 commit comments