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
18
18
19
19
import kotlinx.collections.immutable.internal.assert
20
20
import kotlin.math.pow
21
+ import kotlin.random.*
21
22
import kotlin.test.*
22
23
23
24
class TrieIteratorTest {
@@ -55,21 +56,20 @@ class TrieIteratorTest {
55
56
56
57
@Test
57
58
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()
65
64
65
+ for (leafCount in leafCounts) {
66
66
val root = makeRoot(height, leafCount)
67
67
val size = leafCount * MAX_BUFFER_SIZE
68
68
69
69
val iterator = TrieIterator <Int >(root, 0 , size, height)
70
- repeat( size) { it ->
70
+ for (index in 0 until size) {
71
71
assertTrue(iterator.hasNext())
72
- assertEquals(it , iterator.next())
72
+ assertEquals(index , iterator.next())
73
73
}
74
74
75
75
assertFalse(iterator.hasNext())
You can’t perform that action at this time.
0 commit comments