ICU-4707 Fix some compiler warnings.

X-SVN-Rev: 19783
This commit is contained in:
George Rhoten 2006-07-03 07:40:30 +00:00
parent 144e4c137c
commit 14289dfe22
2 changed files with 136 additions and 134 deletions

View File

@ -1,8 +1,8 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
* COPYRIGHT:
* Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
@ -13,166 +13,169 @@
U_NAMESPACE_USE
ContractionTableTest::ContractionTableTest() {
status = U_ZERO_ERROR;
/*testMapping = ucmpe32_open(0, 0, 0, &status);*/
testMapping = utrie_open(NULL, NULL, 0, 0, 0, TRUE);
testMapping = utrie_open(NULL, NULL, 0, 0, 0, TRUE);
}
ContractionTableTest::~ContractionTableTest() {
/*ucmpe32_close(testMapping);*/
utrie_close(testMapping);
utrie_close(testMapping);
}
void ContractionTableTest::TestGrowTable(/* char* par */) {
uint32_t i = 0, res = 0;
testTable = uprv_cnttab_open(testMapping, &status);
UErrorCode status = U_ZERO_ERROR;
uint32_t i = 0, res = 0;
testTable = uprv_cnttab_open(testMapping, &status);
// fill up one contraction so that it has to expand
for(i = 0; i<65536; i++) {
uprv_cnttab_addContraction(testTable, 0, (UChar)i, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
}
// test whether the filled up contraction really contains the data we input
if(U_SUCCESS(status)) {
// fill up one contraction so that it has to expand
for(i = 0; i<65536; i++) {
res = uprv_cnttab_getCE(testTable, 0, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
if(res != i) {
errln("Error: expected %i, got %i\n", i, res);
break;
}
uprv_cnttab_addContraction(testTable, 0, (UChar)i, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
}
}
uprv_cnttab_close(testTable);
// test whether the filled up contraction really contains the data we input
if(U_SUCCESS(status)) {
for(i = 0; i<65536; i++) {
res = uprv_cnttab_getCE(testTable, 0, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
if(res != i) {
errln("Error: expected %i, got %i\n", i, res);
break;
}
}
}
uprv_cnttab_close(testTable);
}
void ContractionTableTest::TestSetContraction(){
testTable = uprv_cnttab_open(testMapping, &status);
// This should make a new contraction
uprv_cnttab_setContraction(testTable, 1, 0, 0x41, 0x41, &status);
if(U_FAILURE(status)) {
errln("Error setting a non existing contraction error = %i (%s)\n", status, u_errorName(status));
}
// if we try to change the non existing offset, we should get an error
status = U_ZERO_ERROR;
// currently this tests whether there is enough space, maybe it should test whether the element is actually in
// range. Also, maybe a silent growing should take place....
uprv_cnttab_setContraction(testTable, 1, 0x401, 0x41, 0x41, &status);
if(status != U_INDEX_OUTOFBOUNDS_ERROR) {
errln("changing a non-existing offset should have resulted in an error\n");
}
status = U_ZERO_ERROR;
uprv_cnttab_close(testTable);
UErrorCode status = U_ZERO_ERROR;
testTable = uprv_cnttab_open(testMapping, &status);
// This should make a new contraction
uprv_cnttab_setContraction(testTable, 1, 0, 0x41, 0x41, &status);
if(U_FAILURE(status)) {
errln("Error setting a non existing contraction error = %i (%s)\n", status, u_errorName(status));
}
// if we try to change the non existing offset, we should get an error
status = U_ZERO_ERROR;
// currently this tests whether there is enough space, maybe it should test whether the element is actually in
// range. Also, maybe a silent growing should take place....
uprv_cnttab_setContraction(testTable, 1, 0x401, 0x41, 0x41, &status);
if(status != U_INDEX_OUTOFBOUNDS_ERROR) {
errln("changing a non-existing offset should have resulted in an error\n");
}
status = U_ZERO_ERROR;
uprv_cnttab_close(testTable);
}
void ContractionTableTest::TestAddATableElement(){
testTable = uprv_cnttab_open(testMapping, &status);
uint32_t i = 0, res = 0;
UErrorCode status = U_ZERO_ERROR;
testTable = uprv_cnttab_open(testMapping, &status);
uint32_t i = 0, res = 0;
// fill up one contraction so that it has to expand
for(i = 0; i<0x1000; i++) {
uprv_cnttab_addContraction(testTable, i, (UChar)i, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
}
// test whether the filled up contraction really contains the data we input
if(U_SUCCESS(status)) {
// fill up one contraction so that it has to expand
for(i = 0; i<0x1000; i++) {
res = uprv_cnttab_getCE(testTable, i, 0, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
if(res != i) {
errln("Error: expected %i, got %i\n", i, res);
break;
}
uprv_cnttab_addContraction(testTable, i, (UChar)i, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
}
}
uprv_cnttab_close(testTable);
// test whether the filled up contraction really contains the data we input
if(U_SUCCESS(status)) {
for(i = 0; i<0x1000; i++) {
res = uprv_cnttab_getCE(testTable, i, 0, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
if(res != i) {
errln("Error: expected %i, got %i\n", i, res);
break;
}
}
}
uprv_cnttab_close(testTable);
}
void ContractionTableTest::TestClone(){
testTable = uprv_cnttab_open(testMapping, &status);
int32_t i = 0, res = 0;
// we must construct table in order to copy codepoints and CEs
// fill up one contraction so that it has to expand
for(i = 0; i<0x500; i++) {
uprv_cnttab_addContraction(testTable, i, (UChar)i, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
}
uprv_cnttab_constructTable(testTable, 0, &status);
if(U_FAILURE(status)) {
errln("Error constructing table error = %i (%s)\n", status, u_errorName(status));
} else {
testClone = uprv_cnttab_clone(testTable, &status);
if(U_SUCCESS(status)) {
for(i = 0; i<0x500; i++) {
res = uprv_cnttab_getCE(testTable, i, 0, &status);
UErrorCode status = U_ZERO_ERROR;
testTable = uprv_cnttab_open(testMapping, &status);
int32_t i = 0, res = 0;
// we must construct table in order to copy codepoints and CEs
// fill up one contraction so that it has to expand
for(i = 0; i<0x500; i++) {
uprv_cnttab_addContraction(testTable, i, (UChar)i, i, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
if(res != i) {
errln("Error: expected %i, got %i\n", i, res);
break;
}
}
}
uprv_cnttab_close(testClone);
}
uprv_cnttab_close(testTable);
testTable = uprv_cnttab_open(testMapping, &status);
if(U_FAILURE(status)) {
errln("Error opening table error = %i (%s)\n", status, u_errorName(status));
}
uprv_cnttab_close(testTable);
uprv_cnttab_constructTable(testTable, 0, &status);
if(U_FAILURE(status)) {
errln("Error constructing table error = %i (%s)\n", status, u_errorName(status));
} else {
testClone = uprv_cnttab_clone(testTable, &status);
if(U_SUCCESS(status)) {
for(i = 0; i<0x500; i++) {
res = uprv_cnttab_getCE(testTable, i, 0, &status);
if(U_FAILURE(status)) {
errln("Error occurred at position %i, error = %i (%s)\n", i, status, u_errorName(status));
break;
}
if(res != i) {
errln("Error: expected %i, got %i\n", i, res);
break;
}
}
}
uprv_cnttab_close(testClone);
}
uprv_cnttab_close(testTable);
testTable = uprv_cnttab_open(testMapping, &status);
if(U_FAILURE(status)) {
errln("Error opening table error = %i (%s)\n", status, u_errorName(status));
}
uprv_cnttab_close(testTable);
}
void ContractionTableTest::TestChangeContraction(){
testTable = uprv_cnttab_open(testMapping, &status);
uint32_t i = 0, res = 0;
res = uprv_cnttab_changeContraction(testTable, 0, 0x41, 0xAB, &status);
if(res != 0) {
errln("found a non existing contraction!\n");
}
for(i = 0; i < 0x20; i+=2) {
uprv_cnttab_addContraction(testTable, 0, (UChar)i, i, &status);
}
res = uprv_cnttab_changeContraction(testTable, 0, 0x41, 0xAB, &status);
if(res != UCOL_NOT_FOUND) {
errln("managed to change a non existing contraction!\n");
}
for(i = 1; i < 0x20; i+=2) {
res = uprv_cnttab_changeContraction(testTable, 0, (UChar)i, 0xAB, &status);
if(res != UCOL_NOT_FOUND) {
errln("managed to change a non existing contraction!\n");
UErrorCode status = U_ZERO_ERROR;
testTable = uprv_cnttab_open(testMapping, &status);
uint32_t i = 0, res = 0;
res = uprv_cnttab_changeContraction(testTable, 0, 0x41, 0xAB, &status);
if(res != 0) {
errln("found a non existing contraction!\n");
}
}
uprv_cnttab_close(testTable);
for(i = 0; i < 0x20; i+=2) {
uprv_cnttab_addContraction(testTable, 0, (UChar)i, i, &status);
}
res = uprv_cnttab_changeContraction(testTable, 0, 0x41, 0xAB, &status);
if(res != UCOL_NOT_FOUND) {
errln("managed to change a non existing contraction!\n");
}
for(i = 1; i < 0x20; i+=2) {
res = uprv_cnttab_changeContraction(testTable, 0, (UChar)i, 0xAB, &status);
if(res != UCOL_NOT_FOUND) {
errln("managed to change a non existing contraction!\n");
}
}
uprv_cnttab_close(testTable);
}
void ContractionTableTest::TestChangeLastCE(){
testTable = uprv_cnttab_open(testMapping, &status);
uint32_t res = uprv_cnttab_changeLastCE(testTable, 1, 0xABCD, &status);
if(res!=0) {
errln("managed to change the last CE in an non-existing contraction!\n");
}
uprv_cnttab_close(testTable);
UErrorCode status = U_ZERO_ERROR;
testTable = uprv_cnttab_open(testMapping, &status);
uint32_t res = uprv_cnttab_changeLastCE(testTable, 1, 0xABCD, &status);
if(res!=0) {
errln("managed to change the last CE in an non-existing contraction!\n");
}
uprv_cnttab_close(testTable);
}
void ContractionTableTest::TestErrorCodeChecking(){

View File

@ -34,7 +34,6 @@ private:
CntTable *testTable, *testClone;
/*CompactEIntArray *testMapping;*/
UNewTrie *testMapping;
UErrorCode status;
};
#endif /* #if !UCONFIG_NO_COLLATION */