[K/N][Tests] Migrate framework and objcexport tests

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-22 20:12:14 +01:00
committed by Space Team
parent f00a145dd7
commit 025771460c
136 changed files with 698 additions and 416 deletions
@@ -0,0 +1,3 @@
language = Objective-C
headers = Foundation/NSArray.h Foundation/NSValue.h Foundation/NSString.h
headerFilter = gh3343.h Foundation/NSArray.h Foundation/NSValue.h Foundation/NSString.h
+11
View File
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
NSString* foo1(int x) {
return [NSString stringWithFormat:@"%d", x];
}
NSArray* foo2(int x) {
NSValue* xx = @(x);
NSString* s = @"zzz";
return [NSArray arrayWithObjects: xx, s, nil];
}
+16
View File
@@ -0,0 +1,16 @@
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
import kotlinx.cinterop.*
import gh3343.*
import kotlin.native.ref.*
fun run(): List<Any?> {
val result = mutableListOf<Any?>()
result.add(foo1(42))
val list = foo2(117)
if (list != null) {
result.add(list.size)
for (x in list)
result.add(x)
}
return result
}
@@ -0,0 +1,23 @@
import Foundation
import Gh3343
func testGh3343() throws {
let list = Gh3343Kt.run()
try assertEquals(actual: list[0] as? String, expected: "42")
try assertEquals(actual: list[1] as? Int, expected: 2)
try assertEquals(actual: list[2] as? Int, expected: 117)
try assertEquals(actual: list[3] as? String, expected: "zzz")
}
// -------- Execution of the test --------
class Gh3343Tests : TestProvider {
var tests: [TestCase] = []
init() {
providers.append(self)
tests = [
TestCase(name: "Gh3343", method: withAutorelease(testGh3343)),
]
}
}