[K/N][Tests] Migrate framework and objcexport tests
^KT-61259
This commit is contained in:
committed by
Space Team
parent
f00a145dd7
commit
025771460c
@@ -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
|
||||
@@ -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];
|
||||
}
|
||||
@@ -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)),
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user