classlib: fix toLowerCase/toUpperCase on Locale.ROOT (#862)

This commit is contained in:
Jonathan Coates 2023-11-19 18:45:32 +00:00 committed by GitHub
parent fa5fa3df47
commit 4fc43a5597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -278,7 +278,7 @@ public final class TLocale implements TCloneable, TSerializable {
public TString toLanguageTag() {
StringBuilder result = new StringBuilder();
result.append(languageCode);
result.append(languageCode.isEmpty() ? "und" : languageCode);
if (!countryCode.isEmpty()) {
result.append('-');
result.append(countryCode);

View File

@ -328,6 +328,7 @@ public class StringTest {
assertEquals("İSTANBUL", turkish.toUpperCase(new Locale("tr", "TR")));
assertNotEquals(common.toUpperCase(Locale.US), turkish.toUpperCase(new Locale("tr", "TR")));
assertEquals(common.toUpperCase(Locale.US), common.toUpperCase(Locale.CANADA));
assertEquals(common.toUpperCase(Locale.US), common.toUpperCase(Locale.ROOT));
}
@Test

View File

@ -70,5 +70,6 @@ public class LocaleTest {
assertEquals("zh-CN", Locale.SIMPLIFIED_CHINESE.toLanguageTag());
assertEquals("en-GB", Locale.UK.toLanguageTag());
assertEquals("en-US", Locale.US.toLanguageTag());
assertEquals("und", Locale.ROOT.toLanguageTag());
}
}