[K/N] Internalize CharCategory.value/valueOf
As a part of efforts to stabilize K/N stdlib.
This commit is contained in:
committed by
Space Team
parent
7eba68e62b
commit
208b279d2b
@@ -70,17 +70,6 @@ fun testCase() {
|
||||
}
|
||||
|
||||
fun testCategory() {
|
||||
assertEquals('\n'.category.value, CharCategory.CONTROL.value)
|
||||
assertEquals('1'.category.value, CharCategory.DECIMAL_DIGIT_NUMBER.value)
|
||||
assertEquals(' '.category.value, CharCategory.SPACE_SEPARATOR.value)
|
||||
assertEquals('a'.category.value, CharCategory.LOWERCASE_LETTER.value)
|
||||
assertEquals('A'.category.value, CharCategory.UPPERCASE_LETTER.value)
|
||||
assertEquals('<'.category.value, CharCategory.MATH_SYMBOL.value)
|
||||
assertEquals(';'.category.value, CharCategory.OTHER_PUNCTUATION.value)
|
||||
assertEquals('_'.category.value, CharCategory.CONNECTOR_PUNCTUATION.value)
|
||||
assertEquals('$'.category.value, CharCategory.CURRENCY_SYMBOL.value)
|
||||
assertEquals('\u2029'.category.value, CharCategory.PARAGRAPH_SEPARATOR.value)
|
||||
|
||||
assertTrue('\n' in CharCategory.CONTROL)
|
||||
assertTrue('1' in CharCategory.DECIMAL_DIGIT_NUMBER)
|
||||
assertTrue(' ' in CharCategory.SPACE_SEPARATOR)
|
||||
@@ -91,21 +80,6 @@ fun testCategory() {
|
||||
assertTrue('_' in CharCategory.CONNECTOR_PUNCTUATION)
|
||||
assertTrue('$' in CharCategory.CURRENCY_SYMBOL)
|
||||
assertTrue('\u2029' in CharCategory.PARAGRAPH_SEPARATOR)
|
||||
|
||||
try {
|
||||
CharCategory.valueOf(-1)
|
||||
throw AssertionError()
|
||||
} catch (e: IllegalArgumentException) {}
|
||||
|
||||
try {
|
||||
CharCategory.valueOf(31)
|
||||
throw AssertionError()
|
||||
} catch (e: IllegalArgumentException) {}
|
||||
|
||||
try {
|
||||
CharCategory.valueOf(17)
|
||||
throw AssertionError()
|
||||
} catch (e: IllegalArgumentException) {}
|
||||
}
|
||||
|
||||
fun testIsHighSurrogate() {
|
||||
|
||||
@@ -7,7 +7,7 @@ package kotlin.text
|
||||
/**
|
||||
* Represents the character general category in the Unicode specification.
|
||||
*/
|
||||
public actual enum class CharCategory(public val value: Int, public actual val code: String) {
|
||||
public actual enum class CharCategory(internal val value: Int, public actual val code: String) {
|
||||
/**
|
||||
* General category "Cn" in the Unicode specification.
|
||||
*/
|
||||
@@ -164,7 +164,7 @@ public actual enum class CharCategory(public val value: Int, public actual val c
|
||||
public actual operator fun contains(char: Char): Boolean = char.getCategoryValue() == this.value
|
||||
|
||||
public companion object {
|
||||
public fun valueOf(category: Int): CharCategory =
|
||||
internal fun valueOf(category: Int): CharCategory =
|
||||
when (category) {
|
||||
in 0..16 -> values()[category]
|
||||
in 18..30 -> values()[category - 1]
|
||||
|
||||
Reference in New Issue
Block a user