Add test case for LocaleBuilder with default locale with extensions.
Use Locale::getRoot().clone() instead of new Locale();
Add CI build bot with LANG that has extension tags
CC: gcc
CXX: g++
#-------------------------------------------------------------------------
+- job: ICU4C_Clang_Ubuntu_2004_LANG
+ displayName: 'C: Linux Clang (Ubuntu 20.04) - LANG has extension tags'
+ timeoutInMinutes: 30
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - checkout: self
+ lfs: true
+ fetchDepth: 10
+ - script: |
+ cd icu4c/source && ./runConfigureICU Linux && make -j2 check
+ displayName: 'Build and Test'
+ env:
+ CC: clang
+ CXX: clang++
+ LANG: "en_US@calendar=gregorian;hours=h12"
+
+#-------------------------------------------------------------------------
# VS 2019 Builds
#-------------------------------------------------------------------------
- job: ICU4C_MSVC_x64_Release_Distrelease
return *this;
}
if (extensions_ == nullptr) {
- extensions_ = new Locale();
+ extensions_ = Locale::getRoot().clone();
if (extensions_ == nullptr) {
status_ = U_MEMORY_ALLOCATION_ERROR;
return *this;
return *this;
}
if (extensions_ == nullptr) {
- extensions_ = new Locale();
- }
- if (extensions_ == nullptr) {
- status_ = U_MEMORY_ALLOCATION_ERROR;
- return *this;
+ extensions_ = Locale::getRoot().clone();
+ if (extensions_ == nullptr) {
+ status_ = U_MEMORY_ALLOCATION_ERROR;
+ return *this;
+ }
}
extensions_->setUnicodeKeywordValue(key, type, status_);
return *this;
return *this;
}
if (extensions_ == nullptr) {
- extensions_ = new Locale();
+ extensions_ = Locale::getRoot().clone();
if (extensions_ == nullptr) {
status_ = U_MEMORY_ALLOCATION_ERROR;
return *this;
return;
}
if (extensions_ == nullptr) {
- extensions_ = new Locale();
+ extensions_ = Locale::getRoot().clone();
if (extensions_ == nullptr) {
status_ = U_MEMORY_ALLOCATION_ERROR;
return;
TESTCASE_AUTO(TestAddUnicodeLocaleAttributeIllFormed);
TESTCASE_AUTO(TestLocaleBuilder);
TESTCASE_AUTO(TestLocaleBuilderBasic);
+ TESTCASE_AUTO(TestLocaleBuilderBasicWithExtensionsOnDefaultLocale);
TESTCASE_AUTO(TestPosixCases);
TESTCASE_AUTO(TestSetExtensionOthers);
TESTCASE_AUTO(TestSetExtensionPU);
"setRegion('') got Error: %s\n");
}
+void LocaleBuilderTest::TestLocaleBuilderBasicWithExtensionsOnDefaultLocale() {
+ // Change the default locale to one with extension tags.
+ UErrorCode status = U_ZERO_ERROR;
+ Locale originalDefault;
+ Locale::setDefault(Locale::createFromName("en-US-u-hc-h12"), status);
+ if (U_FAILURE(status)) {
+ errln("ERROR: Could not change the default locale");
+ return;
+ }
+
+ // Invoke the basic test now that the default locale has been changed.
+ TestLocaleBuilderBasic();
+
+ Locale::setDefault(originalDefault, status);
+ if (U_FAILURE(status)) {
+ errln("ERROR: Could not restore the default locale");
+ }
+}
+
void LocaleBuilderTest::TestSetLanguageWellFormed() {
// http://www.unicode.org/reports/tr35/tr35.html#unicode_language_subtag
// unicode_language_subtag = alpha{2,3} | alpha{5,8};
void TestAddUnicodeLocaleAttributeIllFormed(void);
void TestLocaleBuilder(void);
void TestLocaleBuilderBasic(void);
+ void TestLocaleBuilderBasicWithExtensionsOnDefaultLocale(void);
void TestPosixCases(void);
void TestSetExtensionOthers(void);
void TestSetExtensionPU(void);