[K/N][Tests] Move codegen test sources interfaceCallsNCasts..vector
^KT-61259
This commit is contained in:
committed by
Space Team
parent
56e1c5cbc6
commit
93642020ff
@@ -0,0 +1,21 @@
|
||||
|
||||
@file:OptIn(ExperimentalForeignApi::class)
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun convertIntToShortOrNull(i: Int, b: Boolean): Short? = if (b) i.convert() else null
|
||||
fun narrowIntToShortOrNull(i: Int, b: Boolean): Short? = if (b) i.narrow() else null
|
||||
fun signExtendShortToIntOrNull(i: Short, b: Boolean): Int? = if (b) i.signExtend() else null
|
||||
|
||||
fun box(): String {
|
||||
assertNull(convertIntToShortOrNull(0, false))
|
||||
assertEquals(1, convertIntToShortOrNull(1, true))
|
||||
|
||||
assertNull(narrowIntToShortOrNull(2, false))
|
||||
assertEquals(3, narrowIntToShortOrNull(3, true))
|
||||
|
||||
assertNull(signExtendShortToIntOrNull(4, false))
|
||||
assertEquals(5, signExtendShortToIntOrNull(5, true))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user