ICU-13183 on branch - Add more tests and sample data
X-SVN-Rev: 40127
This commit is contained in:
parent
56e884e22e
commit
458a47f288
@ -1133,7 +1133,12 @@ zh{
|
||||
Timezone{"{1}{0}"}
|
||||
}
|
||||
availableFormats{
|
||||
Bh{"Bh时"}
|
||||
Bhm{"Bh:mm"}
|
||||
Bhms{"Bh:mm:ss"}
|
||||
E{"ccc"}
|
||||
EBhm{"EBh:mm"}
|
||||
EBms{"EBh:mm:ss"}
|
||||
EHm{"EHH:mm"}
|
||||
EHms{"EHH:mm:ss"}
|
||||
Ed{"d日E"}
|
||||
|
@ -1089,31 +1089,39 @@ void IntlTestDateTimePatternGeneratorAPI::testStaticGetSkeleton(/*char *par*/)
|
||||
}
|
||||
|
||||
void IntlTestDateTimePatternGeneratorAPI::testC() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
const int32_t numLocales = 11;
|
||||
|
||||
const char* tests[numLocales][3] = {
|
||||
const char* tests[][3] = {
|
||||
// These may change with actual data for Bhmm/bhmm skeletons
|
||||
{"zh", "Cm", "h:mm B"},
|
||||
{"zh", "CCCm", "h:mm BBBB"},
|
||||
{"zh", "CCCCCm", "h:mm BBBBB"},
|
||||
{"zh", "Cm", "h:mm B"},
|
||||
{"de", "Cm", "HH:mm"},
|
||||
{"en", "Cm", "h:mm a"},
|
||||
{"en", "CCCm", "h:mm aaaa"},
|
||||
{"en", "CCCCCm", "h:mm aaaaa"},
|
||||
{"en-BN", "Cm", "h:mm b"},
|
||||
{"gu-IN", "Cm", "h:mm B"},
|
||||
{"und-IN", "Cm", "h:mm a"},
|
||||
{"zh", "Cm", "Bh:mm"},
|
||||
{"zh", "CCm", "Bhh:mm"},
|
||||
{"zh", "CCCm", "BBBBh:mm"},
|
||||
{"zh", "CCCCm", "BBBBhh:mm"},
|
||||
{"zh", "CCCCCm", "BBBBBh:mm"},
|
||||
{"zh", "CCCCCCm", "BBBBBhh:mm"},
|
||||
{"de", "Cm", "HH:mm"},
|
||||
{"de", "CCm", "HH:mm"},
|
||||
{"de", "CCCm", "HH:mm"},
|
||||
{"de", "CCCCm", "HH:mm"},
|
||||
{"en", "Cm", "h:mm a"},
|
||||
{"en", "CCm", "hh:mm a"},
|
||||
{"en", "CCCm", "h:mm aaaa"},
|
||||
{"en", "CCCCm", "hh:mm aaaa"},
|
||||
{"en", "CCCCCm", "h:mm aaaaa"},
|
||||
{"en", "CCCCCCm", "hh:mm aaaaa"},
|
||||
{"en-BN", "Cm", "h:mm b"},
|
||||
{"gu-IN", "Cm", "h:mm B"},
|
||||
{"und-IN", "Cm", "h:mm a"}
|
||||
};
|
||||
|
||||
for (int32_t i = 0; i < numLocales; ++i) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t numTests = UPRV_LENGTHOF(tests);
|
||||
for (int32_t i = 0; i < numTests; ++i) {
|
||||
DateTimePatternGenerator *gen = DateTimePatternGenerator::createInstance(Locale(tests[i][0]), status);
|
||||
if (gen == NULL) {
|
||||
dataerrln("FAIL: DateTimePatternGenerator::createInstance failed for %s", tests[i][0]);
|
||||
return;
|
||||
}
|
||||
UnicodeString pattern = gen->getBestPattern(tests[i][1], status);
|
||||
UDateTimePatternMatchOptions options = UDATPG_MATCH_HOUR_FIELD_LENGTH;
|
||||
UnicodeString pattern = gen->getBestPattern(tests[i][1], options, status);
|
||||
UnicodeString expectedPattern = tests[i][2];
|
||||
|
||||
char message[100] = "\0";
|
||||
@ -1140,18 +1148,33 @@ void IntlTestDateTimePatternGeneratorAPI::testSkeletonsWithDayPeriods() {
|
||||
};
|
||||
const char* testItems[][2] = {
|
||||
// sample requested skeletons and results
|
||||
// skel pattern
|
||||
{ "H", "H"},
|
||||
{ "aH", "H"},
|
||||
{ "BH", "H"},
|
||||
{ "h", "h a"},
|
||||
{ "ah", "h a"},
|
||||
{ "bh", "h b"},
|
||||
{ "Bh", "B h"},
|
||||
{ "BBBBh", "BBBB h"},
|
||||
{ "a", "a"},
|
||||
{ "b", "b"},
|
||||
{ "B", "B"}
|
||||
// skel pattern
|
||||
{ "H", "H"},
|
||||
{ "HH", "HH"},
|
||||
{ "aH", "H"},
|
||||
{ "aHH", "HH"},
|
||||
{ "BH", "H"},
|
||||
{ "BHH", "HH"},
|
||||
{ "BBBBH", "H"},
|
||||
{ "h", "h a"},
|
||||
{ "hh", "hh a"},
|
||||
{ "ah", "h a"},
|
||||
{ "ahh", "hh a"},
|
||||
{ "aaaah", "h aaaa"},
|
||||
{ "aaaahh", "hh aaaa"},
|
||||
{ "bh", "h b"},
|
||||
{ "bhh", "hh b"},
|
||||
{ "bbbbh", "h bbbb"},
|
||||
{ "Bh", "B h"},
|
||||
{ "Bhh", "B hh"},
|
||||
{ "BBBBh", "BBBB h"},
|
||||
{ "BBBBhh", "BBBB hh"},
|
||||
{ "a", "a"},
|
||||
{ "aaaaa", "aaaaa"},
|
||||
{ "b", "b"},
|
||||
{ "bbbb", "bbbb"},
|
||||
{ "B", "B"},
|
||||
{ "BBBB", "BBBB"},
|
||||
};
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
DateTimePatternGenerator *gen = DateTimePatternGenerator::createEmptyInstance(status);
|
||||
@ -1171,7 +1194,8 @@ void IntlTestDateTimePatternGeneratorAPI::testSkeletonsWithDayPeriods() {
|
||||
len = UPRV_LENGTHOF(testItems);
|
||||
for (i = 0; i < len; i++) {
|
||||
status = U_ZERO_ERROR;
|
||||
UnicodeString result = gen->getBestPattern(UnicodeString(testItems[i][0]), status);
|
||||
UDateTimePatternMatchOptions options = UDATPG_MATCH_HOUR_FIELD_LENGTH;
|
||||
UnicodeString result = gen->getBestPattern(UnicodeString(testItems[i][0]), options, status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("ERROR: getBestPattern %s fail, status: %s", testItems[i][0], u_errorName(status));
|
||||
} else if (result != UnicodeString(testItems[i][1])) {
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:be32359b49e989b80821acea019b8e01807b726a4f57bf1322235f03c0c11709
|
||||
size 12153095
|
||||
oid sha256:a2e7756f45badde8ea612be307feb2a7674c0c52062e524c30a653fced4b710b
|
||||
size 12153152
|
||||
|
@ -56,21 +56,31 @@ public class DateTimeGeneratorTest extends TestFmwk {
|
||||
public void TestC() {
|
||||
String[][] tests = {
|
||||
// These may change with actual data for Bhmm/bhmm skeletons
|
||||
{"zh", "Cm", "h:mm B"},
|
||||
{"zh", "CCCm", "h:mm BBBB"},
|
||||
{"zh", "CCCCCm", "h:mm BBBBB"},
|
||||
{"de", "Cm", "HH:mm"},
|
||||
{"en", "Cm", "h:mm a"},
|
||||
{"en", "CCCm", "h:mm aaaa"},
|
||||
{"en", "CCCCCm", "h:mm aaaaa"},
|
||||
{"en-BN", "Cm", "h:mm b"},
|
||||
{"gu-IN", "Cm", "h:mm B"},
|
||||
{"und-IN", "Cm", "h:mm a"},
|
||||
{"zh", "Cm", "Bh:mm"},
|
||||
{"zh", "CCm", "Bhh:mm"},
|
||||
{"zh", "CCCm", "BBBBh:mm"},
|
||||
{"zh", "CCCCm", "BBBBhh:mm"},
|
||||
{"zh", "CCCCCm", "BBBBBh:mm"},
|
||||
{"zh", "CCCCCCm", "BBBBBhh:mm"},
|
||||
{"de", "Cm", "HH:mm"},
|
||||
{"de", "CCm", "HH:mm"},
|
||||
{"de", "CCCm", "HH:mm"},
|
||||
{"de", "CCCCm", "HH:mm"},
|
||||
{"en", "Cm", "h:mm a"},
|
||||
{"en", "CCm", "hh:mm a"},
|
||||
{"en", "CCCm", "h:mm aaaa"},
|
||||
{"en", "CCCCm", "hh:mm aaaa"},
|
||||
{"en", "CCCCCm", "h:mm aaaaa"},
|
||||
{"en", "CCCCCCm", "hh:mm aaaaa"},
|
||||
{"en-BN", "Cm", "h:mm b"},
|
||||
{"gu-IN", "Cm", "h:mm B"},
|
||||
{"und-IN", "Cm", "h:mm a"},
|
||||
};
|
||||
for (String[] test : tests) {
|
||||
DateTimePatternGenerator gen = DateTimePatternGenerator.getInstance(ULocale.forLanguageTag(test[0]));
|
||||
String skeleton = test[1];
|
||||
String pattern = gen.getBestPattern(skeleton);
|
||||
int options = DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH;
|
||||
String pattern = gen.getBestPattern(skeleton, options);
|
||||
assertEquals(test[0] + "/" + skeleton, test[2], pattern);
|
||||
}
|
||||
}
|
||||
@ -86,18 +96,33 @@ public class DateTimeGeneratorTest extends TestFmwk {
|
||||
};
|
||||
String[][] testItems = {
|
||||
// sample requested skeletons and results
|
||||
// skel pattern
|
||||
{ "H", "H"},
|
||||
{ "aH", "H"},
|
||||
{ "BH", "H"},
|
||||
{ "h", "h a"},
|
||||
{ "ah", "h a"},
|
||||
{ "bh", "h b"},
|
||||
{ "Bh", "B h"},
|
||||
{ "BBBBh", "BBBB h"},
|
||||
{ "a", "a"},
|
||||
{ "b", "b"},
|
||||
{ "B", "B"},
|
||||
// skel pattern
|
||||
{ "H", "H"},
|
||||
{ "HH", "HH"},
|
||||
{ "aH", "H"},
|
||||
{ "aHH", "HH"},
|
||||
{ "BH", "H"},
|
||||
{ "BHH", "HH"},
|
||||
{ "BBBBH", "H"},
|
||||
{ "h", "h a"},
|
||||
{ "hh", "hh a"},
|
||||
{ "ah", "h a"},
|
||||
{ "ahh", "hh a"},
|
||||
{ "aaaah", "h aaaa"},
|
||||
{ "aaaahh", "hh aaaa"},
|
||||
{ "bh", "h b"},
|
||||
{ "bhh", "hh b"},
|
||||
{ "bbbbh", "h bbbb"},
|
||||
{ "Bh", "B h"},
|
||||
{ "Bhh", "B hh"},
|
||||
{ "BBBBh", "BBBB h"},
|
||||
{ "BBBBhh", "BBBB hh"},
|
||||
{ "a", "a"},
|
||||
{ "aaaaa", "aaaaa"},
|
||||
{ "b", "b"},
|
||||
{ "bbbb", "bbbb"},
|
||||
{ "B", "B"},
|
||||
{ "BBBB", "BBBB"},
|
||||
};
|
||||
DateTimePatternGenerator gen = DateTimePatternGenerator.getEmptyInstance();
|
||||
DateTimePatternGenerator.PatternInfo returnInfo = new DateTimePatternGenerator.PatternInfo();
|
||||
@ -109,7 +134,8 @@ public class DateTimeGeneratorTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
for (String[] testItem : testItems) {
|
||||
String pattern = gen.getBestPattern(testItem[0]);
|
||||
int options = DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH;
|
||||
String pattern = gen.getBestPattern(testItem[0], options);
|
||||
if (!pattern.equals(testItem[1])) {
|
||||
errln("getBestPattern for skeleton " + testItem[0] + ", expected " + testItem[1] + ", got " + pattern);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user