ICU-432 various memory leaks

X-SVN-Rev: 1709
This commit is contained in:
Vladimir Weinstein 2000-06-29 19:42:17 +00:00
parent a99c615bff
commit cc42314029
25 changed files with 138 additions and 25 deletions

View file

@ -35,9 +35,8 @@ CollationDummyTest::CollationDummyTest()
: myCollation(0)
{
UErrorCode status = U_ZERO_ERROR;
UnicodeString rules(DEFAULTRULEARRAY);
UnicodeString rules(TRUE, DEFAULTRULEARRAY, sizeof(DEFAULTRULEARRAY)/sizeof(DEFAULTRULEARRAY[0]));
UnicodeString newRules("& C < ch, cH, Ch, CH & Five, 5 & Four, 4 & one, 1 & Ampersand; '&' & Two, 2 ");
rules += newRules;
myCollation = new RuleBasedCollator(rules, status);
}

View file

@ -159,6 +159,8 @@ CalendarRegressionTest::test4028518()
failure(status, "cal1->add");
printdate(cal1, "cal1 after adding 1 day:") ;
printdate(cal2, "cal2 should be unmodified:") ;
delete cal1;
delete cal2;
}
void
@ -266,6 +268,7 @@ CalendarRegressionTest::test4031502()
errln(UnicodeString("Fail: Calendar::add misbehaves"));
delete calendar;
delete ids;
}
/**
@ -548,6 +551,7 @@ CalendarRegressionTest::test4031502()
delete saveZone;
delete newZone;
delete cal;
}
/**
@ -587,6 +591,9 @@ CalendarRegressionTest::test4031502()
logln("*** THE RESULTS OF THIS TEST MUST BE VERIFIED MANUALLY ***");
delete newZone;
delete cal;
delete date;
delete saveZone;
}
/**
@ -1183,6 +1190,7 @@ CalendarRegressionTest::test4031502()
errln("Calendar not proleptic");
delete cal;
delete fmt;
}
/**
@ -1401,8 +1409,10 @@ void
CalendarRegressionTest::Test4162587()
{
UErrorCode status = U_ZERO_ERROR;
TimeZone *savedef = TimeZone::createDefault();
TimeZone *tz = TimeZone::createTimeZone("PST");
TimeZone::adoptDefault(tz);
//TimeZone::adoptDefault(tz);
TimeZone::setDefault(*tz);
GregorianCalendar *cal = new GregorianCalendar(tz, status);
if(U_FAILURE(status)) {
@ -1442,6 +1452,10 @@ CalendarRegressionTest::Test4162587()
errln("Fail: All three lines must match");
}
}
TimeZone::setDefault(*savedef);
//delete tz;
delete cal;
delete savedef;
}
/**

View file

@ -1192,6 +1192,9 @@ CalendarTest::TestDOW_LOCALandYEAR_WOY()
loop_addroll(cal, sdf, times, Calendar::DOW_LOCAL, Calendar::DAY_OF_WEEK, status);
if (U_FAILURE(status)) { errln("Error in parse/calculate test for 1582"); return; }
delete sdf;
delete cal;
return;
}

View file

@ -78,7 +78,6 @@ void CharIterTest::TestConstructionAndEquality() {
if (*test1 != *test3 || *test1 == *test5)
errln("operator= failed");
delete test1;
delete test2;
delete test3;
delete test4;
@ -110,6 +109,7 @@ void CharIterTest::TestConstructionAndEquality() {
delete testChar1;
delete testChar2;
delete testChar3;
delete test1;
}
void CharIterTest::TestConstructionAndEqualityUChariter() {

View file

@ -525,12 +525,12 @@ void ConvertTest::TestConvert()
fclose(ucs_file_in);
delete myConverter;
#ifndef WIN32
//#ifndef WIN32
delete uniString;
delete uniString2;
delete uniString3;
delete testUnistr;
#endif
//#endif
}
}

View file

@ -121,6 +121,7 @@ void CollationCurrencyTest::currencyTest(char *par)
}
}
delete c;
}
void CollationCurrencyTest::runIndexedTest(int32_t index, UBool exec, char* &name, char* par)

View file

@ -384,6 +384,7 @@ void DateFormatRegressionTest::Test4061287(void)
//} catch (ParseException e) {ok=TRUE;}
if(!ok)
errln("Fail: Lenient not working");
delete df;
}
/**
@ -445,7 +446,11 @@ void DateFormatRegressionTest::Test4065240(void)
TimeZone::setDefault(*saveZone);
//}
delete shortdate;
delete fulldate;
delete saveZone;
delete curLocale;
delete bundle;
}
/*
@ -536,6 +541,7 @@ void DateFormatRegressionTest::Test4073003(void)
errln("Fail: " + e);
e.printStackTrace();
}*/
delete fmt;
}
/**
@ -802,6 +808,8 @@ void DateFormatRegressionTest::Test4104522(void)
dt = sdf->parse(text, pp);
logln(" text: \"" + text + "\"" +
" date: " + dt);
delete sdf;
}
/**
@ -970,6 +978,7 @@ void DateFormatRegressionTest::Test4151706(void)
/*} catch (Exception e) {
errln("Fail: " + e);
}*/
delete fmt;
}
/**

View file

@ -276,6 +276,8 @@ void DateFormatRoundTripTest::test(DateFormat *fmt, UBool timeOnly)
(j > 0 && s[j] == s[j-1]?" s==":""));
}
}
delete d;
delete[] s;
}
/*}
catch (ParseException e) {

View file

@ -813,7 +813,7 @@ DateFormatTest::TestDateFormatZone146()
// java.util.Locale.setDefault(new java.util.Locale("ar", "", ""));
// check to be sure... its GMT all right
TimeZone *testdefault = TimeZone::createDefault();
TimeZone *testdefault = TimeZone::createDefault();
UnicodeString testtimezone;
testdefault->getID(testtimezone);
if (testtimezone == "GMT")
@ -856,11 +856,15 @@ TimeZone *testdefault = TimeZone::createDefault();
logln(DATA[i] + result);
if (result != DATA[i+1])
errln("FAIL: Expected " + DATA[i+1] + ", got " + result);
delete fmt;
}
//}
//finally {
TimeZone::adoptDefault(saveDefault);
//}
delete testdefault;
delete greenwichcalendar;
delete thedefault;
}

View file

@ -303,6 +303,7 @@ void HangToJamoTransliteratorTest::expectTranslit(const HangulJamoTransliterator
uprv_memcpy(&index, &_index, sizeof(index));
equal.handleTransliterate(rsource2, index, TRUE);
expectAux(t.getID() + "=OPERATOR:handleTransliterator(increment=TRUE) "+ message, source + "-->" + rsource2, rsource2==expectedResult, expectedResult);
delete clone;
}
void HangToJamoTransliteratorTest::expect(const HangulJamoTransliterator& t,

View file

@ -34,7 +34,8 @@ static int32_t getInt(UnicodeString str)
alias++;
}
*alias='\0';
return atoi(buffer);
int32_t result = atoi(buffer);
return result;
}
//---------------------------------------------

View file

@ -440,6 +440,8 @@ void CollationIteratorTest::verifyExpansion(UnicodeString rules, ExpansionRecord
errln(msg1 + expect + msg2 + expansion);
}
}
delete iter;
delete coll;
}
/**

View file

@ -48,7 +48,7 @@ DateFormatMiscTests::failure(UErrorCode status, const char* msg)
}
/*
* @test @(#)$RCSfile: miscdtfm.cpp,v $ $Revision: 1.9 $ $Date: 2000/05/18 22:08:31 $
* @test @(#)$RCSfile: miscdtfm.cpp,v $ $Revision: 1.10 $ $Date: 2000/06/29 19:42:17 $
*
* @bug 4097450
*/
@ -140,7 +140,7 @@ DateFormatMiscTests::test4097450()
}
/*
* @test @(#)$RCSfile: miscdtfm.cpp,v $ $Revision: 1.9 $ $Date: 2000/05/18 22:08:31 $
* @test @(#)$RCSfile: miscdtfm.cpp,v $ $Revision: 1.10 $ $Date: 2000/06/29 19:42:17 $
*
* @bug 4099975
*/
@ -239,5 +239,6 @@ DateFormatMiscTests::test4117335()
errln("*** Should have been " + jstShort);
//throw new Exception("Error in short TZ name");
}
delete symbols;
}

