From bc144887eaa755d0bc980f2c9f8aa093eefc2453 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Mon, 1 Nov 2021 15:25:57 +0700 Subject: [PATCH] [K/N] Add native test for KT-48591 We can't rely on stdlib tests now, because they are not executed with compiler caches. --- .../tests/runtime/text/chars0.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/kotlin-native/backend.native/tests/runtime/text/chars0.kt b/kotlin-native/backend.native/tests/runtime/text/chars0.kt index c2595667244..3bdb1ebdf53 100644 --- a/kotlin-native/backend.native/tests/runtime/text/chars0.kt +++ b/kotlin-native/backend.native/tests/runtime/text/chars0.kt @@ -7,10 +7,6 @@ package runtime.text.chars0 import kotlin.test.* -fun assertTrue(v: Boolean) = if (!v) throw AssertionError() else Unit -fun assertFalse(v: Boolean) = if (v) throw AssertionError() else Unit -fun assertEquals(a: Int, b: Int) { if (a != b) throw AssertionError() } - fun testIsSupplementaryCodePoint() { assertFalse(Char.isSupplementaryCodePoint(-1)) for (c in 0..0xFFFF) { @@ -112,6 +108,20 @@ fun testCategory() { } catch (e: IllegalArgumentException) {} } +fun testIsHighSurrogate() { + assertTrue('\uD800'.isHighSurrogate()) + assertTrue('\uDBFF'.isHighSurrogate()) + assertFalse('\uDC00'.isHighSurrogate()) + assertFalse('\uDFFF'.isHighSurrogate()) +} + +fun testIsLowSurrogate() { + assertFalse('\uD800'.isLowSurrogate()) + assertFalse('\uDBFF'.isLowSurrogate()) + assertTrue('\uDC00'.isLowSurrogate()) + assertTrue('\uDFFF'.isLowSurrogate()) +} + @Test fun runTest() { testIsSurrogatePair() testToChars() @@ -119,4 +129,6 @@ fun testCategory() { testIsSupplementaryCodePoint() testCase() testCategory() + testIsHighSurrogate() + testIsLowSurrogate() } \ No newline at end of file