Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: source/test/threadtest/converttest.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/threadtest/Makefile.in ('k') | source/test/threadtest/stringtest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //
2 //********************************************************************
3 // Copyright (C) 2002-2003, International Business Machines
4 // Corporation and others. All Rights Reserved.
5 //********************************************************************
6 //
7 // File converttest.cpp
8 //
9
10 #include "threadtest.h"
11 #include "unicode/utypes.h"
12 #include "unicode/ucnv.h"
13 #include "unicode/uclean.h"
14 #include "stdio.h"
15
16 U_CAPI UBool U_EXPORT2 ucnv_cleanup();
17
18 class ConvertThreadTest: public AbstractThreadTest {
19 public:
20 ConvertThreadTest();
21 virtual ~ConvertThreadTest();
22 virtual void check();
23 virtual void runOnce();
24
25 private:
26 UConverter *fCnv;
27 };
28
29
30 ConvertThreadTest::ConvertThreadTest() {
31 UErrorCode err = U_ZERO_ERROR;
32
33 fCnv = ucnv_open("gb18030", &err);
34 if (U_FAILURE(err)) {
35 fprintf(stderr, "ConvertTest - could not ucnv_open(\"gb18030\")\n");
36 fCnv = NULL;
37 }
38 };
39
40
41 ConvertThreadTest::~ConvertThreadTest() {
42 ucnv_close(fCnv);
43 fCnv = 0;
44 }
45
46 void ConvertThreadTest::runOnce() {
47 UErrorCode err = U_ZERO_ERROR;
48 UConverter *cnv1;
49 UConverter *cnv2;
50 char buf[U_CNV_SAFECLONE_BUFFERSIZE];
51 int32_t bufSize = U_CNV_SAFECLONE_BUFFERSIZE;
52
53 cnv1 = ucnv_open("shift_jis", &err);
54 if (U_FAILURE(err)) {
55 fprintf(stderr, "ucnv_open(\"shift_jis\") failed.\n");
56 }
57
58 cnv2 = ucnv_safeClone(fCnv, // The source converter, common to all thr eads.
59 buf,
60 &bufSize,
61 &err);
62 if (U_FAILURE(err)) {
63 fprintf(stderr, "ucnv_safeClone() failed.\n");
64 }
65 ucnv_close(cnv1);
66 ucnv_close(cnv2);
67 ucnv_flushCache();
68 }
69
70 void ConvertThreadTest::check() {
71 UErrorCode err = U_ZERO_ERROR;
72
73 if (fCnv) {ucnv_close(fCnv);}
74 //if (ucnv_cleanup () == FALSE) {
75 // fprintf(stderr, "ucnv_cleanup() failed - cache was not empty.\n");
76 //}
77 fCnv = ucnv_open("gb18030", &err);
78 if (U_FAILURE(err)) {
79 fprintf(stderr, "ConvertTest::check() - could not redo ucnv_open(\"gb180 30\")\n");
80 fCnv = NULL;
81 }
82 }
83
84
85 AbstractThreadTest *createConvertTest() {
86 return new ConvertThreadTest();
87 }
88
OLDNEW
« no previous file with comments | « source/test/threadtest/Makefile.in ('k') | source/test/threadtest/stringtest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698