Null-terminate Collection.toArray destination only in JVM
In other platforms the elements following the collection elements should not be changed. As a part of efforts to stabilize Native stdlib.
This commit is contained in:
committed by
Space Team
parent
60455daa9d
commit
6fdfd4e8dd
@@ -5,6 +5,7 @@
|
||||
|
||||
package test.collections
|
||||
|
||||
import test.*
|
||||
import test.collections.behaviors.iteratorBehavior
|
||||
import test.collections.behaviors.listIteratorBehavior
|
||||
import test.collections.behaviors.listIteratorProperties
|
||||
@@ -622,12 +623,20 @@ class ArrayDequeTest {
|
||||
|
||||
val dest = Array(expected.size + 2) { it + 100 }
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val nullTerminatedExpected = (expected as Array<Any?>) + null + (expected.size + 101)
|
||||
val expectedDest = buildList {
|
||||
addAll(expected)
|
||||
if (TestPlatform.current == TestPlatform.Jvm) {
|
||||
add(null)
|
||||
} else {
|
||||
add(expected.size + 100)
|
||||
}
|
||||
add(expected.size + 101)
|
||||
}.toTypedArray()
|
||||
|
||||
val actual = deque.testToArray(dest)
|
||||
assertTrue(
|
||||
nullTerminatedExpected contentEquals actual,
|
||||
message = "Expected: ${nullTerminatedExpected.contentToString()}, Actual: ${actual.contentToString()}"
|
||||
expectedDest contentEquals actual,
|
||||
message = "Expected: ${expectedDest.contentToString()}, Actual: ${actual.contentToString()}"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user