View file

@ -249,6 +249,7 @@ void MessageFormatRegressionTest::Test4031438()
/*} catch (Exception foo) {
errln("Exception when formatting in bug 4031438. "+foo.getMessage());
}*/
delete messageFormatter;
}
void MessageFormatRegressionTest::Test4052223()
@ -439,6 +440,7 @@ void MessageFormatRegressionTest::Test4114743()
if (!originalPattern.equals(mf.toPattern()))
errln("pattern after: \"" + mf.toPattern() + "\"");
}*/
delete mf;
}
/* @bug 4116444
@ -479,6 +481,7 @@ void MessageFormatRegressionTest::Test4116444()
log(",");
}
log("}") ;
delete[] array;
} else {
log("null");
}
@ -695,11 +698,11 @@ void MessageFormatRegressionTest::Test4118592()
logln((UnicodeString)" " + objs[0].getString(temp));
else
logln((UnicodeString)" " + (objs[0].getType() == Formattable::kLong ? objs[0].getLong() : objs[0].getDouble()));
delete[] objs;
}
}
delete [] objs;
delete mf;
}
/* @bug 4118594
@ -814,8 +817,10 @@ void MessageFormatRegressionTest::Test4120552()
errln(UnicodeString("Incorrect error index: ") + pp.getErrorIndex());
} else {
logln(" (correctly formatted string)");
delete[] objs;
}
}
delete mf;
}
/**
@ -937,5 +942,6 @@ void MessageFormatRegressionTest::Test4112104()
catch (NullPointerException e) {
errln("MessageFormat.equals(null) throws " + e);
}*/
delete format;
}

