[K/N][Tests] Migrate objcSmoke & objcTests tests

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-24 18:04:17 +01:00
committed by Space Team
parent 58f7dd1c83
commit 524f0d335e
98 changed files with 227 additions and 8 deletions
@@ -0,0 +1,18 @@
import kotlinx.cinterop.*
import kotlin.test.*
import objcTests.*
@Test fun testConversions() {
testMethodsOfAny(emptyList<Nothing>(), NSArray())
testMethodsOfAny(listOf(1, "foo"), nsArrayOf(1, "foo"))
testMethodsOfAny(42, NSNumber.numberWithInt(42), 17)
testMethodsOfAny(true, NSNumber.numberWithBool(true), false)
}
private fun testMethodsOfAny(kotlinObject: Any, equalNsObject: NSObject, otherObject: Any = Any()) {
assertEquals(kotlinObject.hashCode(), equalNsObject.hashCode())
assertEquals(kotlinObject.toString(), equalNsObject.toString())
assertEquals(kotlinObject, equalNsObject)
assertEquals(equalNsObject, kotlinObject)
assertNotEquals(equalNsObject, otherObject)
}