Skip to content

Commit

Permalink
ICU-22365 Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Jul 1, 2023
1 parent ec67c17 commit 09fb90f
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions icu4c/source/test/cintltst/ulocbuildertst.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,6 @@ static void TestSetVariantIllFormed() {
}
}

/*
static void TestSetUnicodeLocaleKeywordWellFormed() {
// http://www.unicode.org/reports/tr35/tr35.html#unicode_locale_extensions
// keyword = key (sep type)? ;
Expand All @@ -878,16 +877,17 @@ static void TestSetUnicodeLocaleKeywordWellFormed() {
};
for (int i = 0; i < UPRV_LENGTHOF(wellFormed_key_value); i += 2) {
UErrorCode status = U_ZERO_ERROR;
LocaleBuilder bld;
bld.setUnicodeLocaleKeyword(wellFormed_key_value[i],
wellFormed_key_value[i + 1]);
Locale loc = bld.build(status);
ULocaleBuilder bld = ulb_open();
ulb_setUnicodeLocaleKeyword(bld, wellFormed_key_value[i], wellFormed_key_value[i + 1]);
char buffer[ULOC_FULLNAME_CAPACITY];
ulb_build(bld, buffer, ULOC_FULLNAME_CAPACITY, &status);
if (U_FAILURE(status)) {
errln("setUnicodeLocaleKeyword(\"%s\", \"%s\") got Error: %s\n",
log_err("setUnicodeLocaleKeyword(\"%s\", \"%s\") got Error: %s\n",
wellFormed_key_value[i],
wellFormed_key_value[i + 1],
u_errorName(status));
}
ulb_close(bld);
}
}

Expand All @@ -900,15 +900,18 @@ static void TestSetUnicodeLocaleKeywordIllFormedKey() {
"zyzabcdef",
"Z0",
};
for (const char* ill : illFormed) {
for (int i = 0; i < UPRV_LENGTHOF(illFormed); i++) {
const char* ill = illFormed[i];
UErrorCode status = U_ZERO_ERROR;
LocaleBuilder bld;
bld.setUnicodeLocaleKeyword(ill, "abc");
Locale loc = bld.build(status);
ULocaleBuilder bld = ulb_open();
ulb_setUnicodeLocaleKeyword(bld, ill, "abc");
char buffer[ULOC_FULLNAME_CAPACITY];
ulb_build(bld, buffer, ULOC_FULLNAME_CAPACITY, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
errln("setUnicodeLocaleKeyword(\"%s\", \"abc\") should fail but has no Error\n",
log_err("setUnicodeLocaleKeyword(\"%s\", \"abc\") should fail but has no Error\n",
ill);
}
ulb_close(bld);
}
}

Expand All @@ -923,18 +926,22 @@ static void TestSetUnicodeLocaleKeywordIllFormedValue() {
"1ZB30zfk9-abc",
"2ck30zfk9-adsf023-234kcZ",
};
for (const char* ill : illFormed) {
for (int i = 0; i < UPRV_LENGTHOF(illFormed); i++) {
const char* ill = illFormed[i];
UErrorCode status = U_ZERO_ERROR;
LocaleBuilder bld;
bld.setUnicodeLocaleKeyword("ab", ill);
Locale loc = bld.build(status);
ULocaleBuilder bld = ulb_open();
ulb_setUnicodeLocaleKeyword(bld, "ab", ill);
char buffer[ULOC_FULLNAME_CAPACITY];
ulb_build(bld, buffer, ULOC_FULLNAME_CAPACITY, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
errln("setUnicodeLocaleKeyword(\"ab\", \"%s\") should fail but has no Error\n",
log_err("setUnicodeLocaleKeyword(\"ab\", \"%s\") should fail but has no Error\n",
ill);
}
ulb_close(bld);
}
}

/*
static void TestAddRemoveUnicodeLocaleAttribute() {
LocaleBuilder bld;
UErrorCode status = U_ZERO_ERROR;
Expand Down Expand Up @@ -1693,10 +1700,10 @@ void addLocaleBuilderTest(TestNode** root)
TESTCASE(TestSetRegionIllFormed);
TESTCASE(TestSetVariantWellFormed);
TESTCASE(TestSetVariantIllFormed);
/*
TESTCASE(TestSetUnicodeLocaleKeywordWellFormed);
TESTCASE(TestSetUnicodeLocaleKeywordIllFormedKey);
TESTCASE(TestSetUnicodeLocaleKeywordIllFormedValue);
/*
TESTCASE(TestAddRemoveUnicodeLocaleAttribute);
TESTCASE(TestAddRemoveUnicodeLocaleAttributeWellFormed);
TESTCASE(TestAddUnicodeLocaleAttributeIllFormed);
Expand Down

0 comments on commit 09fb90f

Please sign in to comment.