View file

@ -208,6 +208,7 @@ void NumberFormatRegressionTest::Test4087245 (void)
errln("Test for bug 4087245 failed");
delete df;
delete symbols;
}
/* @bug 4087535
@ -253,6 +254,7 @@ void NumberFormatRegressionTest::Test4088503 (void)
/*} catch (Exception foo) {
errln("Test for bug 4088503 failed.");
}*/
delete df;
}
/* @bug 4066646
@ -586,6 +588,7 @@ void NumberFormatRegressionTest::Test4095713 (void)
logln(UnicodeString("") + d1);
if (d2.getDouble() != d1)
errln(UnicodeString("Bug 4095713 test failed, new double value : ") + d2.getDouble());
delete df;
}
/* @bug 4092561
@ -1087,6 +1090,7 @@ void NumberFormatRegressionTest::Test4101481(void)
failure(status, "new DecimalFormat");
if (sdf->getMinimumIntegerDigits() != 1)
errln("Minimum integer digits : " + sdf->getMinimumIntegerDigits());
delete sdf;
}
/* @bug 4052223 (API addition request A27)
* Tests ParsePosition.setErrorPosition() and ParsePosition.getErrorPosition().
@ -1586,6 +1590,7 @@ void NumberFormatRegressionTest::Test4140009(void)
s = f->format(-123.456, s, pos);
if (s != UnicodeString("-123.456"))
errln("Fail: Format empty pattern x -123.456 => " + s);
delete f;
}
/**
@ -1889,6 +1894,7 @@ void NumberFormatRegressionTest::Test4170798(void) {
|| n.getLong() != 0) {
errln(UnicodeString("FAIL: parse(\"-0.0\") returns ") + toString(n));
}
delete nf;
}
/**

View file

@ -73,8 +73,10 @@ void RBBIAPITest::TestCloneEquals()
bi2clone->getText() != bi2->getText() ||
*bi2clone == *bi1clone )
errln((UnicodeString)"ERROR: RBBI's clone() method failed");
delete bi1;
delete bi1clone;
delete bi2clone;
delete bi1;
delete bi3;
delete bi2;
delete biequal;
@ -87,6 +89,8 @@ void RBBIAPITest::TestgetRules()
RuleBasedBreakIterator* bi2=(RuleBasedBreakIterator*)RuleBasedBreakIterator::createWordInstance(Locale::getDefault(), status);
if(U_FAILURE(status)){
errln((UnicodeString)"FAIL: in construction");
delete bi1;
delete bi2;
return;
}
@ -108,7 +112,7 @@ void RBBIAPITest::TestgetRules()
delete bi1;
delete bi2;
delete bi3;
}
void RBBIAPITest::TestHashCode()
{
@ -118,6 +122,9 @@ void RBBIAPITest::TestHashCode()
RuleBasedBreakIterator* bi2 = (RuleBasedBreakIterator*)RuleBasedBreakIterator::createWordInstance(Locale::getDefault(), status);
if(U_FAILURE(status)){
errln((UnicodeString)"FAIL : in construction");
delete bi1;
delete bi2;
delete bi3;
return;
}
@ -138,7 +145,9 @@ void RBBIAPITest::TestHashCode()
if(bi1->hashCode() == bi2->hashCode() || bi2->hashCode() == bi3->hashCode() ||
bi1clone->hashCode() == bi2clone->hashCode() || bi1clone->hashCode() == bi2->hashCode())
errln((UnicodeString)"ERROR: different objects have same hasecodes");
delete bi1clone;
delete bi2clone;
delete bi1;
delete bi2;
delete bi3;
@ -159,6 +168,7 @@ void RBBIAPITest::TestGetSetAdoptText()
CharacterIterator* text1= new StringCharacterIterator(str1);
CharacterIterator* text1Clone = text1->clone();
CharacterIterator* text2= new StringCharacterIterator(str2);
wordIter1->setText(str1);
@ -174,7 +184,7 @@ void RBBIAPITest::TestGetSetAdoptText()
errln((UnicodeString)"ERROR:2 setText did not reset the iteration position to the beginning of the text, it is" + wordIter1->current() + (UnicodeString)"\n");
charIter1->adoptText(text1);
charIter1->adoptText(text1Clone);
if( wordIter1->getText() == charIter1->getText() ||
wordIter1->getText() != *text2 || charIter1->getText() != *text1 )
errln((UnicodeString)"ERROR:2 error is getText or setText()");
@ -188,8 +198,9 @@ void RBBIAPITest::TestGetSetAdoptText()
errln((UnicodeString)"ERROR:2 error in adoptText ");
delete wordIter1;
delete wordIter1;
delete charIter1;
delete rb;
}
void RBBIAPITest::TestFirstNextFollowing()

View file

@ -336,7 +336,7 @@ void RBBITest::TestDefaultRuleBasedSentenceIteration()
sentdata->addElement("Testing the sentence iterator. ");
sentdata->addElement("\"This isn\'t it.\" ");
sentdata->addElement("Hi! ");
sentdata = new Vector();
//sentdata = new Vector();
sentdata->addElement("This is a simple sample sentence. ");
sentdata->addElement("(This is it.) ");
sentdata->addElement("This is a simple sample sentence. ");
@ -1006,6 +1006,10 @@ void RBBITest::generalIteratorTest(RuleBasedBreakIterator& bi, Vector* expectedR
testIsBoundary(bi, text, boundaries);
doMultipleSelectionTest(bi, text);
delete[] boundaries;
delete nextResults;
delete previousResults;
}
Vector* RBBITest::testFirstAndNext(RuleBasedBreakIterator& bi, UnicodeString& text)
@ -1217,7 +1221,7 @@ void RBBITest::doMultipleSelectionTest(RuleBasedBreakIterator& iterator,
}
} while (offset != RuleBasedBreakIterator::DONE);
//delete testIterator;
delete testIterator;
}

View file

@ -292,6 +292,9 @@ ResourceBundleTest::TestConstruction()
if (strcmp(version1, versionID1) != 0 || strcmp(version2, versionID2) != 0)
errln("getVersionNumber() failed");
delete[] versionID1;
delete[] versionID2;
}
{
UErrorCode err = U_ZERO_ERROR;
@ -323,6 +326,8 @@ ResourceBundleTest::TestConstruction()
if (result2 != "TE_IN")
errln("Construction test failed; run verbose for more information");
delete[] wideDirectory;
}
}

View file

@ -290,6 +290,8 @@ NewResourceBundleTest::TestConstruction()
if (strcmp(version1, versionID1) != 0 || strcmp(version2, versionID2) != 0)
errln("getVersionNumber() failed");
delete[] versionID1;
delete[] versionID2;
}
{
UErrorCode err = U_ZERO_ERROR;
@ -319,6 +321,8 @@ NewResourceBundleTest::TestConstruction()
if (result2 != "TE_IN")
errln("Construction test failed; run verbose for more information");
delete[] wideDirectory;
}
}
void
@ -428,6 +432,7 @@ NewResourceBundleTest::TestIteration()
}
delete locale;
}

View file

@ -10,7 +10,7 @@
#include "intltest.h"
#include "tchcfmt.h"
#include "cmemory.h"
#include "unicode/msgfmt.h"
#include "unicode/choicfmt.h"
@ -56,8 +56,8 @@ TestChoiceFormat::TestSimpleExample( void )
//Testing ==operator
const double filelimits[] = {0,1,2};
const UnicodeString filepart[] = {"are no files","is one file","are {2} files"};
ChoiceFormat* formnew=new ChoiceFormat(filelimits, filepart, 3);
ChoiceFormat* formequal=new ChoiceFormat(limits, monthNames, 7);
ChoiceFormat* formnew=new ChoiceFormat(filelimits, filepart, 3);
ChoiceFormat* formequal=new ChoiceFormat(limits, monthNames, 7);
if(*formnew == *form){
errln("ERROR: ==operator failed\n");
}
@ -67,10 +67,18 @@ TestChoiceFormat::TestSimpleExample( void )
delete formequal;
//Testing adoptChoices()
formnew->adoptChoices(limits, monthNames, 7);
double *limitsToAdopt = new double[7];
UnicodeString *monthNamesToAdopt = new UnicodeString[7];
uprv_arrayCopy(monthNames, monthNamesToAdopt, 7);
uprv_memcpy(limitsToAdopt, limits, (size_t)(7 * sizeof(limits[0])));
formnew->adoptChoices(limitsToAdopt, monthNamesToAdopt, 7);
if(!(*formnew == *form)){
errln("ERROR: ==Operator or adoptChoices failed\n");
}
delete formnew;
//Testing getLimits()
double *gotLimits=0;
@ -171,7 +179,15 @@ TestChoiceFormat::TestComplexExample( void )
"There are 3 files on Disk_A"
};
if (status != U_ZERO_ERROR) return;
// if (status != U_ZERO_ERROR) return; // TODO: analyze why we have such a bad bail out here!
if (U_FAILURE(status)) {
delete fileform;
delete filenumform;
delete pattform;
return;
}
int32_t i;
for (i = 0; i < 4; ++i) {

View file

@ -1033,6 +1033,10 @@ static void testCopyConstructor2()
result = fmt2->format( &fargs, 1, resultStr, fp, status );
result = fmt3->format( &fargs, 1, resultStr, fp, status );
result = fmt4->format( &fargs, 1, resultStr, fp, status );
delete fmt1;
delete fmt2;
delete fmt3;
delete fmt4;
}

View file

@ -110,6 +110,8 @@ void TransliteratorAPITest::TestgetID() {
delete t1;
delete t2;
delete t3;
delete t4;
delete t5;

View file

@ -335,6 +335,10 @@ void MultithreadTest::TestThreads()
if(count == THREADTEST_NRTHREADS)
{
logln("->" + UnicodeString(threadTestChars) + "<- Got all threads! cya");
for(i=0;i<THREADTEST_NRTHREADS;i++)
{
delete threads[i];
}
return;
}
@ -343,6 +347,10 @@ void MultithreadTest::TestThreads()
}
errln("->" + UnicodeString(threadTestChars) + "<- PATIENCE EXCEEDED!! Still missing some.");
for(i=0;i<THREADTEST_NRTHREADS;i++)
{
delete threads[i];
}
}

View file

@ -158,6 +158,8 @@ void BasicNormalizerTest::TestPrevious()
for (i = 0; i < ARRAY_LENGTH(canonTests); i++) {
backAndForth(norm, canonTests[i][0]);
}
delete norm;
}
void BasicNormalizerTest::TestDecomp()
@ -166,6 +168,7 @@ void BasicNormalizerTest::TestDecomp()
iterateTest(norm, canonTests, ARRAY_LENGTH(canonTests), 1);
staticTest(Normalizer::DECOMP, 0, canonTests, ARRAY_LENGTH(canonTests), 1);
delete norm;
}
void BasicNormalizerTest::TestCompatDecomp()
@ -175,6 +178,7 @@ void BasicNormalizerTest::TestCompatDecomp()
staticTest(Normalizer::DECOMP_COMPAT, 0,
compatTests, ARRAY_LENGTH(compatTests), 1);
delete norm;
}
void BasicNormalizerTest::TestCanonCompose()
@ -184,6 +188,7 @@ void BasicNormalizerTest::TestCanonCompose()
staticTest(Normalizer::COMPOSE, 0, canonTests,
ARRAY_LENGTH(canonTests), 2);
delete norm;
}
void BasicNormalizerTest::TestCompatCompose()
@ -193,6 +198,7 @@ void BasicNormalizerTest::TestCompatCompose()
staticTest(Normalizer::COMPOSE_COMPAT, 0,
compatTests, ARRAY_LENGTH(compatTests), 2);
delete norm;
}
@ -223,6 +229,7 @@ void BasicNormalizerTest::TestHangulCompose()
for (int i = 0; i < ARRAY_LENGTH(hangulCanon); i++) {
backAndForth(norm, hangulCanon[i][0]);
}
delete norm;
}
void BasicNormalizerTest::TestHangulDecomp()
@ -246,6 +253,7 @@ void BasicNormalizerTest::TestHangulDecomp()
for (int i = 0; i < ARRAY_LENGTH(hangulCanon); i++) {
backAndForth(norm, hangulCanon[i][0]);
}
delete norm;
}

View file

@ -645,6 +645,7 @@ void TimeZoneRegressionTest:: Test4154542()
}
delete temp;
}
delete zone;
}