summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-xetex/test/threadtest/converttest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu/icu-xetex/test/threadtest/converttest.cpp')
-rw-r--r--Build/source/libs/icu/icu-xetex/test/threadtest/converttest.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-xetex/test/threadtest/converttest.cpp b/Build/source/libs/icu/icu-xetex/test/threadtest/converttest.cpp
new file mode 100644
index 00000000000..8de22efa786
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/test/threadtest/converttest.cpp
@@ -0,0 +1,88 @@
+//
+//********************************************************************
+// Copyright (C) 2002-2003, International Business Machines
+// Corporation and others. All Rights Reserved.
+//********************************************************************
+//
+// File converttest.cpp
+//
+
+#include "threadtest.h"
+#include "unicode/utypes.h"
+#include "unicode/ucnv.h"
+#include "unicode/uclean.h"
+#include "stdio.h"
+
+U_CAPI UBool U_EXPORT2 ucnv_cleanup();
+
+class ConvertThreadTest: public AbstractThreadTest {
+public:
+ ConvertThreadTest();
+ virtual ~ConvertThreadTest();
+ virtual void check();
+ virtual void runOnce();
+
+private:
+ UConverter *fCnv;
+};
+
+
+ConvertThreadTest::ConvertThreadTest() {
+ UErrorCode err = U_ZERO_ERROR;
+
+ fCnv = ucnv_open("gb18030", &err);
+ if (U_FAILURE(err)) {
+ fprintf(stderr, "ConvertTest - could not ucnv_open(\"gb18030\")\n");
+ fCnv = NULL;
+ }
+};
+
+
+ConvertThreadTest::~ConvertThreadTest() {
+ ucnv_close(fCnv);
+ fCnv = 0;
+}
+
+void ConvertThreadTest::runOnce() {
+ UErrorCode err = U_ZERO_ERROR;
+ UConverter *cnv1;
+ UConverter *cnv2;
+ char buf[U_CNV_SAFECLONE_BUFFERSIZE];
+ int32_t bufSize = U_CNV_SAFECLONE_BUFFERSIZE;
+
+ cnv1 = ucnv_open("shift_jis", &err);
+ if (U_FAILURE(err)) {
+ fprintf(stderr, "ucnv_open(\"shift_jis\") failed.\n");
+ }
+
+ cnv2 = ucnv_safeClone(fCnv, // The source converter, common to all threads.
+ buf,
+ &bufSize,
+ &err);
+ if (U_FAILURE(err)) {
+ fprintf(stderr, "ucnv_safeClone() failed.\n");
+ }
+ ucnv_close(cnv1);
+ ucnv_close(cnv2);
+ ucnv_flushCache();
+}
+
+void ConvertThreadTest::check() {
+ UErrorCode err = U_ZERO_ERROR;
+
+ if (fCnv) {ucnv_close(fCnv);}
+ //if (ucnv_cleanup () == FALSE) {
+ // fprintf(stderr, "ucnv_cleanup() failed - cache was not empty.\n");
+ //}
+ fCnv = ucnv_open("gb18030", &err);
+ if (U_FAILURE(err)) {
+ fprintf(stderr, "ConvertTest::check() - could not redo ucnv_open(\"gb18030\")\n");
+ fCnv = NULL;
+ }
+}
+
+
+AbstractThreadTest *createConvertTest() {
+ return new ConvertThreadTest();
+}
+