2 //********************************************************************
3 // Copyright (C) 2002-2003, International Business Machines
4 // Corporation and others. All Rights Reserved.
5 //********************************************************************
7 // File converttest.cpp
10 #include "threadtest.h"
11 #include "unicode/utypes.h"
12 #include "unicode/ucnv.h"
13 #include "unicode/uclean.h"
16 U_CAPI UBool U_EXPORT2
ucnv_cleanup();
18 class ConvertThreadTest
: public AbstractThreadTest
{
21 virtual ~ConvertThreadTest();
23 virtual void runOnce();
30 ConvertThreadTest::ConvertThreadTest() {
31 UErrorCode err
= U_ZERO_ERROR
;
33 fCnv
= ucnv_open("gb18030", &err
);
35 fprintf(stderr
, "ConvertTest - could not ucnv_open(\"gb18030\")\n");
41 ConvertThreadTest::~ConvertThreadTest() {
46 void ConvertThreadTest::runOnce() {
47 UErrorCode err
= U_ZERO_ERROR
;
50 char buf
[U_CNV_SAFECLONE_BUFFERSIZE
];
51 int32_t bufSize
= U_CNV_SAFECLONE_BUFFERSIZE
;
53 cnv1
= ucnv_open("shift_jis", &err
);
55 fprintf(stderr
, "ucnv_open(\"shift_jis\") failed.\n");
58 cnv2
= ucnv_safeClone(fCnv
, // The source converter, common to all threads.
63 fprintf(stderr
, "ucnv_safeClone() failed.\n");
70 void ConvertThreadTest::check() {
71 UErrorCode err
= U_ZERO_ERROR
;
73 if (fCnv
) {ucnv_close(fCnv
);}
74 //if (ucnv_cleanup () == FALSE) {
75 // fprintf(stderr, "ucnv_cleanup() failed - cache was not empty.\n");
77 fCnv
= ucnv_open("gb18030", &err
);
79 fprintf(stderr
, "ConvertTest::check() - could not redo ucnv_open(\"gb18030\")\n");
85 AbstractThreadTest
*createConvertTest() {
86 return new ConvertThreadTest();