ICU-6991 Code coverage for missing functions in CEList, CollData, BoyerMooreSearch, PluralFormat.

X-SVN-Rev: 26588
This commit is contained in:
John Vu 2009-09-02 22:27:16 +00:00
parent d65164c274
commit beeba02f88
2 changed files with 104 additions and 2 deletions
icu4c/source/test/intltest

View file

@ -61,7 +61,7 @@ void PluralFormatTest::pluralFormatBasicTest(/*char *par*/)
NumberFormat *numFmt = NumberFormat::createInstance(status[0]);
if (U_FAILURE(status[0])) {
dataerrln("ERROR: Could not create NumberFormat instance with default locale ");
}
}
for (int32_t i=0; i< 8; ++i) {
status[i] = U_ZERO_ERROR;
@ -87,6 +87,9 @@ void PluralFormatTest::pluralFormatBasicTest(/*char *par*/)
}
// ======= Test clone, assignment operator && == operator.
plFmt[0]= new PluralFormat(status[0]);
plFmt[0]->setNumberFormat(numFmt,status[0]);
UnicodeString us = UnicodeString("");
plFmt[0]->toPattern(us);
plFmt[1]= new PluralFormat(locale, status[1]);
if ( U_SUCCESS(status[0]) && U_SUCCESS(status[1]) ) {
*plFmt[1] = *plFmt[0];
@ -107,13 +110,25 @@ void PluralFormatTest::pluralFormatBasicTest(/*char *par*/)
errln("ERROR: assignment operator test failed!");
}
}
delete plFmt[1];
}
else {
dataerrln("ERROR: PluralFormat constructor failed! - %s", u_errorName(status[1]));
}
plFmt[3] = (PluralFormat*) plFmt[1]->clone();
if ( U_SUCCESS(status[1]) ) {
if (plFmt[1]!=NULL) {
if ( *plFmt[1] != *plFmt[3] ) {
errln("ERROR: clone function test failed!");
}
}
delete plFmt[1];
}
else {
dataerrln("ERROR: PluralFormat clone failed! - %s", u_errorName(status[1]));
}
delete plFmt[0];
delete plFmt[2];
delete plFmt[3];
delete numFmt;
delete plRules;
}

View file

@ -1226,6 +1226,8 @@ void SSearchTest::boyerMooreTest()
UErrorCode status = U_ZERO_ERROR;
UCollator *coll = NULL;
CollData *data = NULL;
const CEList* ce = NULL;
const CEList* ce1 = NULL;
UnicodeString lp = "fuss";
UnicodeString sp = "fu\\u00DF";
BoyerMooreSearch *longPattern = NULL;
@ -1247,6 +1249,17 @@ void SSearchTest::boyerMooreTest()
goto close_data;
}
data->getDynamicClassID();
if (U_FAILURE(status)) {
errln("Could not get dynamic class ID of CollData.");
goto close_patterns;
}
data->getStaticClassID();
if (U_FAILURE(status)) {
errln("Could not get static class ID of CollData.");
goto close_patterns;
}
longPattern = new BoyerMooreSearch(data, lp.unescape(), NULL, status);
shortPattern = new BoyerMooreSearch(data, sp.unescape(), NULL, status);
@ -1255,6 +1268,72 @@ void SSearchTest::boyerMooreTest()
goto close_patterns;
}
longPattern->getBadCharacterTable();
shortPattern->getBadCharacterTable();
if (U_FAILURE(status)) {
errln("Could not get bad character table.");
goto close_patterns;
}
longPattern->getGoodSuffixTable();
shortPattern->getGoodSuffixTable();
if (U_FAILURE(status)) {
errln("Could not get good suffix table.");
goto close_patterns;
}
longPattern->getDynamicClassID();
shortPattern->getDynamicClassID();
if (U_FAILURE(status)) {
errln("Could not get dynamic class ID of BoyerMooreSearch.");
goto close_patterns;
}
longPattern->getStaticClassID();
shortPattern->getStaticClassID();
if (U_FAILURE(status)) {
errln("Could not get static class ID of BoyerMooreSearch.");
goto close_patterns;
}
longPattern->getData();
shortPattern->getData();
if (U_FAILURE(status)) {
errln("Could not get collate data.");
goto close_patterns;
}
ce = longPattern->getPatternCEs();
ce1 = shortPattern->getPatternCEs();
if (U_FAILURE(status)) {
errln("Could not get pattern CEs.");
goto close_patterns;
}
ce->getDynamicClassID();
ce1->getDynamicClassID();
if (U_FAILURE(status)) {
errln("Could not get dynamic class ID of CEList.");
goto close_patterns;
}
ce->getStaticClassID();
ce1->getStaticClassID();
if (U_FAILURE(status)) {
errln("Could not get static class ID of CEList.");
goto close_patterns;
}
if(data->minLengthInChars(ce,0) != 3){
errln("Minimal Length in Characters for 'data' with 'ce' was suppose to give 3.");
goto close_patterns;
}
if(data->minLengthInChars(ce1,0) != 3){
errln("Minimal Length in Characters for 'data' with 'ce1' was suppose to give 3.");
goto close_patterns;
}
for (uint32_t t = 0; t < (sizeof(targets)/sizeof(targets[0])); t += 1) {
UnicodeString target = targets[t].unescape();
@ -1271,6 +1350,14 @@ void SSearchTest::boyerMooreTest()
} else {
errln("Test %d: did not find short pattern.", t);
}
if(longPattern->empty()){
errln("Test %d: Long pattern should not have been empty.");
}
if(shortPattern->empty()){
errln("Test %d: Short pattern should not have been empty.");
}
}
close_patterns: