ICU-5445 Fix some compiler warnings.
X-SVN-Rev: 22008
This commit is contained in:
parent
0abc6413d3
commit
d1f7d0ed12
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* *
|
* *
|
||||||
* Copyright (C) 2001-2004, International Business Machines *
|
* Copyright (C) 2001-2007, International Business Machines *
|
||||||
* Corporation and others. All Rights Reserved. *
|
* Corporation and others. All Rights Reserved. *
|
||||||
* *
|
* *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
@ -50,7 +50,7 @@
|
|||||||
typedef enum ECleanupLibraryType {
|
typedef enum ECleanupLibraryType {
|
||||||
UCLN_START = -1,
|
UCLN_START = -1,
|
||||||
UCLN_CUSTOM, /* Custom is for anyone else. */
|
UCLN_CUSTOM, /* Custom is for anyone else. */
|
||||||
UCLN_CTESTFW,
|
UCLN_CTESTFW,
|
||||||
UCLN_LAYOUTEX,
|
UCLN_LAYOUTEX,
|
||||||
UCLN_LAYOUT,
|
UCLN_LAYOUT,
|
||||||
UCLN_IO,
|
UCLN_IO,
|
||||||
|
@ -2278,7 +2278,7 @@ static void TestLocDataErrorCodeChaining(void) {
|
|||||||
UErrorCode ec = U_USELESS_COLLATOR_ERROR;
|
UErrorCode ec = U_USELESS_COLLATOR_ERROR;
|
||||||
ulocdata_open(NULL, &ec);
|
ulocdata_open(NULL, &ec);
|
||||||
ulocdata_getExemplarSet(NULL, NULL, 0, ULOCDATA_ES_STANDARD, &ec);
|
ulocdata_getExemplarSet(NULL, NULL, 0, ULOCDATA_ES_STANDARD, &ec);
|
||||||
ulocdata_getDelimiter(NULL, ULOCDATA_ES_STANDARD, NULL, -1, &ec);
|
ulocdata_getDelimiter(NULL, ULOCDATA_DELIMITER_COUNT, NULL, -1, &ec);
|
||||||
ulocdata_getMeasurementSystem(NULL, &ec);
|
ulocdata_getMeasurementSystem(NULL, &ec);
|
||||||
ulocdata_getPaperSize(NULL, NULL, NULL, &ec);
|
ulocdata_getPaperSize(NULL, NULL, NULL, &ec);
|
||||||
if (ec != U_USELESS_COLLATOR_ERROR) {
|
if (ec != U_USELESS_COLLATOR_ERROR) {
|
||||||
|
@ -2,15 +2,10 @@
|
|||||||
* COPYRIGHT:
|
* COPYRIGHT:
|
||||||
* Copyright (c) 1997-2007, International Business Machines Corporation and
|
* Copyright (c) 1997-2007, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
********************************************************************/
|
***********************************************************************
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* Modification history
|
* Modification history
|
||||||
* Date Name Description
|
* Date Name Description
|
||||||
* 07/09/2007 srl Copied from dadrcoll.cpp
|
* 07/09/2007 srl Copied from dadrcoll.cpp
|
||||||
* 02/14/2001 synwee Compare with cintltst and commented away tests
|
|
||||||
* that are not run.
|
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include "unicode/utypes.h"
|
#include "unicode/utypes.h"
|
||||||
@ -34,141 +29,141 @@
|
|||||||
/** ------- Calendar Fields Set -------- **/
|
/** ------- Calendar Fields Set -------- **/
|
||||||
class CalendarFieldsSet {
|
class CalendarFieldsSet {
|
||||||
public:
|
public:
|
||||||
CalendarFieldsSet();
|
CalendarFieldsSet();
|
||||||
~CalendarFieldsSet();
|
~CalendarFieldsSet();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void clear(UCalendarDateFields field);
|
void clear(UCalendarDateFields field);
|
||||||
void set(UCalendarDateFields field, int32_t amount);
|
void set(UCalendarDateFields field, int32_t amount);
|
||||||
|
|
||||||
UBool isSet(UCalendarDateFields field) const;
|
UBool isSet(UCalendarDateFields field) const;
|
||||||
int32_t get(UCalendarDateFields field) const;
|
int32_t get(UCalendarDateFields field) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the specified fields on this calendar. Doesn't clear first. Returns any errors the cale
|
* set the specified fields on this calendar. Doesn't clear first. Returns any errors the cale
|
||||||
*/
|
*/
|
||||||
void setOnCalendar(Calendar *cal, UErrorCode& status) const;
|
void setOnCalendar(Calendar *cal, UErrorCode& status) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param diffSet fillin to hold any fields different. Will have the calendar's value set on them.
|
* @param diffSet fillin to hold any fields different. Will have the calendar's value set on them.
|
||||||
* @return true if the calendar matches in these fields
|
* @return true if the calendar matches in these fields
|
||||||
*/
|
*/
|
||||||
UBool matches(Calendar *cal, CalendarFieldsSet &diffSet, UErrorCode& status) const;
|
UBool matches(Calendar *cal, CalendarFieldsSet &diffSet, UErrorCode& status) const;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param "expected" set to match against
|
* @param "expected" set to match against
|
||||||
* @return a formatted string listing which fields are set in
|
* @return a formatted string listing which fields are set in
|
||||||
* this, with the comparison made agaainst those fields in other.
|
* this, with the comparison made agaainst those fields in other.
|
||||||
*/
|
*/
|
||||||
UnicodeString diffFrom(const CalendarFieldsSet& other) const;
|
UnicodeString diffFrom(const CalendarFieldsSet& other) const;
|
||||||
/**
|
/**
|
||||||
* parse from a string.
|
* parse from a string.
|
||||||
* @param str the string to parse
|
* @param str the string to parse
|
||||||
* @param inherit the CalendarFieldsSet to inherit any inherited items from, or NULL
|
* @param inherit the CalendarFieldsSet to inherit any inherited items from, or NULL
|
||||||
* @param status error code
|
* @param status error code
|
||||||
* @return the number of items successfully parsed
|
* @return the number of items successfully parsed
|
||||||
*/
|
*/
|
||||||
int32_t parseFrom(const UnicodeString& str, CalendarFieldsSet* inheritFrom, UErrorCode& status);
|
int32_t parseFrom(const UnicodeString& str, CalendarFieldsSet* inheritFrom, UErrorCode& status);
|
||||||
int32_t parseFrom(const UnicodeString& str, UErrorCode& status);
|
int32_t parseFrom(const UnicodeString& str, UErrorCode& status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t fValue[UDAT_FIELD_COUNT]; /** field values **/
|
int32_t fValue[UDAT_FIELD_COUNT]; /** field values **/
|
||||||
UBool fIsSet[UDAT_FIELD_COUNT]; /** Is this field set? **/
|
UBool fIsSet[UDAT_FIELD_COUNT]; /** Is this field set? **/
|
||||||
};
|
};
|
||||||
|
|
||||||
CalendarFieldsSet::CalendarFieldsSet() {
|
CalendarFieldsSet::CalendarFieldsSet() {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CalendarFieldsSet::~CalendarFieldsSet() {
|
CalendarFieldsSet::~CalendarFieldsSet() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarFieldsSet::clear() {
|
void CalendarFieldsSet::clear() {
|
||||||
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
||||||
fValue[i]=-1;
|
fValue[i]=-1;
|
||||||
fIsSet[i]=FALSE;
|
fIsSet[i]=FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarFieldsSet::clear(UCalendarDateFields field) {
|
void CalendarFieldsSet::clear(UCalendarDateFields field) {
|
||||||
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fValue[field] = -1;
|
fValue[field] = -1;
|
||||||
fIsSet[field] = FALSE;
|
fIsSet[field] = FALSE;
|
||||||
}
|
}
|
||||||
void CalendarFieldsSet::set(UCalendarDateFields field, int32_t amount) {
|
void CalendarFieldsSet::set(UCalendarDateFields field, int32_t amount) {
|
||||||
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fValue[field] = amount;
|
fValue[field] = amount;
|
||||||
fIsSet[field] = TRUE;
|
fIsSet[field] = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
UBool CalendarFieldsSet::isSet(UCalendarDateFields field) const {
|
UBool CalendarFieldsSet::isSet(UCalendarDateFields field) const {
|
||||||
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return fIsSet[field];
|
return fIsSet[field];
|
||||||
}
|
}
|
||||||
int32_t CalendarFieldsSet::get(UCalendarDateFields field) const {
|
int32_t CalendarFieldsSet::get(UCalendarDateFields field) const {
|
||||||
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
if(field<0 || field>=UCAL_FIELD_COUNT) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return fValue[field];
|
return fValue[field];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the specified fields on this calendar. Doesn't clear first. Returns any errors the caller
|
* set the specified fields on this calendar. Doesn't clear first. Returns any errors the caller
|
||||||
*/
|
*/
|
||||||
void CalendarFieldsSet::setOnCalendar(Calendar *cal, UErrorCode& status) const {
|
void CalendarFieldsSet::setOnCalendar(Calendar *cal, UErrorCode& status) const {
|
||||||
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
||||||
if(isSet((UCalendarDateFields)i)) {
|
if(isSet((UCalendarDateFields)i)) {
|
||||||
int32_t value = get((UCalendarDateFields)i);
|
int32_t value = get((UCalendarDateFields)i);
|
||||||
//fprintf(stderr, "Setting: %s#%d=%d\n",udbg_enumName(UDBG_UCalendarDateFields,i),i,value);
|
//fprintf(stderr, "Setting: %s#%d=%d\n",udbg_enumName(UDBG_UCalendarDateFields,i),i,value);
|
||||||
cal->set((UCalendarDateFields)i,get((UCalendarDateFields)i));
|
cal->set((UCalendarDateFields)i,get((UCalendarDateFields)i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if the calendar matches in these fields
|
* return true if the calendar matches in these fields
|
||||||
*/
|
*/
|
||||||
UBool CalendarFieldsSet::matches(Calendar *cal, CalendarFieldsSet &diffSet, UErrorCode& status) const {
|
UBool CalendarFieldsSet::matches(Calendar *cal, CalendarFieldsSet &diffSet, UErrorCode& status) const {
|
||||||
UBool match = TRUE;
|
UBool match = TRUE;
|
||||||
if(U_FAILURE(status)) return FALSE;
|
if(U_FAILURE(status)) return FALSE;
|
||||||
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
||||||
if(isSet((UCalendarDateFields)i)) {
|
if(isSet((UCalendarDateFields)i)) {
|
||||||
int32_t calVal = cal->get((UCalendarDateFields)i,status);
|
int32_t calVal = cal->get((UCalendarDateFields)i,status);
|
||||||
if(U_FAILURE(status)) return FALSE;
|
if(U_FAILURE(status)) return FALSE;
|
||||||
if(calVal != get((UCalendarDateFields)i)) {
|
if(calVal != get((UCalendarDateFields)i)) {
|
||||||
match = FALSE;
|
match = FALSE;
|
||||||
diffSet.set((UCalendarDateFields)i,calVal);
|
diffSet.set((UCalendarDateFields)i,calVal);
|
||||||
//fprintf(stderr, "match failed: %s#%d=%d != %d\n",udbg_enumName(UDBG_UCalendarDateFields,i),i,cal->get((UCalendarDateFields)i,status), get((UCalendarDateFields)i));;
|
//fprintf(stderr, "match failed: %s#%d=%d != %d\n",udbg_enumName(UDBG_UCalendarDateFields,i),i,cal->get((UCalendarDateFields)i,status), get((UCalendarDateFields)i));;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnicodeString CalendarFieldsSet::diffFrom(const CalendarFieldsSet& other) const {
|
UnicodeString CalendarFieldsSet::diffFrom(const CalendarFieldsSet& other) const {
|
||||||
UnicodeString str;
|
UnicodeString str;
|
||||||
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
for(int i=0;i<UDAT_FIELD_COUNT;i++) {
|
||||||
if(isSet((UCalendarDateFields)i)) {
|
if(isSet((UCalendarDateFields)i)) {
|
||||||
int32_t myVal = get((UCalendarDateFields)i);
|
int32_t myVal = get((UCalendarDateFields)i);
|
||||||
int32_t theirVal = other.get((UCalendarDateFields)i);
|
int32_t theirVal = other.get((UCalendarDateFields)i);
|
||||||
const UnicodeString& fieldName = udbg_enumString(UDBG_UCalendarDateFields,i);
|
const UnicodeString& fieldName = udbg_enumString(UDBG_UCalendarDateFields,i);
|
||||||
|
|
||||||
str = str + fieldName +"="+myVal+" not "+theirVal+", ";
|
str = str + fieldName +"="+myVal+" not "+theirVal+", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CalendarFieldsSet::parseFrom(const UnicodeString& str, UErrorCode& status) {
|
int32_t CalendarFieldsSet::parseFrom(const UnicodeString& str, UErrorCode& status) {
|
||||||
return parseFrom(str, NULL, status);
|
return parseFrom(str, NULL, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -179,110 +174,104 @@ int32_t CalendarFieldsSet::parseFrom(const UnicodeString& str, UErrorCode& statu
|
|||||||
* @return the number of items successfully parsed or -1 on error
|
* @return the number of items successfully parsed or -1 on error
|
||||||
*/
|
*/
|
||||||
int32_t CalendarFieldsSet::parseFrom(const UnicodeString& str, CalendarFieldsSet* inheritFrom, UErrorCode& status) {
|
int32_t CalendarFieldsSet::parseFrom(const UnicodeString& str, CalendarFieldsSet* inheritFrom, UErrorCode& status) {
|
||||||
UnicodeString pattern(",","");
|
UnicodeString pattern(",","");
|
||||||
RegexMatcher matcher(pattern,0,status);
|
RegexMatcher matcher(pattern,0,status);
|
||||||
UnicodeString pattern2("=","");
|
UnicodeString pattern2("=","");
|
||||||
RegexMatcher matcher2(pattern2,0,status);
|
RegexMatcher matcher2(pattern2,0,status);
|
||||||
if(U_FAILURE(status)) return -1;
|
if(U_FAILURE(status)) return -1;
|
||||||
|
|
||||||
UnicodeString dest[UDAT_FIELD_COUNT+10];
|
UnicodeString dest[UDAT_FIELD_COUNT+10];
|
||||||
int32_t destCount = matcher.split(str,dest,sizeof(dest)/sizeof(dest[0]), status);
|
int32_t destCount = matcher.split(str,dest,sizeof(dest)/sizeof(dest[0]), status);
|
||||||
if(U_FAILURE(status)) return -1;
|
if(U_FAILURE(status)) return -1;
|
||||||
for(int i=0;i<destCount;i++) {
|
for(int i=0;i<destCount;i++) {
|
||||||
UnicodeString kv[2];
|
UnicodeString kv[2];
|
||||||
int32_t kvCount = matcher2.split(dest[i],kv,2,status);
|
int32_t kvCount = matcher2.split(dest[i],kv,2,status);
|
||||||
if(U_FAILURE(status)) return -1;
|
if(U_FAILURE(status)) return -1;
|
||||||
|
|
||||||
int32_t field = udbg_enumByString(UDBG_UCalendarDateFields, kv[0]);
|
int32_t field = udbg_enumByString(UDBG_UCalendarDateFields, kv[0]);
|
||||||
|
|
||||||
if(field == -1) {
|
if(field == -1) {
|
||||||
char ch[256];
|
char ch[256];
|
||||||
const UChar *u = kv[0].getBuffer();
|
const UChar *u = kv[0].getBuffer();
|
||||||
int32_t len = kv[0].length();
|
int32_t len = kv[0].length();
|
||||||
u_UCharsToChars(u, ch, len);
|
u_UCharsToChars(u, ch, len);
|
||||||
ch[len] = 0; /* include terminating \0 */
|
ch[len] = 0; /* include terminating \0 */
|
||||||
fprintf(stderr,"Parse Failed: Unknown Field %s\n", ch);
|
fprintf(stderr,"Parse Failed: Unknown Field %s\n", ch);
|
||||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int value = -1;
|
int value = -1;
|
||||||
|
|
||||||
if(kv[1].length()==0) {
|
if(kv[1].length()==0) {
|
||||||
// inherit
|
// inherit
|
||||||
if((inheritFrom == NULL) || !inheritFrom->isSet((UCalendarDateFields)field)) {
|
if((inheritFrom == NULL) || !inheritFrom->isSet((UCalendarDateFields)field)) {
|
||||||
// couldn't inherit from field
|
// couldn't inherit from field
|
||||||
fprintf(stderr,"Parse Failed: Couldn't inherit field %d [%s]\n", field, udbg_enumName(UDBG_UCalendarDateFields, field));
|
fprintf(stderr,"Parse Failed: Couldn't inherit field %d [%s]\n", field, udbg_enumName(UDBG_UCalendarDateFields, field));
|
||||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
value = inheritFrom->get((UCalendarDateFields)field);
|
value = inheritFrom->get((UCalendarDateFields)field);
|
||||||
} else {
|
} else {
|
||||||
if(field==UCAL_MONTH) {
|
if(field==UCAL_MONTH) {
|
||||||
value = udbg_enumByString(UDBG_UCalendarMonths, kv[1]);
|
value = udbg_enumByString(UDBG_UCalendarMonths, kv[1]);
|
||||||
} // else, other types..
|
} // else, other types..
|
||||||
if(value==-1) {
|
if(value==-1) {
|
||||||
// parse as decimal
|
// parse as decimal
|
||||||
value = udbg_stoi(kv[1]);
|
value = udbg_stoi(kv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr, "Parsed: %s#%d=%d\n",udbg_enumName(UDBG_UCalendarDateFields,field),field,value);
|
//fprintf(stderr, "Parsed: %s#%d=%d\n",udbg_enumName(UDBG_UCalendarDateFields,field),field,value);
|
||||||
set((UCalendarDateFields)field,value);
|
set((UCalendarDateFields)field,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DataDrivenCalendarTest::DataDrivenCalendarTest()
|
DataDrivenCalendarTest::DataDrivenCalendarTest()
|
||||||
: // seq(StringCharacterIterator("")),
|
//: status(U_ZERO_ERROR)
|
||||||
status(U_ZERO_ERROR)
|
|
||||||
//sequences(status)
|
|
||||||
{
|
{
|
||||||
driver = TestDataModule::getTestDataModule("calendar", *this, status);
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
//sequences.setDeleter(deleteSeqElement);
|
driver = TestDataModule::getTestDataModule("calendar", *this, status);
|
||||||
//UCA = (RuleBasedCalendar*)Calendar::createInstance("root", status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataDrivenCalendarTest::~DataDrivenCalendarTest()
|
DataDrivenCalendarTest::~DataDrivenCalendarTest()
|
||||||
{
|
{
|
||||||
delete driver;
|
delete driver;
|
||||||
//delete UCA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataDrivenCalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */)
|
void DataDrivenCalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */)
|
||||||
{
|
{
|
||||||
if(driver != NULL) {
|
if(driver != NULL) {
|
||||||
if (exec)
|
if (exec)
|
||||||
{
|
{
|
||||||
// logln("Begin ");
|
// logln("Begin ");
|
||||||
}
|
}
|
||||||
const DataMap *info = NULL;
|
const DataMap *info = NULL;
|
||||||
TestData *testData = driver->createTestData(index, status);
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
if(U_SUCCESS(status)) {
|
TestData *testData = driver->createTestData(index, status);
|
||||||
name = testData->getName();
|
if(U_SUCCESS(status)) {
|
||||||
if(testData->getInfo(info, status)) {
|
name = testData->getName();
|
||||||
log(info->getString("Description", status));
|
if(testData->getInfo(info, status)) {
|
||||||
}
|
log(info->getString("Description", status));
|
||||||
if(exec) {
|
}
|
||||||
log(name);
|
if(exec) {
|
||||||
logln("---");
|
log(name);
|
||||||
logln("");
|
logln("---");
|
||||||
|
logln("");
|
||||||
|
|
||||||
processTest(testData);
|
processTest(testData, status);
|
||||||
}
|
}
|
||||||
delete testData;
|
delete testData;
|
||||||
|
} else {
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
name = "";
|
errln("format/DataDrivenTest data (calendar.res) not initialized!");
|
||||||
|
name = "";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
errln("format/DataDrivenTest data (calendar.res) not initialized!");
|
|
||||||
name = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads the options string and sets appropriate attributes in Calendar
|
// Reads the options string and sets appropriate attributes in Calendar
|
||||||
@ -291,193 +280,196 @@ DataDrivenCalendarTest::processArguments(Calendar *col, const UChar *start, int3
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataDrivenCalendarTest::testConvert(int32_t n, const CalendarFieldsSet &fromSet, Calendar *fromCalendar,
|
void DataDrivenCalendarTest::testConvert(int32_t n, const CalendarFieldsSet &fromSet, Calendar *fromCalendar,
|
||||||
const CalendarFieldsSet &toSet, Calendar *toCalendar, UBool forward) {
|
const CalendarFieldsSet &toSet, Calendar *toCalendar, UBool forward)
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
{
|
||||||
UnicodeString thisString = (UnicodeString)"#"+n+" "+(forward?"forward":"reverse")+" "+fromCalendar->getType()+"->"+
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
toCalendar->getType();
|
UnicodeString thisString = (UnicodeString)"#"+n+" "+(forward?"forward":"reverse")+" "+fromCalendar->getType()+"->"+
|
||||||
|
toCalendar->getType();
|
||||||
|
|
||||||
fromCalendar->clear();
|
fromCalendar->clear();
|
||||||
|
|
||||||
fromSet.setOnCalendar(fromCalendar,status);
|
fromSet.setOnCalendar(fromCalendar,status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
errln("FAIL: Failed to set on Source calendar: %s", u_errorName(status));
|
errln("FAIL: Failed to set on Source calendar: %s", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CalendarFieldsSet diffSet;
|
CalendarFieldsSet diffSet;
|
||||||
|
|
||||||
// turn this on to test that the calendar was set as expected. Normally not needed.
|
// turn this on to test that the calendar was set as expected. Normally not needed.
|
||||||
#if 0
|
#if 0
|
||||||
diffSet.clear();
|
diffSet.clear();
|
||||||
// Is the calendar sane at the first?
|
// Is the calendar sane at the first?
|
||||||
if(!fromSet.matches(fromCalendar, diffSet, status)) {
|
if(!fromSet.matches(fromCalendar, diffSet, status)) {
|
||||||
UnicodeString diffs = diffSet.diffFrom(fromSet);
|
UnicodeString diffs = diffSet.diffFrom(fromSet);
|
||||||
errln((UnicodeString)"FAIL: "+thisString+", SOURCE calendar was not set: Differences: " + diffs +"', status: " + u_errorName(status));
|
errln((UnicodeString)"FAIL: "+thisString+", SOURCE calendar was not set: Differences: " + diffs +"', status: " + u_errorName(status));
|
||||||
} else if(U_FAILURE(status)) {
|
} else if(U_FAILURE(status)) {
|
||||||
errln("FAIL: "+thisString+" SOURCE calendar Failed to match: "+u_errorName(status));
|
errln("FAIL: "+thisString+" SOURCE calendar Failed to match: "+u_errorName(status));
|
||||||
} else {
|
} else {
|
||||||
logln("PASS: "+thisString+" SOURCE calendar match.");
|
logln("PASS: "+thisString+" SOURCE calendar match.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//logln("Set Source calendar: " + from);
|
//logln("Set Source calendar: " + from);
|
||||||
|
|
||||||
UDate fromTime = fromCalendar->getTime(status);
|
UDate fromTime = fromCalendar->getTime(status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
errln("FAIL: Failed to get Source time: %s", u_errorName(status));
|
errln("FAIL: Failed to get Source time: %s", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn this on to test that the calendar completed as expected. Normally not needed.
|
// turn this on to test that the calendar completed as expected. Normally not needed.
|
||||||
#if 0
|
#if 0
|
||||||
diffSet.clear();
|
diffSet.clear();
|
||||||
// Is the calendar sane after being set?
|
// Is the calendar sane after being set?
|
||||||
if(!fromSet.matches(fromCalendar, diffSet, status)) {
|
if(!fromSet.matches(fromCalendar, diffSet, status)) {
|
||||||
UnicodeString diffs = diffSet.diffFrom(fromSet);
|
UnicodeString diffs = diffSet.diffFrom(fromSet);
|
||||||
errln((UnicodeString)"FAIL: "+thisString+", SET SOURCE calendar was not set: Differences: " + diffs +"', status: " + u_errorName(status));
|
errln((UnicodeString)"FAIL: "+thisString+", SET SOURCE calendar was not set: Differences: " + diffs +"', status: " + u_errorName(status));
|
||||||
} else if(U_FAILURE(status)) {
|
} else if(U_FAILURE(status)) {
|
||||||
errln("FAIL: "+thisString+" SET SOURCE calendar Failed to match: "+u_errorName(status));
|
errln("FAIL: "+thisString+" SET SOURCE calendar Failed to match: "+u_errorName(status));
|
||||||
} else {
|
} else {
|
||||||
logln("PASS: "+thisString+" SET SOURCE calendar match.");
|
logln("PASS: "+thisString+" SET SOURCE calendar match.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
toCalendar->clear();
|
toCalendar->clear();
|
||||||
toCalendar->setTime(fromTime, status);
|
toCalendar->setTime(fromTime, status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
errln("FAIL: Failed to set Target time: %s", u_errorName(status));
|
errln("FAIL: Failed to set Target time: %s", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
diffSet.clear();
|
diffSet.clear();
|
||||||
if(!toSet.matches(toCalendar, diffSet, status)) {
|
if(!toSet.matches(toCalendar, diffSet, status)) {
|
||||||
UnicodeString diffs = diffSet.diffFrom(toSet);
|
UnicodeString diffs = diffSet.diffFrom(toSet);
|
||||||
errln((UnicodeString)"FAIL: "+thisString+", Differences: " + diffs +"', status: " + u_errorName(status));
|
errln((UnicodeString)"FAIL: "+thisString+", Differences: " + diffs +"', status: " + u_errorName(status));
|
||||||
SimpleDateFormat fmt(UnicodeString("EEE MMM dd yyyy G"), status);
|
SimpleDateFormat fmt(UnicodeString("EEE MMM dd yyyy G"), status);
|
||||||
UnicodeString fromString;
|
UnicodeString fromString;
|
||||||
fmt.format(fromTime,fromString);
|
fmt.format(fromTime,fromString);
|
||||||
logln("Source Time: "+fromString+", Source Calendar: "+fromCalendar->getType());
|
logln("Source Time: "+fromString+", Source Calendar: "+fromCalendar->getType());
|
||||||
} else if(U_FAILURE(status)) {
|
} else if(U_FAILURE(status)) {
|
||||||
errln("FAIL: "+thisString+" Failed to match: "+u_errorName(status));
|
errln("FAIL: "+thisString+" Failed to match: "+u_errorName(status));
|
||||||
} else {
|
} else {
|
||||||
logln("PASS: "+thisString+" match.");
|
logln("PASS: "+thisString+" match.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataDrivenCalendarTest::testConvert(TestData *testData, const DataMap *settings, UBool forward) {
|
void DataDrivenCalendarTest::testConvert(TestData *testData, const DataMap *settings, UBool forward) {
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
Calendar *toCalendar = NULL;
|
Calendar *toCalendar = NULL;
|
||||||
const DataMap *currentCase = NULL;
|
const DataMap *currentCase = NULL;
|
||||||
char toCalLoc[256] = "";
|
char toCalLoc[256] = "";
|
||||||
char fromCalLoc[256] = "";
|
char fromCalLoc[256] = "";
|
||||||
// build to calendar
|
// build to calendar
|
||||||
UnicodeString testSetting = settings->getString("ToCalendar", status);
|
UnicodeString testSetting = settings->getString("ToCalendar", status);
|
||||||
if(U_SUCCESS(status)) {
|
if(U_SUCCESS(status)) {
|
||||||
testSetting.extract(0, testSetting.length(), toCalLoc, (const char*)0);
|
testSetting.extract(0, testSetting.length(), toCalLoc, (const char*)0);
|
||||||
toCalendar = Calendar::createInstance(toCalLoc, status);
|
toCalendar = Calendar::createInstance(toCalLoc, status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
errln("Unable to instantiate ToCalendar for "+testSetting);
|
errln("Unable to instantiate ToCalendar for "+testSetting);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CalendarFieldsSet fromSet, toSet, diffSet;
|
CalendarFieldsSet fromSet, toSet, diffSet;
|
||||||
SimpleDateFormat fmt(UnicodeString("EEE MMM dd yyyy / YYYY'-W'ww-ee"), status);
|
SimpleDateFormat fmt(UnicodeString("EEE MMM dd yyyy / YYYY'-W'ww-ee"), status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
errln("FAIL: Couldn't create SimpleDateFormat: %s\n", u_errorName(status));
|
errln("FAIL: Couldn't create SimpleDateFormat: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Start the processing
|
// Start the processing
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while(testData->nextCase(currentCase, status)) {
|
while(testData->nextCase(currentCase, status)) {
|
||||||
++n;
|
++n;
|
||||||
Calendar *fromCalendar = NULL;
|
Calendar *fromCalendar = NULL;
|
||||||
UnicodeString locale = currentCase->getString("locale", status);
|
UnicodeString locale = currentCase->getString("locale", status);
|
||||||
if(U_SUCCESS(status)) {
|
if(U_SUCCESS(status)) {
|
||||||
locale.extract(0, locale.length(), fromCalLoc, (const char*)0); // default codepage. Invariant codepage doesn't have '@'!
|
locale.extract(0, locale.length(), fromCalLoc, (const char*)0); // default codepage. Invariant codepage doesn't have '@'!
|
||||||
fromCalendar = Calendar::createInstance(fromCalLoc, status);
|
fromCalendar = Calendar::createInstance(fromCalLoc, status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
errln("Unable to instantiate fromCalendar for "+locale);
|
errln("Unable to instantiate fromCalendar for "+locale);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errln("No 'locale' line.");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
errln("No 'locale' line.");
|
fromSet.clear();
|
||||||
continue;
|
toSet.clear();
|
||||||
}
|
|
||||||
|
UnicodeString from = currentCase->getString("from", status);
|
||||||
fromSet.clear();
|
if(U_FAILURE(status)) {
|
||||||
toSet.clear();
|
errln("No 'from' line.");
|
||||||
|
continue;
|
||||||
UnicodeString from = currentCase->getString("from", status);
|
}
|
||||||
if(U_FAILURE(status)) {
|
fromSet.parseFrom(from, status);
|
||||||
errln("No 'from' line.");
|
if(U_FAILURE(status)) {
|
||||||
continue;
|
errln("Failed to parse 'from' parameter: "+from);
|
||||||
}
|
continue;
|
||||||
fromSet.parseFrom(from, status);
|
}
|
||||||
if(U_FAILURE(status)) {
|
UnicodeString to = currentCase->getString("to", status);
|
||||||
errln("Failed to parse 'from' parameter: "+from);
|
if(U_FAILURE(status)) {
|
||||||
continue;
|
errln("No 'to' line.");
|
||||||
}
|
continue;
|
||||||
UnicodeString to = currentCase->getString("to", status);
|
}
|
||||||
if(U_FAILURE(status)) {
|
toSet.parseFrom(to, &fromSet, status);
|
||||||
errln("No 'to' line.");
|
if(U_FAILURE(status)) {
|
||||||
continue;
|
errln("Failed to parse 'to' parameter: "+to);
|
||||||
}
|
continue;
|
||||||
toSet.parseFrom(to, &fromSet, status);
|
}
|
||||||
if(U_FAILURE(status)) {
|
|
||||||
errln("Failed to parse 'to' parameter: "+to);
|
// now, do it.
|
||||||
continue;
|
if(forward) {
|
||||||
}
|
logln((UnicodeString)"#"+n+" "+locale+"/"+from+" >>> "+toCalLoc+"/"+to);
|
||||||
|
testConvert(n, fromSet, fromCalendar, toSet, toCalendar, forward);
|
||||||
// now, do it.
|
} else {
|
||||||
if(forward) {
|
logln((UnicodeString)"#"+n+" "+locale+"/"+from+" <<< "+toCalLoc+"/"+to);
|
||||||
logln((UnicodeString)"#"+n+" "+locale+"/"+from+" >>> "+toCalLoc+"/"+to);
|
testConvert(n, toSet, toCalendar, fromSet, fromCalendar, forward);
|
||||||
testConvert(n, fromSet, fromCalendar, toSet, toCalendar, forward);
|
}
|
||||||
} else {
|
|
||||||
logln((UnicodeString)"#"+n+" "+locale+"/"+from+" <<< "+toCalLoc+"/"+to);
|
delete fromCalendar;
|
||||||
testConvert(n, toSet, toCalendar, fromSet, fromCalendar, forward);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete fromCalendar;
|
|
||||||
}
|
}
|
||||||
delete toCalendar;
|
delete toCalendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DataDrivenCalendarTest::processTest(TestData *testData) {
|
DataDrivenCalendarTest::processTest(TestData *testData, UErrorCode status) {
|
||||||
Calendar *cal = NULL;
|
Calendar *cal = NULL;
|
||||||
const UChar *arguments = NULL;
|
const UChar *arguments = NULL;
|
||||||
int32_t argLen = 0;
|
int32_t argLen = 0;
|
||||||
char testType[256];
|
char testType[256];
|
||||||
const DataMap *settings = NULL;
|
const DataMap *settings = NULL;
|
||||||
const UChar *type = NULL;
|
const UChar *type = NULL;
|
||||||
UErrorCode intStatus = U_ZERO_ERROR;
|
UnicodeString testSetting;
|
||||||
UnicodeString testSetting;
|
int n = 0;
|
||||||
int n = 0;
|
while(testData->nextSettings(settings, status)) {
|
||||||
while(testData->nextSettings(settings, status)) {
|
status = U_ZERO_ERROR;
|
||||||
intStatus = U_ZERO_ERROR;
|
// try to get a locale
|
||||||
// try to get a locale
|
testSetting = settings->getString("Type", status);
|
||||||
testSetting = settings->getString("Type", intStatus);
|
if(U_SUCCESS(status)) {
|
||||||
if(U_SUCCESS(intStatus)) {
|
if((++n)>0) {
|
||||||
if((++n)>0) {
|
logln("---");
|
||||||
logln("---");
|
}
|
||||||
}
|
logln(testSetting + "---");
|
||||||
logln(testSetting + "---");
|
testSetting.extract(0, testSetting.length(), testType, "");
|
||||||
testSetting.extract(0, testSetting.length(), testType, "");
|
} else {
|
||||||
} else {
|
errln("Unable to extract 'Type'. Skipping..");
|
||||||
errln("Unable to extract 'Type'. Skipping..");
|
continue;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
|
if(!strcmp(testType,"convert_fwd")) {
|
||||||
|
testConvert(testData, settings, true);
|
||||||
|
} else if(!strcmp(testType,"convert_rev")) {
|
||||||
|
testConvert(testData, settings, false);
|
||||||
|
} else {
|
||||||
|
errln("Unknown type: %s", testType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
if(!strcmp(testType,"convert_fwd")) {
|
errln("Failure: %s", u_errorName(status));
|
||||||
testConvert(testData, settings, true);
|
|
||||||
} else if(!strcmp(testType,"convert_rev")) {
|
|
||||||
testConvert(testData, settings, false);
|
|
||||||
} else {
|
|
||||||
errln("Unknown type: %s", testType);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,19 +36,16 @@ protected:
|
|||||||
|
|
||||||
void DataDrivenTest(char *par);
|
void DataDrivenTest(char *par);
|
||||||
void processSequence(Calendar* cal, const UnicodeString &sequence);
|
void processSequence(Calendar* cal, const UnicodeString &sequence);
|
||||||
void processTest(TestData *testData);
|
void processTest(TestData *testData, UErrorCode status);
|
||||||
void processArguments(Calendar *cal, const UChar *start, int32_t optLen);
|
void processArguments(Calendar *cal, const UChar *start, int32_t optLen);
|
||||||
private:
|
private:
|
||||||
void testConvert(TestData *testData, const DataMap *settings, UBool fwd);
|
void testConvert(TestData *testData, const DataMap *settings, UBool fwd);
|
||||||
void testConvert(int32_t n, const CalendarFieldsSet &fromSet, Calendar *fromCal,
|
void testConvert(int32_t n, const CalendarFieldsSet &fromSet, Calendar *fromCal,
|
||||||
const CalendarFieldsSet &toSet, Calendar *toCal, UBool fwd);
|
const CalendarFieldsSet &toSet, Calendar *toCal, UBool fwd);
|
||||||
private:
|
private:
|
||||||
TestDataModule *driver;
|
TestDataModule *driver;
|
||||||
UErrorCode status;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* #if !UCONFIG_NO_COLLATION */
|
#endif /* #if !UCONFIG_NO_COLLATION */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,120 +1,122 @@
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* COPYRIGHT:
|
* COPYRIGHT:
|
||||||
* Copyright (c) 2007, International Business Machines Corporation and
|
* Copyright (c) 2007, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
#include "unicode/udbgutil.h"
|
#include "unicode/udbgutil.h"
|
||||||
#include "unicode/dbgutil.h"
|
#include "unicode/dbgutil.h"
|
||||||
|
|
||||||
#if !UCONFIG_NO_FORMATTING
|
#if !UCONFIG_NO_FORMATTING
|
||||||
|
|
||||||
#include "unicode/unistr.h"
|
#include "unicode/unistr.h"
|
||||||
#include "unicode/ustring.h"
|
#include "unicode/ustring.h"
|
||||||
#include "ucln.h"
|
#include "ucln.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
UnicodeString **strs = NULL;
|
UnicodeString **strs = NULL;
|
||||||
|
|
||||||
static const UnicodeString& _fieldString(UDebugEnumType type, int32_t field, UnicodeString& fillin) {
|
static const UnicodeString& _fieldString(UDebugEnumType type, int32_t field, UnicodeString& fillin) {
|
||||||
const char *str = udbg_enumName(type, field);
|
const char *str = udbg_enumName(type, field);
|
||||||
if(str == NULL) {
|
if(str == NULL) {
|
||||||
return fillin.remove();
|
return fillin.remove();
|
||||||
} else {
|
} else {
|
||||||
return fillin = UnicodeString(str, ""); // optimize?
|
return fillin = UnicodeString(str, ""); // optimize?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void udbg_cleanup(void) {
|
U_CDECL_BEGIN
|
||||||
if(strs != NULL) {
|
static void udbg_cleanup(void) {
|
||||||
for(int t=0;t<=UDBG_ENUM_COUNT;t++) {
|
if(strs != NULL) {
|
||||||
delete [] strs[t];
|
for(int t=0;t<=UDBG_ENUM_COUNT;t++) {
|
||||||
}
|
delete [] strs[t];
|
||||||
delete[] strs;
|
}
|
||||||
strs = NULL;
|
delete[] strs;
|
||||||
}
|
strs = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static UBool ctestfw_cleanup(void)
|
static UBool ctestfw_cleanup(void)
|
||||||
{
|
{
|
||||||
udbg_cleanup();
|
udbg_cleanup();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void udbg_register_cleanup(void) {
|
static void udbg_register_cleanup(void) {
|
||||||
ucln_registerCleanup(UCLN_CTESTFW, ctestfw_cleanup);
|
ucln_registerCleanup(UCLN_CTESTFW, ctestfw_cleanup);
|
||||||
}
|
}
|
||||||
|
U_CDECL_END
|
||||||
static void udbg_setup(void) {
|
|
||||||
if(strs == NULL) {
|
static void udbg_setup(void) {
|
||||||
udbg_register_cleanup();
|
if(strs == NULL) {
|
||||||
//fprintf(stderr,"Initializing string cache..\n");
|
udbg_register_cleanup();
|
||||||
//fflush(stderr);
|
//fprintf(stderr,"Initializing string cache..\n");
|
||||||
UnicodeString **newStrs = new UnicodeString*[UDBG_ENUM_COUNT+1];
|
//fflush(stderr);
|
||||||
for(int t=0;t<UDBG_ENUM_COUNT;t++) {
|
UnicodeString **newStrs = new UnicodeString*[UDBG_ENUM_COUNT+1];
|
||||||
int32_t c = udbg_enumCount((UDebugEnumType)t);
|
for(int t=0;t<UDBG_ENUM_COUNT;t++) {
|
||||||
newStrs[t] = new UnicodeString[c+1];
|
int32_t c = udbg_enumCount((UDebugEnumType)t);
|
||||||
for(int f=0;f<=c;f++) {
|
newStrs[t] = new UnicodeString[c+1];
|
||||||
_fieldString((UDebugEnumType)t, f, newStrs[t][f]);
|
for(int f=0;f<=c;f++) {
|
||||||
}
|
_fieldString((UDebugEnumType)t, f, newStrs[t][f]);
|
||||||
}
|
}
|
||||||
newStrs[UDBG_ENUM_COUNT] = new UnicodeString[1]; // empty string
|
}
|
||||||
|
newStrs[UDBG_ENUM_COUNT] = new UnicodeString[1]; // empty string
|
||||||
strs = newStrs;
|
|
||||||
}
|
strs = newStrs;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
T_CTEST_API const UnicodeString& T_CTEST_EXPORT2 udbg_enumString(UDebugEnumType type, int32_t field) {
|
|
||||||
if(strs == NULL ) {
|
T_CTEST_API const UnicodeString& T_CTEST_EXPORT2 udbg_enumString(UDebugEnumType type, int32_t field) {
|
||||||
udbg_setup();
|
if(strs == NULL ) {
|
||||||
}
|
udbg_setup();
|
||||||
if(type<0||type>=UDBG_ENUM_COUNT) {
|
}
|
||||||
// use UDBG_ENUM_COUNT,0 to mean an empty string
|
if(type<0||type>=UDBG_ENUM_COUNT) {
|
||||||
//fprintf(stderr, "** returning out of range on %d\n",type);
|
// use UDBG_ENUM_COUNT,0 to mean an empty string
|
||||||
//fflush(stderr);
|
//fprintf(stderr, "** returning out of range on %d\n",type);
|
||||||
return strs[UDBG_ENUM_COUNT][0];
|
//fflush(stderr);
|
||||||
}
|
return strs[UDBG_ENUM_COUNT][0];
|
||||||
int32_t count = udbg_enumCount(type);
|
}
|
||||||
//fprintf(stderr, "enumString [%d,%d]: typecount %d, fieldcount %d\n", type,field,UDBG_ENUM_COUNT,count);
|
int32_t count = udbg_enumCount(type);
|
||||||
//fflush(stderr);
|
//fprintf(stderr, "enumString [%d,%d]: typecount %d, fieldcount %d\n", type,field,UDBG_ENUM_COUNT,count);
|
||||||
if(field<0 || field > count) {
|
//fflush(stderr);
|
||||||
return strs[type][count];
|
if(field<0 || field > count) {
|
||||||
} else {
|
return strs[type][count];
|
||||||
return strs[type][field];
|
} else {
|
||||||
}
|
return strs[type][field];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumByString(UDebugEnumType type, const UnicodeString& string) {
|
|
||||||
if(type<0||type>=UDBG_ENUM_COUNT) {
|
T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumByString(UDebugEnumType type, const UnicodeString& string) {
|
||||||
return -1;
|
if(type<0||type>=UDBG_ENUM_COUNT) {
|
||||||
}
|
return -1;
|
||||||
// initialize array
|
}
|
||||||
udbg_enumString(type,0);
|
// initialize array
|
||||||
// search
|
udbg_enumString(type,0);
|
||||||
for(int i=0;i<udbg_enumCount(type);i++) {
|
// search
|
||||||
if(string == (strs[type][i])) {
|
for(int i=0;i<udbg_enumCount(type);i++) {
|
||||||
return i;
|
if(string == (strs[type][i])) {
|
||||||
}
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
}
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
// from DataMap::utoi
|
|
||||||
T_CTEST_API int32_t
|
// from DataMap::utoi
|
||||||
udbg_stoi(const UnicodeString &s)
|
T_CTEST_API int32_t
|
||||||
{
|
udbg_stoi(const UnicodeString &s)
|
||||||
char ch[256];
|
{
|
||||||
const UChar *u = s.getBuffer();
|
char ch[256];
|
||||||
int32_t len = s.length();
|
const UChar *u = s.getBuffer();
|
||||||
u_UCharsToChars(u, ch, len);
|
int32_t len = s.length();
|
||||||
ch[len] = 0; /* include terminating \0 */
|
u_UCharsToChars(u, ch, len);
|
||||||
return atoi(ch);
|
ch[len] = 0; /* include terminating \0 */
|
||||||
}
|
return atoi(ch);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user