[K/N] Migrate runtime/text tests to new testing infra ^KT-61259

This commit is contained in:
Alexander Shabalin
2023-10-23 16:11:12 +02:00
committed by Space Team
parent e9983a947f
commit 17dc60aac9
22 changed files with 693 additions and 1240 deletions
@@ -0,0 +1,37 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package runtime.basic.print_utf8
import kotlin.test.*
import kotlinx.cinterop.toKString
fun convertUtf8to16(byteArray: ByteArray, action: (String) -> Unit) {
byteArray.decodeToString().let { action(it) }
byteArray.toKString().let { action(it) }
}
@Test
fun testPrint() {
// Valid strings.
println("Hello")
println("Привет")
println("\uD800\uDC00")
println("")
// Illegal surrogate pair -> default output
println("\uDC00\uD800")
// Lone surrogate -> default output
println("\uD80012")
println("\uDC0012")
println("12\uD800")
// https://github.com/JetBrains/kotlin-native/issues/1091
val array = byteArrayOf(0xF0.toByte(), 0x9F.toByte(), 0x98.toByte(), 0xA5.toByte())
convertUtf8to16(array) { badString ->
assertEquals(2, badString.length)
println(badString)
}
}
@@ -0,0 +1,10 @@
Hello
Привет
𐀀
12
12
12
😥
😥