Unverified Commit d2c2fa33 authored by Nikolay Igotti's avatar Nikolay Igotti Committed by GitHub

Ios test with resource (#302)

parent bb9cefcb
package org.jetbrains.skiko
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.toKString
import kotlinx.cinterop.usePinned
import platform.Foundation.NSBundle
import platform.posix.*
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
fun resourcePath(): String {
val kexeDir = NSBundle.mainBundle.bundlePath
// Binary currently compiled into `build/bin/iosX64/debugTest`.
return "$kexeDir/../../../../src/iosTest/resources"
}
class BasicIosTests {
@Test
fun resourceAccess() {
val path = "${resourcePath()}/data.txt"
val f = fopen(path, "r") ?: throw Error("cannot open $path: ${strerror(errno)?.toKString()}")
val buf = ByteArray(200)
buf.usePinned {
val rv = fread(it.addressOf(0), 1, buf.size.toULong(), f)
assertTrue { rv != 0UL }
}
assertEquals("This is test data.\n", buf.toKString())
fclose(f)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment