[stdlib] Improve documentation of Char.isWhitespace and test it behaves the same in different targets

This commit is contained in:
Ilya Gorbunov
2024-02-19 22:23:23 +01:00
committed by Space Team
parent baca742a31
commit 709076acc9
6 changed files with 38 additions and 5 deletions
+13
View File
@@ -17,6 +17,8 @@ class CharTest {
"Κκϰ", "Ππϖ", "Ρρϱ", "Σςσ", "Φφϕ", "ΩωΩ", "Ṡṡẛ",
"Θθϑϴ", "Iiİı",
)
val allCharsByCategory = (Char.MIN_VALUE..Char.MAX_VALUE).groupBy { it.category }
}
@Test
@@ -326,6 +328,17 @@ class CharTest {
assertEquals("Cc", CharCategory.CONTROL.code)
}
@Test
fun whitespace() {
val allWhitespace = (Char.MIN_VALUE..Char.MAX_VALUE).filter { it.isWhitespace() }
val expected =
listOf(CharCategory.SPACE_SEPARATOR, CharCategory.LINE_SEPARATOR, CharCategory.PARAGRAPH_SEPARATOR)
.flatMap { allCharsByCategory[it]!! } +
('\u0009'..'\u000D') +
('\u001C'..'\u001F')
assertEquals(expected.sorted(), allWhitespace)
}
@Test
fun lowercaseChar() {
assertEquals('\u0000', '\u0000'.lowercaseChar())