platform.zlib: fix + mingw + test (#1880)

This commit is contained in:
Mike Sinkovsky
2018-08-16 19:17:00 +05:00
committed by Nikolay Igotti
parent d3d6d49b68
commit 3ad52b8736
7 changed files with 182 additions and 3 deletions
+6
View File
@@ -2841,6 +2841,12 @@ task interop_libiconv(type: RunStandaloneKonanTest) {
goldValue = "72 72\n101 101\n108 108\n108 108\n111 111\n33 33\n"
}
task interop_zlib(type: RunStandaloneKonanTest) {
disabled = (project.testTarget != null)
source = "interop/platform_zlib.kt"
goldValue = "Hello!\nHello!\n"
}
task produce_dynamic(type: DynamicKonanTest) {
disabled = (project.testTarget != null && project.testTarget != project.hostName)
source = "produce_dynamic/simple/hello.kt"
@@ -0,0 +1,21 @@
import kotlinx.cinterop.*
import platform.zlib.*
val source = immutableBinaryBlobOf(0xF3, 0x48, 0xCD, 0xC9, 0xC9, 0x57, 0x04, 0x00).asCPointer(0)!!
val golden = immutableBinaryBlobOf(0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21, 0x00).asCPointer(0)!!
fun main(args: Array<String>) = memScoped {
val buffer = allocArray<ByteVar>(32)
val z = alloc<z_stream>().apply {
next_in = source
avail_in = 8
next_out = buffer
avail_out = 32
}.ptr
if (inflateInit2(z, -15) == Z_OK && inflate(z, Z_FINISH) == Z_STREAM_END && inflateEnd(z) == Z_OK)
println(buffer.toKString())
println(golden.toKString())
}