KT-38817 capitalize uses title case for the first char where available
This unifies its behavior with new capitalize overload with Locale. Co-authored-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
@@ -74,6 +74,25 @@ class StringJVMTest {
|
||||
assertEquals("UTF-32BE", Charsets.UTF_32BE.name())
|
||||
}
|
||||
|
||||
@Test fun capitalize() {
|
||||
// Case mapping that results in multiple characters (validating Character.toUpperCase was not used).
|
||||
assertEquals("SSßß", "ßßß".capitalize())
|
||||
|
||||
// Case mapping where title case is different than uppercase and so Character.toTitleCase is preferred.
|
||||
assertEquals("Dzdzdz", "dzdzdz".capitalize())
|
||||
assertEquals("DZDZDZ", "DZDZDZ".capitalize())
|
||||
}
|
||||
|
||||
@Test fun decapitalize() {
|
||||
assertEquals("aBC", "ABC".decapitalize())
|
||||
assertEquals("abc", "Abc".decapitalize())
|
||||
assertEquals("abc", "abc".decapitalize())
|
||||
|
||||
// Case mapping where title case is different than uppercase.
|
||||
assertEquals("dzdzdz", "DZdzdz".decapitalize())
|
||||
assertEquals("dzdzdz", "Dzdzdz".decapitalize())
|
||||
}
|
||||
|
||||
@Test fun capitalizeLocale() {
|
||||
assertEquals("ABC", "ABC".capitalize(Locale.US))
|
||||
assertEquals("Abc", "Abc".capitalize(Locale.US))
|
||||
|
||||
Reference in New Issue
Block a user