ICU-535 fixed some compiler warnings

X-SVN-Rev: 2344
This commit is contained in:
George Rhoten 2000-08-24 01:12:12 +00:00
parent 1f16762e57
commit 70d0f2d72d
13 changed files with 58 additions and 38 deletions

View file

@ -116,8 +116,8 @@ void CharIterTest::TestConstructionAndEqualityUChariter() {
const char* testTextchars= {"Now is the time for all good men to come to the aid of their country."};
const char* testText2chars={"Don't bother using this string."};
UChar *testText=(UChar*)malloc(sizeof(UChar) * (strlen(testTextchars)+1));
UChar *testText2=(UChar*)malloc(sizeof(UChar) * (strlen(testText2chars)+1));
UChar *testText = new UChar[strlen(testTextchars)+1];
UChar *testText2 = new UChar[strlen(testText2chars)+1];
u_uastrcpy(testText, testTextchars);
u_uastrcpy(testText2, testText2chars);
@ -184,8 +184,8 @@ void CharIterTest::TestConstructionAndEqualityUChariter() {
errln("operator= failed");
free(testText);
free(testText2);
delete testText;
delete testText2;
delete test1;
delete test2;

View file

@ -7,6 +7,8 @@
#ifndef _DATEFORMATROUNDTRIPTEST_
#define _DATEFORMATROUNDTRIPTEST_
#include <stdlib.h>
#include "unicode/utypes.h"
#include "intltest.h"
#include "locale.h"
@ -45,7 +47,7 @@ static uint32_t randLong()
// Assume 8-bit (or larger) rand values. Also assume
// that the system rand() function is very poor, which it always is.
uint32_t d;
int32_t i;
uint32_t i;
char* poke = (char*)&d;
for (i=0; i < sizeof(uint32_t); ++i)
{

View file

@ -85,8 +85,11 @@ void DateFormatTest::TestWallyWedel()
cal->setTime(today, status);
offset = cal->get(Calendar::ZONE_OFFSET, status) + cal->get(Calendar::DST_OFFSET, status);
// logln(i + " " + ids[i] + " offset " + offset);
char* sign = "+";
if (offset < 0) { sign = "-"; offset = -offset; }
const char* sign = "+";
if (offset < 0) {
sign = "-";
offset = -offset;
}
hours = offset/3600000;
minutes = (offset%3600000)/60000;
UnicodeString dstOffset = (UnicodeString)"" + sign + (hours < 10 ? "0" : "") +
@ -679,7 +682,8 @@ DateFormatTest::TestBadInput135a()
SimpleDateFormat* dateParse = new SimpleDateFormat(status);
const char* s;
UDate date;
int32_t PFLENGTH = sizeof(parseFormats)/sizeof(parseFormats[0]);
const uint32_t PFLENGTH = sizeof(parseFormats)/sizeof(parseFormats[0]);
dateParse->applyPattern("d MMMM, yyyy");
dateParse->adoptTimeZone(TimeZone::createDefault());
s = "not parseable";
@ -695,7 +699,7 @@ DateFormatTest::TestBadInput135a()
logln((UnicodeString)"Exception during parse: " + (int32_t)status);
status = U_ZERO_ERROR;
//}
for (int32_t i = 0; i < sizeof(inputStrings)/sizeof(inputStrings[0]); i += (PFLENGTH + 1)) {
for (uint32_t i = 0; i < sizeof(inputStrings)/sizeof(inputStrings[0]); i += (PFLENGTH + 1)) {
ParsePosition parsePosition(0);
UnicodeString s( inputStrings[i]);
for (int32_t index = 0; index < PFLENGTH;++index) {
@ -706,33 +710,39 @@ DateFormatTest::TestBadInput135a()
parsePosition.setIndex(0);
date = dateParse->parse(s, parsePosition);
if (parsePosition.getIndex() != 0) {
UnicodeString s1, s2;
s.extract(0, parsePosition.getIndex(), s1);
s.extract(parsePosition.getIndex(), s.length(), s2);
if (date == 0) errln((UnicodeString)"ERROR: null result fmt=\"" +
parseFormats[index] +
"\" pos=" + parsePosition.getIndex() + " " +
s1 + "|" + s2);
else {
UnicodeString result; ((DateFormat*)dateParse)->format(date, result);
logln((UnicodeString)"Parsed \"" + s + "\" using \"" + dateParse->toPattern(thePat) + "\" to: " + result);
if (expected == 0) errln((UnicodeString)"FAIL: Expected parse failure");
else if (!(result == expected)) errln(UnicodeString("FAIL: Expected ") + expected);
}
UnicodeString s1, s2;
s.extract(0, parsePosition.getIndex(), s1);
s.extract(parsePosition.getIndex(), s.length(), s2);
if (date == 0) {
errln((UnicodeString)"ERROR: null result fmt=\"" +
parseFormats[index] +
"\" pos=" + parsePosition.getIndex() + " " +
s1 + "|" + s2);
}
else {
UnicodeString result;
((DateFormat*)dateParse)->format(date, result);
logln((UnicodeString)"Parsed \"" + s + "\" using \"" + dateParse->toPattern(thePat) + "\" to: " + result);
if (expected == 0)
errln((UnicodeString)"FAIL: Expected parse failure");
else if (!(result == expected))
errln(UnicodeString("FAIL: Expected ") + expected);
}
}
else {
if (expected != 0) errln(UnicodeString("FAIL: Expected ") + expected + " from \"" +
s + "\" with \"" + dateParse->toPattern(thePat) + "\"");
else if (expected != 0) {
errln(UnicodeString("FAIL: Expected ") + expected + " from \"" +
s + "\" with \"" + dateParse->toPattern(thePat) + "\"");
}
//}
//catch(Exception ex) {
if (U_FAILURE(status))
errln((UnicodeString)"An exception was thrown during parse: " + (int32_t)status);
errln((UnicodeString)"An exception was thrown during parse: " + (int32_t)status);
//}
}
}
delete dateParse;
if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
if (U_FAILURE(status))
errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
}
// -------------------------------------

View file

@ -12,7 +12,6 @@
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
@ -451,7 +450,7 @@ IntlTest::pathnameInContext( char* fullname, int32_t maxsize, const char* relPat
const char*
IntlTest::getTestDirectory()
{
if (_testDirectory == NULL)
if (_testDirectory == NULL)
{
#if defined(_AIX) || defined(U_SOLARIS) || defined(U_LINUX) || defined(HPUX) || defined(POSIX) || defined(OS390)
setTestDirectory("source|test|testdata|");
@ -468,8 +467,8 @@ IntlTest::setTestDirectory(const char* newDir)
char newTestDir[256];
IntlTest::pathnameInContext(newTestDir, sizeof(newTestDir), newDir);
if(_testDirectory != NULL)
free(_testDirectory);
_testDirectory = (char*) malloc(sizeof(char) * (strlen(newTestDir) + 1));
delete _testDirectory;
_testDirectory = new char[strlen(newTestDir) + 1];
strcpy(_testDirectory, newTestDir);
}

View file

@ -4,6 +4,8 @@
* others. All Rights Reserved.
********************************************************************/
#include "cmemory.h"
#ifndef _COLL
#include "unicode/coll.h"
#endif
@ -501,7 +503,7 @@ int32_t *CollationIteratorTest::getOrders(CollationElementIterator &iter, int32_
maxSize *= 2;
int32_t *temp = new int32_t[maxSize];
memcpy(temp, orders, size * sizeof(int32_t));
uprv_memcpy(temp, orders, size * sizeof(int32_t));
delete[] orders;
orders = temp;
}

View file

@ -7,6 +7,7 @@
#ifndef _NUMBERFORMATROUNDTRIPTEST_
#define _NUMBERFORMATROUNDTRIPTEST_
#include <stdlib.h>
#include "unicode/utypes.h"
#include "intltest.h"
@ -60,7 +61,7 @@ static uint32_t randLong()
// Assume 8-bit (or larger) rand values. Also assume
// that the system rand() function is very poor, which it always is.
uint32_t d;
int32_t i;
uint32_t i;
char* poke = (char*)&d;
for (i=0; i < sizeof(uint32_t); ++i)
{

View file

@ -4,6 +4,7 @@
* others. All Rights Reserved.
********************************************************************/
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <limits.h>

View file

@ -4,6 +4,7 @@
* others. All Rights Reserved.
********************************************************************/
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <limits.h>

View file

@ -338,7 +338,7 @@ TestChoiceFormat::TestComplexExample( void )
delete form_A; delete form_A2; delete form_B;
char* testPattern = "0#none|1#one|2#many";
const char* testPattern = "0#none|1#one|2#many";
ChoiceFormat form_pat( testPattern, status );
if (!chkstatus( status, "*** ChoiceFormat contructor( newPattern, status)" )) {
delete fileform;

View file

@ -18,6 +18,7 @@
#include "unicode/nultrans.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "unicode/rep.h"
int32_t getInt(UnicodeString str)

View file

@ -10,6 +10,7 @@
#include "unicode/datefmt.h"
#include "unicode/smpdtfmt.h"
#include <stdlib.h>
#include <math.h>
const double IntlTestDateFormat::ONEYEAR = 365.25 * ONEDAY; // Approximate
@ -202,7 +203,7 @@ double IntlTestDateFormat::randDouble()
// Assume 8-bit (or larger) rand values. Also assume
// that the system rand() function is very poor, which it always is.
double d=0.0;
int32_t i;
uint32_t i;
char* poke = (char*)&d;
do {
for (i=0; i < sizeof(double); ++i)

View file

@ -8,6 +8,8 @@
#define _INTLTESTNUMBERFORMAT
#include <stdlib.h>
#include "unicode/utypes.h"
#include "intltest.h"

View file

@ -151,7 +151,7 @@ void BasicNormalizerTest::TestPrevious()
Normalizer* norm = new Normalizer("", Normalizer::DECOMP, 0);
logln("testing decomp...");
int i;
uint32_t i;
for (i = 0; i < ARRAY_LENGTH(canonTests); i++) {
backAndForth(norm, canonTests[i][0]);
}
@ -225,7 +225,7 @@ void BasicNormalizerTest::TestHangulCompose()
// And finally, make sure you can do it in reverse too
logln("Reverse iteration...");
norm->setMode(Normalizer::COMPOSE);
for (int i = 0; i < ARRAY_LENGTH(hangulCanon); i++) {
for (uint32_t i = 0; i < ARRAY_LENGTH(hangulCanon); i++) {
backAndForth(norm, hangulCanon[i][0]);
}
delete norm;
@ -247,7 +247,7 @@ void BasicNormalizerTest::TestHangulDecomp()
// And finally, make sure you can do it in reverse too
logln("Reverse iteration...");
norm->setMode(Normalizer::DECOMP);
for (int i = 0; i < ARRAY_LENGTH(hangulCanon); i++) {
for (uint32_t i = 0; i < ARRAY_LENGTH(hangulCanon); i++) {
backAndForth(norm, hangulCanon[i][0]);
}
delete norm;