File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
core/commonTest/src/implementations/list Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package kotlinx.collections.immutable.implementations.immutableList
1818
1919import kotlinx.collections.immutable.internal.assert
2020import kotlin.math.pow
21+ import kotlin.random.*
2122import kotlin.test.*
2223
2324class 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())
You can’t perform that action at this time.
0 commit comments