From cae394378b7ddefca43f6f053d69616f6085bb73 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Fri, 22 Oct 1999 23:45:55 +0000 Subject: [PATCH] add euro regression test X-Trac-URL: https://ssl.icu-project.org/trac/ticket/38 git-svn-id: http://source.icu-project.org/repos/icu/icu/trunk@112 0a8b766c-62c9-45f9-954d-7f2943c9ead0 --- source/test/cintltst/Makefile.in | 2 +- source/test/cintltst/cconvtst.c | 3 +- source/test/cintltst/cintltst.dsp | 4 + source/test/cintltst/eurocreg.c | 145 ++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 source/test/cintltst/eurocreg.c diff --git a/source/test/cintltst/Makefile.in b/source/test/cintltst/Makefile.in index 5ea268dadd9..8e80ee5bd5b 100644 --- a/source/test/cintltst/Makefile.in +++ b/source/test/cintltst/Makefile.in @@ -60,7 +60,7 @@ cdattst.o cdetst.o cdtdptst.o cdtrgtst.o cestst.o cfintst.o cformtst.o \ cfrtst.o cg7coll.o cintltst.o citertst.o cjaptst.o cloctst.o cmsgtst.o \ cnmdptst.o cnormtst.o cnumtst.o cregrtst.o crestst.o cturtst.o \ cucdtst.o cutiltst.o encoll.o nucnvtst.o susctest.o nccbtst.o \ -cbiditst.o cbididat.o +cbiditst.o cbididat.o eurocreg.o DEPS = $(OBJECTS:.o=.d) diff --git a/source/test/cintltst/cconvtst.c b/source/test/cintltst/cconvtst.c index cb2afeeaeb5..e750b1865c1 100644 --- a/source/test/cintltst/cconvtst.c +++ b/source/test/cintltst/cconvtst.c @@ -23,11 +23,12 @@ void addTestConvert(TestNode**); void addTestNewConvert(TestNode**); void addTestConvertErrorCallBack(TestNode** root); +void addTestEuroRegression(TestNode** root); void addConvert(TestNode** root) { addTestConvert(root); addTestNewConvert(root); addTestConvertErrorCallBack(root); - + addTestEuroRegression(root); } diff --git a/source/test/cintltst/cintltst.dsp b/source/test/cintltst/cintltst.dsp index 49717cd82c1..f0184f6fa75 100644 --- a/source/test/cintltst/cintltst.dsp +++ b/source/test/cintltst/cintltst.dsp @@ -231,6 +231,10 @@ SOURCE=.\encoll.c # End Source File # Begin Source File +SOURCE=.\eurocreg.c +# End Source File +# Begin Source File + SOURCE=.\nccbtst.c # End Source File # Begin Source File diff --git a/source/test/cintltst/eurocreg.c b/source/test/cintltst/eurocreg.c new file mode 100644 index 00000000000..4cd81e6498b --- /dev/null +++ b/source/test/cintltst/eurocreg.c @@ -0,0 +1,145 @@ +#include "utypes.h" +#include "ustring.h" +#include "ctest.h" +#include "ucnv.h" +#include + +void TestEuroRegression(); +void addTestEuroRegression(TestNode** root) +{ + addTest(root, &TestEuroRegression, "tsconv/eurocreg/TestEuroRegression"); +} + +char convertersToCheck[][15] = { + "cp1250", + "cp1251", + "cp1252", + "cp1254", + "cp1255", + "cp1256", + "cp1257", + "cp1258", + "cp37", + "cp273", + "cp277", + "cp278", + "cp280", + "cp284", + "cp285", + "cp297", + "cp500", + "cp871", + "cp850", + "cp500", + "cp850", + "cp870", + "cp1026", + "cp857", + "cp1025", + "cp1123", + "cp1122", + "cp1112", + "cp424", + "cp803", + "cp862", + "cp9030", + "cp1130", + "cp1258", + "cp290", + "cp930", + "cp950", + "cp937", + "cp1253", + /* "cp819", + "cp13488",*/ + "cp875", + "cp869", + "cp813", + "cp852", + "cp855", + "cp866", + "cp1131", + "cp1125", + "cp922", + "cp921", + "cp420", + "cp864", + "cp1008", + "cp1046", + /* "cp9066", + "cp1129",*/ + "cp1027", + "cp300", + "cp939", + /* "cp4930", + "cp1364",*/ + "cp1362", + "cp1363", + "cp1114", + "cp947", + "cp28709", + "cp835", + ""}; + +bool_t isEuroAware(const UConverter*); + +void TestEuroRegression() +{ + int32_t i=0; + + do + { + UErrorCode err = U_ZERO_ERROR; + UConverter* myConv = ucnv_open(convertersToCheck[i], &err); + if (U_FAILURE(err)&&convertersToCheck[i][0]) log_err("%s \tMISSING\n", convertersToCheck[i]); + else + { + if (isEuroAware(myConv)) log_verbose("%s \tsupports euro\n", convertersToCheck[i]); + else log_err("%s \tDOES NOT support euro\n", convertersToCheck[i]); + ucnv_close(myConv); + } + } while (convertersToCheck[++i][0]); +} + +bool_t isEuroAware(const UConverter* myConv) +{ + static const UChar euroString[2] = { 0x20AC, 0x0000 }; + char target[2]; + UChar euroBack[2]; + int32_t targetSize, euroBackSize; + UErrorCode err = U_ZERO_ERROR; + const char* myName = ucnv_getName(myConv, &err); + + targetSize = ucnv_fromUChars(myConv, + target, + 2, + euroString, + &err); + if (U_FAILURE(err)) + { + log_err("Failure Occured in ucnv_fromUChars euro roundtrip test\n"); + return FALSE; + } + euroBackSize = ucnv_toUChars(myConv, + euroBack, + 2, + target, + targetSize, + &err); + if (U_FAILURE(err)) + { + log_err("Failure Occured in ucnv_toUChars euro roundtrip test\n"); + return FALSE; + } + if (u_strcmp(euroString, euroBack)) + { + /* log_err("%s FAILED Euro rountrip\n", myName);*/ + return FALSE; + } + else + { + /* log_verbose("%s PASSED Euro rountrip\n", myName);*/ + return TRUE; + } + +}