mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-1076 clear toPattern result buffer
X-SVN-Rev: 7306
This commit is contained in:
parent
37279d71cc
commit
426dadc5a8
6 changed files with 64 additions and 25 deletions
|
@ -77,6 +77,7 @@ UMatchDegree Quantifier::matches(const Replaceable& text,
|
|||
*/
|
||||
UnicodeString& Quantifier::toPattern(UnicodeString& result,
|
||||
UBool escapeUnprintable) const {
|
||||
result.truncate(0);
|
||||
matcher->toPattern(result, escapeUnprintable);
|
||||
if (minCount == 0) {
|
||||
if (maxCount == 1) {
|
||||
|
|
|
@ -125,6 +125,7 @@ UMatchDegree StringMatcher::matches(const Replaceable& text,
|
|||
*/
|
||||
UnicodeString& StringMatcher::toPattern(UnicodeString& result,
|
||||
UBool escapeUnprintable) const {
|
||||
result.truncate(0);
|
||||
UnicodeString str, quoteBuf;
|
||||
if (isSegment) {
|
||||
result.append((UChar)40); /*(*/
|
||||
|
|
|
@ -562,7 +562,7 @@ void RTTest::test(const UnicodeString& sourceRangeVal,
|
|||
char str[100];
|
||||
int32_t length = transliteratorID.extract(str, 100, NULL, status);
|
||||
str[length] = 0;
|
||||
parent->errln("%s errors: %d %s", str, errorCount, (errorCount > errorLimit ? " (at least!)" : " ")); // + ", see " + logFileName);
|
||||
parent->errln("FAIL: %s errors: %d %s", str, errorCount, (errorCount > errorLimit ? " (at least!)" : " ")); // + ", see " + logFileName);
|
||||
} else {
|
||||
char str[100];
|
||||
int32_t length = transliteratorID.extract(str, 100, NULL, status);
|
||||
|
@ -592,7 +592,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
Transliterator::createInstance(transliteratorID, UTRANS_FORWARD, parseError,
|
||||
status);
|
||||
if (sourceToTarget == NULL) {
|
||||
parent->errln("Fail: createInstance(" + transliteratorID +
|
||||
parent->errln("FAIL: createInstance(" + transliteratorID +
|
||||
") returned NULL. Error: " + u_errorName(status)
|
||||
+ "\n\tpreContext : " + prettify(parseError.preContext)
|
||||
+ "\n\tpostContext : " + prettify(parseError.postContext));
|
||||
|
@ -601,7 +601,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
}
|
||||
Transliterator* targetToSource = sourceToTarget->createInverse(status);
|
||||
if (targetToSource == NULL) {
|
||||
parent->errln("Fail: " + transliteratorID +
|
||||
parent->errln("FAIL: " + transliteratorID +
|
||||
".createInverse() returned NULL. Error:" + u_errorName(status)
|
||||
+ "\n\tpreContext : " + prettify(parseError.preContext)
|
||||
+ "\n\tpostContext : " + prettify(parseError.postContext));
|
||||
|
@ -612,7 +612,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeSetIterator usi;
|
||||
UnicodeSetIterator usi2;
|
||||
|
||||
parent->logln("Checking that at least one irrevant characters is not NFC'ed");
|
||||
parent->logln("Checking that at least one irrelevant character is not NFC'ed");
|
||||
// string is from NFC_NO in the UCD
|
||||
UnicodeString irrelevants = CharsToUnicodeString("\\u2000\\u2001\\u2126\\u212A\\u212B\\u2329");
|
||||
|
||||
|
@ -628,13 +628,14 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString rules = "";
|
||||
|
||||
UParseError parseError;
|
||||
rules = sourceToTarget->toRules(rules, FALSE);
|
||||
rules = sourceToTarget->toRules(rules, TRUE);
|
||||
// parent->logln((UnicodeString)"toRules => " + rules);
|
||||
Transliterator *sourceToTarget2 = Transliterator::createFromRules(
|
||||
"s2t2", rules,
|
||||
UTRANS_FORWARD,
|
||||
parseError, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed opening from rules %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: createFromRules %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -644,7 +645,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UTRANS_FORWARD,
|
||||
parseError, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed opening from rules %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: createFromRules %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -697,7 +698,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString targD;
|
||||
Normalizer::decompose(targ, FALSE, 0, targD, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
if (UnicodeSetIterator::containsAll(toTarget, targD) == FALSE ||
|
||||
|
@ -712,7 +713,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString cs2;
|
||||
Normalizer::decompose(cs, FALSE, 0, cs2, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
UnicodeString targ2 = cs2;
|
||||
|
@ -749,7 +750,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString targD;
|
||||
Normalizer::decompose(targ, FALSE, 0, targD, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
if (UnicodeSetIterator::containsAll(toTarget,targD) == FALSE ||
|
||||
|
@ -762,7 +763,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString cs2;
|
||||
Normalizer::decompose(cs, FALSE, 0, cs2, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposition %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
UnicodeString targ2 = cs2;
|
||||
|
@ -796,7 +797,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString targD;
|
||||
Normalizer::decompose(targ, FALSE, 0, targD, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition%s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
if (UnicodeSetIterator::containsAll(toSource, targD) == FALSE ||
|
||||
|
@ -817,7 +818,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString targ2;
|
||||
Normalizer::decompose(targ, FALSE, 0, targ2, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition%s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
UnicodeString reverse2 = targ2;
|
||||
|
@ -868,7 +869,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString targD;
|
||||
Normalizer::decompose(targ, FALSE, 0, targD, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n",
|
||||
parent->errln("FAIL: Internal error during decomposition%s\n",
|
||||
u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
@ -889,7 +890,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
UnicodeString targ2;
|
||||
Normalizer::decompose(targ, FALSE, 0, targ2, status);
|
||||
if (U_FAILURE(status)) {
|
||||
parent->errln("Failed decomposation %s\n", u_errorName(status));
|
||||
parent->errln("FAIL: Internal error during decomposition%s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
UnicodeString reverse2 = targ2;
|
||||
|
@ -907,7 +908,7 @@ void RTTest::test2(UBool quickRt) {
|
|||
void RTTest::logWrongScript(const UnicodeString& label,
|
||||
const UnicodeString& from,
|
||||
const UnicodeString& to) {
|
||||
parent->errln((UnicodeString)"Fail " +
|
||||
parent->errln((UnicodeString)"FAIL " +
|
||||
label + ": " +
|
||||
from + "(" + TestUtility::hex(from) + ") => " +
|
||||
to + "(" + TestUtility::hex(to) + ")");
|
||||
|
@ -919,7 +920,7 @@ void RTTest::logNotCanonical(const UnicodeString& label,
|
|||
const UnicodeString& to,
|
||||
const UnicodeString& fromCan,
|
||||
const UnicodeString& toCan) {
|
||||
parent->errln((UnicodeString)"Fail (can.equiv)" +
|
||||
parent->errln((UnicodeString)"FAIL (can.equiv)" +
|
||||
label + ": " +
|
||||
from + "(" + TestUtility::hex(from) + ") => " +
|
||||
to + "(" + TestUtility::hex(to) + ")" +
|
||||
|
@ -931,7 +932,7 @@ void RTTest::logNotCanonical(const UnicodeString& label,
|
|||
}
|
||||
|
||||
void RTTest::logFails(const UnicodeString& label) {
|
||||
parent->errln((UnicodeString)"<br>Fail " + label);
|
||||
parent->errln((UnicodeString)"<br>FAIL " + label);
|
||||
++errorCount;
|
||||
}
|
||||
|
||||
|
@ -940,7 +941,7 @@ void RTTest::logToRulesFails(const UnicodeString& label,
|
|||
const UnicodeString& to,
|
||||
const UnicodeString& otherTo)
|
||||
{
|
||||
parent->errln((UnicodeString)"Fail" +
|
||||
parent->errln((UnicodeString)"FAIL: " +
|
||||
label + ": " +
|
||||
from + "(" + TestUtility::hex(from) + ") => " +
|
||||
to + "(" + TestUtility::hex(to) + ")" +
|
||||
|
@ -959,7 +960,7 @@ void RTTest::logRoundTripFailure(const UnicodeString& from,
|
|||
const UnicodeString& back) {
|
||||
if (legalSource->is(from) == FALSE) return; // skip illegals
|
||||
|
||||
parent->errln((UnicodeString)"Fail Roundtrip: " +
|
||||
parent->errln((UnicodeString)"FAIL Roundtrip: " +
|
||||
from + "(" + TestUtility::hex(from) + ") => " +
|
||||
to + "(" + TestUtility::hex(to) + ") "+toID+" => " +
|
||||
back + "(" + TestUtility::hex(back) + ") "+backID+" => ");
|
||||
|
@ -1140,7 +1141,7 @@ void TransliteratorRoundTripTest::TestDevanagariLatin() {
|
|||
if(t1){
|
||||
t1->createInverse(status);
|
||||
if(U_FAILURE(status)){
|
||||
errln("could not create the Inverse:-( \n");
|
||||
errln("FAIL: could not create the Inverse:-( \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1536,6 +1536,18 @@ void TransliteratorTest::TestToRules(void) {
|
|||
RBT,
|
||||
"$a=[:Zs:]; $b=[x$a]; $b{a} > A;",
|
||||
"[x[:Zs:]]{a} > A;",
|
||||
|
||||
RBT,
|
||||
"$accentMinus = [ [\\u0300-\\u0345] & [:M:] - [\\u0338]] ;"
|
||||
"$macron = \\u0304 ;"
|
||||
"$evowel = [aeiouyAEIOUY] ;"
|
||||
"$iotasub = \\u0345 ;"
|
||||
"($evowel $macron $accentMinus *) i > | $1 $iotasub ;",
|
||||
"([AEIOUYaeiouy]\\u0304[[\\u0300-\\u0345]&[:M:]-[\\u0338]]*)i > | $1 \\u0345;",
|
||||
|
||||
RBT,
|
||||
"([AEIOUYaeiouy]\\u0304[[:M:]-[\\u0304\\u0345]]*)i > | $1 \\u0345;",
|
||||
"([AEIOUYaeiouy]\\u0304[[:M:]-[\\u0304\\u0345]]*)i > | $1 \\u0345;",
|
||||
};
|
||||
static const int32_t DATA_length = (int32_t)(sizeof(DATA) / sizeof(DATA[0]));
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java,v $
|
||||
* $Date: 2001/12/03 23:08:50 $
|
||||
* $Revision: 1.92 $
|
||||
* $Date: 2001/12/04 05:25:39 $
|
||||
* $Revision: 1.93 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -1125,6 +1125,18 @@ public class TransliteratorTest extends TestFmwk {
|
|||
RBT,
|
||||
"$a=[:Zs:]; $b=[x$a]; $b{a} > A;",
|
||||
"[x[:Zs:]]{a} > A;",
|
||||
|
||||
RBT,
|
||||
"$accentMinus = [ [\\u0300-\\u0345] & [:M:] - [\\u0338]] ;"+
|
||||
"$macron = \\u0304 ;"+
|
||||
"$evowel = [aeiouyAEIOUY] ;"+
|
||||
"$iotasub = \\u0345 ;"+
|
||||
"($evowel $macron $accentMinus *) i > | $1 $iotasub ;",
|
||||
"([AEIOUYaeiouy]\\u0304[[\\u0300-\\u0345]&[:M:]-[\\u0338]]*)i > | $1 \\u0345;",
|
||||
|
||||
RBT,
|
||||
"([AEIOUYaeiouy]\\u0304[[:M:]-[\\u0304\\u0345]]*)i > | $1 \\u0345;",
|
||||
"([AEIOUYaeiouy]\\u0304[[:M:]-[\\u0304\\u0345]]*)i > | $1 \\u0345;",
|
||||
};
|
||||
|
||||
for (int d=0; d < DATA.length; d+=3) {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/test/translit/Attic/TransliteratorTest.java,v $
|
||||
* $Date: 2001/12/03 23:08:50 $
|
||||
* $Revision: 1.92 $
|
||||
* $Date: 2001/12/04 05:25:39 $
|
||||
* $Revision: 1.93 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -1125,6 +1125,18 @@ public class TransliteratorTest extends TestFmwk {
|
|||
RBT,
|
||||
"$a=[:Zs:]; $b=[x$a]; $b{a} > A;",
|
||||
"[x[:Zs:]]{a} > A;",
|
||||
|
||||
RBT,
|
||||
"$accentMinus = [ [\\u0300-\\u0345] & [:M:] - [\\u0338]] ;"+
|
||||
"$macron = \\u0304 ;"+
|
||||
"$evowel = [aeiouyAEIOUY] ;"+
|
||||
"$iotasub = \\u0345 ;"+
|
||||
"($evowel $macron $accentMinus *) i > | $1 $iotasub ;",
|
||||
"([AEIOUYaeiouy]\\u0304[[\\u0300-\\u0345]&[:M:]-[\\u0338]]*)i > | $1 \\u0345;",
|
||||
|
||||
RBT,
|
||||
"([AEIOUYaeiouy]\\u0304[[:M:]-[\\u0304\\u0345]]*)i > | $1 \\u0345;",
|
||||
"([AEIOUYaeiouy]\\u0304[[:M:]-[\\u0304\\u0345]]*)i > | $1 \\u0345;",
|
||||
};
|
||||
|
||||
for (int d=0; d < DATA.length; d+=3) {
|
||||
|
|
Loading…
Add table
Reference in a new issue