[K/N] Move cinterop tests from standalone to codegen/box
^KT-61259
This commit is contained in:
committed by
Space Team
parent
0b0ba3160f
commit
c09e8909d4
@@ -0,0 +1,34 @@
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// MODULE: cinterop
|
||||
// FILE: carrayPointers.def
|
||||
---
|
||||
int (*arrayPointer)[1];
|
||||
|
||||
int globalArray[3] = {1, 2, 3};
|
||||
|
||||
struct StructWithArrayPtr {
|
||||
int (*arrayPointer)[1];
|
||||
};
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import carrayPointers.*
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun box(): String {
|
||||
arrayPointer = globalArray
|
||||
assertEquals(globalArray[0], arrayPointer!![0])
|
||||
arrayPointer!![0] = 15
|
||||
assertEquals(15, globalArray[0])
|
||||
|
||||
memScoped {
|
||||
val struct = alloc<StructWithArrayPtr>()
|
||||
struct.arrayPointer = globalArray
|
||||
assertEquals(globalArray[0], struct.arrayPointer!![0])
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user