ICU-11392 data-driven collation test: failed Collator creation skips over its test cases then continues testing
X-SVN-Rev: 37112
This commit is contained in:
parent
0e1cf69814
commit
d03f32e29d
@ -1110,6 +1110,8 @@ static const struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
|
void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
|
||||||
|
// Parse attributes even if the Collator could not be created,
|
||||||
|
// in order to report syntax errors.
|
||||||
int32_t start = skipSpaces(1);
|
int32_t start = skipSpaces(1);
|
||||||
int32_t equalPos = fileLine.indexOf(0x3d);
|
int32_t equalPos = fileLine.indexOf(0x3d);
|
||||||
if(equalPos < 0) {
|
if(equalPos < 0) {
|
||||||
@ -1141,12 +1143,14 @@ void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
|
|||||||
errorCode.set(U_PARSE_ERROR);
|
errorCode.set(U_PARSE_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll->setMaxVariable(max, errorCode);
|
if(coll != NULL) {
|
||||||
if(errorCode.isFailure()) {
|
coll->setMaxVariable(max, errorCode);
|
||||||
errln("setMaxVariable() failed on line %d: %s",
|
if(errorCode.isFailure()) {
|
||||||
(int)fileLineNumber, errorCode.errorName());
|
errln("setMaxVariable() failed on line %d: %s",
|
||||||
infoln(fileLine);
|
(int)fileLineNumber, errorCode.errorName());
|
||||||
return;
|
infoln(fileLine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fileLine.remove();
|
fileLine.remove();
|
||||||
return;
|
return;
|
||||||
@ -1180,12 +1184,14 @@ void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coll->setAttribute(attr, value, errorCode);
|
if(coll != NULL) {
|
||||||
if(errorCode.isFailure()) {
|
coll->setAttribute(attr, value, errorCode);
|
||||||
errln("illegal attribute=value combination on line %d: %s",
|
if(errorCode.isFailure()) {
|
||||||
(int)fileLineNumber, errorCode.errorName());
|
errln("illegal attribute=value combination on line %d: %s",
|
||||||
infoln(fileLine);
|
(int)fileLineNumber, errorCode.errorName());
|
||||||
return;
|
infoln(fileLine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fileLine.remove();
|
fileLine.remove();
|
||||||
}
|
}
|
||||||
@ -1212,11 +1218,14 @@ void CollationTest::parseAndSetReorderCodes(int32_t start, IcuTestErrorCode &err
|
|||||||
reorderCodes.addElement(code, errorCode);
|
reorderCodes.addElement(code, errorCode);
|
||||||
start = limit;
|
start = limit;
|
||||||
}
|
}
|
||||||
coll->setReorderCodes(reorderCodes.getBuffer(), reorderCodes.size(), errorCode);
|
if(coll != NULL) {
|
||||||
if(errorCode.isFailure()) {
|
coll->setReorderCodes(reorderCodes.getBuffer(), reorderCodes.size(), errorCode);
|
||||||
errln("setReorderCodes() failed on line %d: %s", (int)fileLineNumber, errorCode.errorName());
|
if(errorCode.isFailure()) {
|
||||||
infoln(fileLine);
|
errln("setReorderCodes() failed on line %d: %s",
|
||||||
return;
|
(int)fileLineNumber, errorCode.errorName());
|
||||||
|
infoln(fileLine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fileLine.remove();
|
fileLine.remove();
|
||||||
}
|
}
|
||||||
@ -1248,6 +1257,9 @@ void CollationTest::buildTailoring(UCHARBUF *f, IcuTestErrorCode &errorCode) {
|
|||||||
infoln(UnicodeString(" snippet: ...") +
|
infoln(UnicodeString(" snippet: ...") +
|
||||||
parseError.preContext + "(!)" + parseError.postContext + "...");
|
parseError.preContext + "(!)" + parseError.postContext + "...");
|
||||||
}
|
}
|
||||||
|
delete coll;
|
||||||
|
coll = NULL;
|
||||||
|
errorCode.reset();
|
||||||
} else {
|
} else {
|
||||||
assertEquals("no error reason when RuleBasedCollator(rules) succeeds",
|
assertEquals("no error reason when RuleBasedCollator(rules) succeeds",
|
||||||
UnicodeString(), reason);
|
UnicodeString(), reason);
|
||||||
@ -1266,6 +1278,8 @@ void CollationTest::setRootCollator(IcuTestErrorCode &errorCode) {
|
|||||||
|
|
||||||
void CollationTest::setLocaleCollator(IcuTestErrorCode &errorCode) {
|
void CollationTest::setLocaleCollator(IcuTestErrorCode &errorCode) {
|
||||||
if(errorCode.isFailure()) { return; }
|
if(errorCode.isFailure()) { return; }
|
||||||
|
delete coll;
|
||||||
|
coll = NULL;
|
||||||
int32_t at = fileLine.indexOf((UChar)0x40, 9); // @ is not invariant
|
int32_t at = fileLine.indexOf((UChar)0x40, 9); // @ is not invariant
|
||||||
if(at >= 0) {
|
if(at >= 0) {
|
||||||
fileLine.setCharAt(at, (UChar)0x2a); // *
|
fileLine.setCharAt(at, (UChar)0x2a); // *
|
||||||
@ -1284,15 +1298,15 @@ void CollationTest::setLocaleCollator(IcuTestErrorCode &errorCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logln("creating a collator for locale ID %s", locale.getName());
|
logln("creating a collator for locale ID %s", locale.getName());
|
||||||
Collator *newColl = Collator::createInstance(locale, errorCode);
|
coll = Collator::createInstance(locale, errorCode);
|
||||||
if(errorCode.isFailure()) {
|
if(errorCode.isFailure()) {
|
||||||
dataerrln("unable to create a collator for locale %s on line %d",
|
dataerrln("unable to create a collator for locale %s on line %d",
|
||||||
locale.getName(), (int)fileLineNumber);
|
locale.getName(), (int)fileLineNumber);
|
||||||
infoln(fileLine);
|
infoln(fileLine);
|
||||||
return;
|
delete coll;
|
||||||
|
coll = NULL;
|
||||||
|
errorCode.reset();
|
||||||
}
|
}
|
||||||
delete coll;
|
|
||||||
coll = newColl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UBool CollationTest::needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const {
|
UBool CollationTest::needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const {
|
||||||
@ -1750,11 +1764,19 @@ void CollationTest::checkCompareStrings(UCHARBUF *f, IcuTestErrorCode &errorCode
|
|||||||
while(readLine(f, errorCode)) {
|
while(readLine(f, errorCode)) {
|
||||||
if(fileLine.isEmpty()) { continue; }
|
if(fileLine.isEmpty()) { continue; }
|
||||||
if(isSectionStarter(fileLine[0])) { break; }
|
if(isSectionStarter(fileLine[0])) { break; }
|
||||||
|
// Parse the line even if it will be ignored (when we do not have a Collator)
|
||||||
|
// in order to report syntax issues.
|
||||||
Collation::Level relation = parseRelationAndString(s, errorCode);
|
Collation::Level relation = parseRelationAndString(s, errorCode);
|
||||||
if(errorCode.isFailure()) {
|
if(errorCode.isFailure()) {
|
||||||
errorCode.reset();
|
errorCode.reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(coll == NULL) {
|
||||||
|
// We were unable to create the Collator but continue with tests.
|
||||||
|
// Ignore test data for this Collator.
|
||||||
|
// The next Collator creation might work.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
UCollationResult expectedOrder = (relation == Collation::ZERO_LEVEL) ? UCOL_EQUAL : UCOL_LESS;
|
UCollationResult expectedOrder = (relation == Collation::ZERO_LEVEL) ? UCOL_EQUAL : UCOL_LESS;
|
||||||
Collation::Level expectedLevel = relation;
|
Collation::Level expectedLevel = relation;
|
||||||
s.getTerminatedBuffer(); // Ensure NUL-termination.
|
s.getTerminatedBuffer(); // Ensure NUL-termination.
|
||||||
|
Loading…
Reference in New Issue
Block a user