Migrate stdlib, tests and samples to new case conversion api
This commit is contained in:
@@ -717,6 +717,7 @@ public inline fun String.toPattern(flags: Int = 0): java.util.regex.Pattern {
|
||||
@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }", "java.util.Locale"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
public actual fun String.capitalize(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
return capitalize(Locale.getDefault())
|
||||
}
|
||||
|
||||
@@ -759,6 +760,7 @@ public fun String.capitalize(locale: Locale): String {
|
||||
@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase(Locale.getDefault()) }", "java.util.Locale"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
public actual fun String.decapitalize(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
return if (isNotEmpty() && !this[0].isLowerCase()) substring(0, 1).toLowerCase() + substring(1) else this
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ class StringJVMTest {
|
||||
assertEquals("UTF-32BE", Charsets.UTF_32BE.name())
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test fun capitalize() {
|
||||
fun testCapitalize(expected: String, string: String) {
|
||||
assertEquals(expected, string.capitalize())
|
||||
@@ -90,6 +91,7 @@ class StringJVMTest {
|
||||
|
||||
@Test fun decapitalize() {
|
||||
fun testDecapitalize(expected: String, string: String) {
|
||||
@Suppress("DEPRECATION")
|
||||
assertEquals(expected, string.decapitalize())
|
||||
assertEquals(expected, string.replaceFirstChar { it.lowercase(Locale.getDefault()) })
|
||||
}
|
||||
@@ -98,6 +100,7 @@ class StringJVMTest {
|
||||
testDecapitalize("dzdzdz", "Dzdzdz")
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test fun capitalizeLocale() {
|
||||
fun testCapitalizeLocale(expected: String, string: String, locale: Locale) {
|
||||
assertEquals(expected, string.capitalize(locale))
|
||||
@@ -122,6 +125,7 @@ class StringJVMTest {
|
||||
|
||||
@Test fun decapitalizeLocale() {
|
||||
fun testDecapitalizeLocale(expected: String, string: String, locale: Locale) {
|
||||
@Suppress("DEPRECATION")
|
||||
assertEquals(expected, string.decapitalize(locale))
|
||||
assertEquals(expected, string.replaceFirstChar { it.lowercase(locale) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user