Skip to content

Commit 8dd7476

Browse files
committed
Test at most 12 tries of each height with size up to 1048576 elements
1 parent b6dda56 commit 8dd7476

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

core/commonTest/src/implementations/list/TrieIteratorTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package kotlinx.collections.immutable.implementations.immutableList
1818

1919
import kotlinx.collections.immutable.internal.assert
2020
import kotlin.math.pow
21+
import kotlin.random.*
2122
import kotlin.test.*
2223

2324
class TrieIteratorTest {
@@ -55,21 +56,20 @@ class TrieIteratorTest {
5556

5657
@Test
5758
fun simpleTest() {
58-
var lastStop = 1
59-
for (height in 1..7) {
60-
for (leafCount in lastStop..(1 shl 12) step height) {
61-
if (MAX_BUFFER_SIZE.toDouble().pow(height - 1) < leafCount) {
62-
lastStop = leafCount
63-
break
64-
}
59+
for (height in 1..4) {
60+
val maxCount = MAX_BUFFER_SIZE.toDouble().pow(height - 1).toInt()
61+
val minCount = maxCount / 32 + 1
62+
val leafCountRange = minCount..maxCount
63+
val leafCounts = (listOf(minCount, maxCount) + List(10) { Random.nextInt(leafCountRange) }).distinct().sorted()
6564

65+
for (leafCount in leafCounts) {
6666
val root = makeRoot(height, leafCount)
6767
val size = leafCount * MAX_BUFFER_SIZE
6868

6969
val iterator = TrieIterator<Int>(root, 0, size, height)
70-
repeat(size) { it ->
70+
for (index in 0 until size) {
7171
assertTrue(iterator.hasNext())
72-
assertEquals(it, iterator.next())
72+
assertEquals(index, iterator.next())
7373
}
7474

7575
assertFalse(iterator.hasNext())

0 commit comments

Comments
 (0)