1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4 * COPYRIGHT:
5 * Copyright (c) 1997-2015, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /* file name: strtest.cpp
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 1999nov22
14 * created by: Markus W. Scherer
15 */
16
17 #include <string.h>
18
19 #include "unicode/utypes.h"
20 #include "unicode/putil.h"
21 #include "unicode/std_string.h"
22 #include "unicode/stringpiece.h"
23 #include "unicode/unistr.h"
24 #include "unicode/ustring.h"
25 #include "charstr.h"
26 #include "cstr.h"
27 #include "intltest.h"
28 #include "strtest.h"
29
~StringTest()30 StringTest::~StringTest() {}
31
TestEndian(void)32 void StringTest::TestEndian(void) {
33 union {
34 uint8_t byte;
35 uint16_t word;
36 } u;
37 u.word=0x0100;
38 if(U_IS_BIG_ENDIAN!=u.byte) {
39 errln("TestEndian: U_IS_BIG_ENDIAN needs to be fixed in platform.h");
40 }
41 }
42
TestSizeofTypes(void)43 void StringTest::TestSizeofTypes(void) {
44 if(U_SIZEOF_WCHAR_T!=sizeof(wchar_t)) {
45 errln("TestSizeofWCharT: U_SIZEOF_WCHAR_T!=sizeof(wchar_t) - U_SIZEOF_WCHAR_T needs to be fixed in platform.h");
46 }
47 #ifdef U_INT64_T_UNAVAILABLE
48 errln("int64_t and uint64_t are undefined.");
49 #else
50 if(8!=sizeof(int64_t)) {
51 errln("TestSizeofTypes: 8!=sizeof(int64_t) - int64_t needs to be fixed in platform.h");
52 }
53 if(8!=sizeof(uint64_t)) {
54 errln("TestSizeofTypes: 8!=sizeof(uint64_t) - uint64_t needs to be fixed in platform.h");
55 }
56 #endif
57 if(8!=sizeof(double)) {
58 errln("8!=sizeof(double) - putil.c code may not work");
59 }
60 if(4!=sizeof(int32_t)) {
61 errln("4!=sizeof(int32_t)");
62 }
63 if(4!=sizeof(uint32_t)) {
64 errln("4!=sizeof(uint32_t)");
65 }
66 if(2!=sizeof(int16_t)) {
67 errln("2!=sizeof(int16_t)");
68 }
69 if(2!=sizeof(uint16_t)) {
70 errln("2!=sizeof(uint16_t)");
71 }
72 if(2!=sizeof(UChar)) {
73 errln("2!=sizeof(UChar)");
74 }
75 if(1!=sizeof(int8_t)) {
76 errln("1!=sizeof(int8_t)");
77 }
78 if(1!=sizeof(uint8_t)) {
79 errln("1!=sizeof(uint8_t)");
80 }
81 if(1!=sizeof(UBool)) {
82 errln("1!=sizeof(UBool)");
83 }
84 }
85
TestCharsetFamily(void)86 void StringTest::TestCharsetFamily(void) {
87 unsigned char c='A';
88 if( (U_CHARSET_FAMILY==U_ASCII_FAMILY && c!=0x41) ||
89 (U_CHARSET_FAMILY==U_EBCDIC_FAMILY && c!=0xc1)
90 ) {
91 errln("TestCharsetFamily: U_CHARSET_FAMILY needs to be fixed in platform.h");
92 }
93 }
94
95 U_STRING_DECL(ustringVar, "aZ0 -", 5);
96
97 void
Test_U_STRING()98 StringTest::Test_U_STRING() {
99 U_STRING_INIT(ustringVar, "aZ0 -", 5);
100 if( u_strlen(ustringVar)!=5 ||
101 ustringVar[0]!=0x61 ||
102 ustringVar[1]!=0x5a ||
103 ustringVar[2]!=0x30 ||
104 ustringVar[3]!=0x20 ||
105 ustringVar[4]!=0x2d ||
106 ustringVar[5]!=0
107 ) {
108 errln("Test_U_STRING: U_STRING_DECL with U_STRING_INIT does not work right! "
109 "See putil.h and utypes.h with platform.h.");
110 }
111 }
112
113 void
Test_UNICODE_STRING()114 StringTest::Test_UNICODE_STRING() {
115 UnicodeString ustringVar=UNICODE_STRING("aZ0 -", 5);
116 if( ustringVar.length()!=5 ||
117 ustringVar[0]!=0x61 ||
118 ustringVar[1]!=0x5a ||
119 ustringVar[2]!=0x30 ||
120 ustringVar[3]!=0x20 ||
121 ustringVar[4]!=0x2d
122 ) {
123 errln("Test_UNICODE_STRING: UNICODE_STRING does not work right! "
124 "See unistr.h and utypes.h with platform.h.");
125 }
126 }
127
128 void
Test_UNICODE_STRING_SIMPLE()129 StringTest::Test_UNICODE_STRING_SIMPLE() {
130 UnicodeString ustringVar=UNICODE_STRING_SIMPLE("aZ0 -");
131 if( ustringVar.length()!=5 ||
132 ustringVar[0]!=0x61 ||
133 ustringVar[1]!=0x5a ||
134 ustringVar[2]!=0x30 ||
135 ustringVar[3]!=0x20 ||
136 ustringVar[4]!=0x2d
137 ) {
138 errln("Test_UNICODE_STRING_SIMPLE: UNICODE_STRING_SIMPLE does not work right! "
139 "See unistr.h and utypes.h with platform.h.");
140 }
141 }
142
143 void
Test_UTF8_COUNT_TRAIL_BYTES()144 StringTest::Test_UTF8_COUNT_TRAIL_BYTES() {
145 if(UTF8_COUNT_TRAIL_BYTES(0x7F) != 0
146 || UTF8_COUNT_TRAIL_BYTES(0xC0) != 1
147 || UTF8_COUNT_TRAIL_BYTES(0xE0) != 2
148 || UTF8_COUNT_TRAIL_BYTES(0xF0) != 3)
149 {
150 errln("Test_UTF8_COUNT_TRAIL_BYTES: UTF8_COUNT_TRAIL_BYTES does not work right! "
151 "See utf8.h.");
152 }
153 }
154
runIndexedTest(int32_t index,UBool exec,const char * & name,char *)155 void StringTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
156 if(exec) {
157 logln("TestSuite Character and String Test: ");
158 }
159 TESTCASE_AUTO_BEGIN;
160 TESTCASE_AUTO(TestEndian);
161 TESTCASE_AUTO(TestSizeofTypes);
162 TESTCASE_AUTO(TestCharsetFamily);
163 TESTCASE_AUTO(Test_U_STRING);
164 TESTCASE_AUTO(Test_UNICODE_STRING);
165 TESTCASE_AUTO(Test_UNICODE_STRING_SIMPLE);
166 TESTCASE_AUTO(Test_UTF8_COUNT_TRAIL_BYTES);
167 TESTCASE_AUTO(TestSTLCompatibility);
168 TESTCASE_AUTO(TestStringPiece);
169 TESTCASE_AUTO(TestStringPieceComparisons);
170 TESTCASE_AUTO(TestByteSink);
171 TESTCASE_AUTO(TestCheckedArrayByteSink);
172 TESTCASE_AUTO(TestStringByteSink);
173 TESTCASE_AUTO(TestCharString);
174 TESTCASE_AUTO(TestCStr);
175 TESTCASE_AUTO(Testctou);
176 TESTCASE_AUTO_END;
177 }
178
179 void
TestStringPiece()180 StringTest::TestStringPiece() {
181 // Default constructor.
182 StringPiece empty;
183 if(!empty.empty() || empty.data()!=NULL || empty.length()!=0 || empty.size()!=0) {
184 errln("StringPiece() failed");
185 }
186 // Construct from NULL const char * pointer.
187 StringPiece null(NULL);
188 if(!null.empty() || null.data()!=NULL || null.length()!=0 || null.size()!=0) {
189 errln("StringPiece(NULL) failed");
190 }
191 // Construct from const char * pointer.
192 static const char *abc_chars="abc";
193 StringPiece abc(abc_chars);
194 if(abc.empty() || abc.data()!=abc_chars || abc.length()!=3 || abc.size()!=3) {
195 errln("StringPiece(abc_chars) failed");
196 }
197 // Construct from const char * pointer and length.
198 static const char *abcdefg_chars="abcdefg";
199 StringPiece abcd(abcdefg_chars, 4);
200 if(abcd.empty() || abcd.data()!=abcdefg_chars || abcd.length()!=4 || abcd.size()!=4) {
201 errln("StringPiece(abcdefg_chars, 4) failed");
202 }
203 #if U_HAVE_STD_STRING
204 // Construct from std::string.
205 std::string uvwxyz_string("uvwxyz");
206 StringPiece uvwxyz(uvwxyz_string);
207 if(uvwxyz.empty() || uvwxyz.data()!=uvwxyz_string.data() || uvwxyz.length()!=6 || uvwxyz.size()!=6) {
208 errln("StringPiece(uvwxyz_string) failed");
209 }
210 #endif
211 // Substring constructor with pos.
212 StringPiece sp(abcd, -1);
213 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
214 errln("StringPiece(abcd, -1) failed");
215 }
216 sp=StringPiece(abcd, 5);
217 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
218 errln("StringPiece(abcd, 5) failed");
219 }
220 sp=StringPiece(abcd, 2);
221 if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
222 errln("StringPiece(abcd, -1) failed");
223 }
224 // Substring constructor with pos and len.
225 sp=StringPiece(abcd, -1, 8);
226 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
227 errln("StringPiece(abcd, -1, 8) failed");
228 }
229 sp=StringPiece(abcd, 5, 8);
230 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
231 errln("StringPiece(abcd, 5, 8) failed");
232 }
233 sp=StringPiece(abcd, 2, 8);
234 if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
235 errln("StringPiece(abcd, -1) failed");
236 }
237 sp=StringPiece(abcd, 2, -1);
238 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
239 errln("StringPiece(abcd, 5, -1) failed");
240 }
241 // static const npos
242 const int32_t *ptr_npos=&StringPiece::npos;
243 if(StringPiece::npos!=0x7fffffff || *ptr_npos!=0x7fffffff) {
244 errln("StringPiece::npos!=0x7fffffff");
245 }
246 // substr() method with pos, using len=npos.
247 sp=abcd.substr(-1);
248 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
249 errln("abcd.substr(-1) failed");
250 }
251 sp=abcd.substr(5);
252 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
253 errln("abcd.substr(5) failed");
254 }
255 sp=abcd.substr(2);
256 if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
257 errln("abcd.substr(-1) failed");
258 }
259 // substr() method with pos and len.
260 sp=abcd.substr(-1, 8);
261 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
262 errln("abcd.substr(-1, 8) failed");
263 }
264 sp=abcd.substr(5, 8);
265 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
266 errln("abcd.substr(5, 8) failed");
267 }
268 sp=abcd.substr(2, 8);
269 if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
270 errln("abcd.substr(-1) failed");
271 }
272 sp=abcd.substr(2, -1);
273 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
274 errln("abcd.substr(5, -1) failed");
275 }
276 // clear()
277 sp=abcd;
278 sp.clear();
279 if(!sp.empty() || sp.data()!=NULL || sp.length()!=0 || sp.size()!=0) {
280 errln("abcd.clear() failed");
281 }
282 // remove_prefix()
283 sp=abcd;
284 sp.remove_prefix(-1);
285 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
286 errln("abcd.remove_prefix(-1) failed");
287 }
288 sp=abcd;
289 sp.remove_prefix(2);
290 if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
291 errln("abcd.remove_prefix(2) failed");
292 }
293 sp=abcd;
294 sp.remove_prefix(5);
295 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
296 errln("abcd.remove_prefix(5) failed");
297 }
298 // remove_suffix()
299 sp=abcd;
300 sp.remove_suffix(-1);
301 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
302 errln("abcd.remove_suffix(-1) failed");
303 }
304 sp=abcd;
305 sp.remove_suffix(2);
306 if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=2 || sp.size()!=2) {
307 errln("abcd.remove_suffix(2) failed");
308 }
309 sp=abcd;
310 sp.remove_suffix(5);
311 if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
312 errln("abcd.remove_suffix(5) failed");
313 }
314 }
315
316 void
TestStringPieceComparisons()317 StringTest::TestStringPieceComparisons() {
318 StringPiece empty;
319 StringPiece null(NULL);
320 StringPiece abc("abc");
321 StringPiece abcd("abcdefg", 4);
322 StringPiece abx("abx");
323 if(empty!=null) {
324 errln("empty!=null");
325 }
326 if(empty==abc) {
327 errln("empty==abc");
328 }
329 if(abc==abcd) {
330 errln("abc==abcd");
331 }
332 abcd.remove_suffix(1);
333 if(abc!=abcd) {
334 errln("abc!=abcd.remove_suffix(1)");
335 }
336 if(abc==abx) {
337 errln("abc==abx");
338 }
339 }
340
341 // Verify that ByteSink is subclassable and Flush() overridable.
342 class SimpleByteSink : public ByteSink {
343 public:
SimpleByteSink(char * outbuf)344 SimpleByteSink(char *outbuf) : fOutbuf(outbuf), fLength(0) {}
Append(const char * bytes,int32_t n)345 virtual void Append(const char *bytes, int32_t n) {
346 if(fOutbuf != bytes) {
347 memcpy(fOutbuf, bytes, n);
348 }
349 fOutbuf += n;
350 fLength += n;
351 }
Flush()352 virtual void Flush() { Append("z", 1); }
length()353 int32_t length() { return fLength; }
354 private:
355 char *fOutbuf;
356 int32_t fLength;
357 };
358
359 // Test the ByteSink base class.
360 void
TestByteSink()361 StringTest::TestByteSink() {
362 char buffer[20];
363 buffer[4] = '!';
364 SimpleByteSink sink(buffer);
365 sink.Append("abc", 3);
366 sink.Flush();
367 if(!(sink.length() == 4 && 0 == memcmp("abcz", buffer, 4) && buffer[4] == '!')) {
368 errln("ByteSink (SimpleByteSink) did not Append() or Flush() as expected");
369 return;
370 }
371 char scratch[20];
372 int32_t capacity = -1;
373 char *dest = sink.GetAppendBuffer(0, 50, scratch, (int32_t)sizeof(scratch), &capacity);
374 if(dest != NULL || capacity != 0) {
375 errln("ByteSink.GetAppendBuffer(min_capacity<1) did not properly return NULL[0]");
376 return;
377 }
378 dest = sink.GetAppendBuffer(10, 50, scratch, 9, &capacity);
379 if(dest != NULL || capacity != 0) {
380 errln("ByteSink.GetAppendBuffer(scratch_capacity<min_capacity) did not properly return NULL[0]");
381 return;
382 }
383 dest = sink.GetAppendBuffer(5, 50, scratch, (int32_t)sizeof(scratch), &capacity);
384 if(dest != scratch || capacity != (int32_t)sizeof(scratch)) {
385 errln("ByteSink.GetAppendBuffer() did not properly return the scratch buffer");
386 }
387 }
388
389 void
TestCheckedArrayByteSink()390 StringTest::TestCheckedArrayByteSink() {
391 char buffer[20]; // < 26 for the test code to work
392 buffer[3] = '!';
393 CheckedArrayByteSink sink(buffer, (int32_t)sizeof(buffer));
394 sink.Append("abc", 3);
395 if(!(sink.NumberOfBytesAppended() == 3 && sink.NumberOfBytesWritten() == 3 &&
396 0 == memcmp("abc", buffer, 3) && buffer[3] == '!') &&
397 !sink.Overflowed()
398 ) {
399 errln("CheckedArrayByteSink did not Append() as expected");
400 return;
401 }
402 char scratch[10];
403 int32_t capacity = -1;
404 char *dest = sink.GetAppendBuffer(0, 50, scratch, (int32_t)sizeof(scratch), &capacity);
405 if(dest != NULL || capacity != 0) {
406 errln("CheckedArrayByteSink.GetAppendBuffer(min_capacity<1) did not properly return NULL[0]");
407 return;
408 }
409 dest = sink.GetAppendBuffer(10, 50, scratch, 9, &capacity);
410 if(dest != NULL || capacity != 0) {
411 errln("CheckedArrayByteSink.GetAppendBuffer(scratch_capacity<min_capacity) did not properly return NULL[0]");
412 return;
413 }
414 dest = sink.GetAppendBuffer(10, 50, scratch, (int32_t)sizeof(scratch), &capacity);
415 if(dest != buffer + 3 || capacity != (int32_t)sizeof(buffer) - 3) {
416 errln("CheckedArrayByteSink.GetAppendBuffer() did not properly return its own buffer");
417 return;
418 }
419 memcpy(dest, "defghijklm", 10);
420 sink.Append(dest, 10);
421 if(!(sink.NumberOfBytesAppended() == 13 && sink.NumberOfBytesWritten() == 13 &&
422 0 == memcmp("abcdefghijklm", buffer, 13) &&
423 !sink.Overflowed())
424 ) {
425 errln("CheckedArrayByteSink did not Append(its own buffer) as expected");
426 return;
427 }
428 dest = sink.GetAppendBuffer(10, 50, scratch, (int32_t)sizeof(scratch), &capacity);
429 if(dest != scratch || capacity != (int32_t)sizeof(scratch)) {
430 errln("CheckedArrayByteSink.GetAppendBuffer() did not properly return the scratch buffer");
431 }
432 memcpy(dest, "nopqrstuvw", 10);
433 sink.Append(dest, 10);
434 if(!(sink.NumberOfBytesAppended() == 23 &&
435 sink.NumberOfBytesWritten() == (int32_t)sizeof(buffer) &&
436 0 == memcmp("abcdefghijklmnopqrstuvwxyz", buffer, (int32_t)sizeof(buffer)) &&
437 sink.Overflowed())
438 ) {
439 errln("CheckedArrayByteSink did not Append(scratch buffer) as expected");
440 return;
441 }
442 sink.Reset().Append("123", 3);
443 if(!(sink.NumberOfBytesAppended() == 3 && sink.NumberOfBytesWritten() == 3 &&
444 0 == memcmp("123defghijklmnopqrstuvwxyz", buffer, (int32_t)sizeof(buffer)) &&
445 !sink.Overflowed())
446 ) {
447 errln("CheckedArrayByteSink did not Reset().Append() as expected");
448 return;
449 }
450 }
451
452 void
TestStringByteSink()453 StringTest::TestStringByteSink() {
454 #if U_HAVE_STD_STRING
455 // Not much to test because only the constructor and Append()
456 // are implemented, and trivially so.
457 std::string result("abc"); // std::string
458 StringByteSink<std::string> sink(&result);
459 sink.Append("def", 3);
460 if(result != "abcdef") {
461 errln("StringByteSink did not Append() as expected");
462 }
463 #endif
464 }
465
466 #if defined(_MSC_VER)
467 #include <vector>
468 #endif
469
470 void
TestSTLCompatibility()471 StringTest::TestSTLCompatibility() {
472 #if defined(_MSC_VER)
473 /* Just make sure that it compiles with STL's placement new usage. */
474 std::vector<UnicodeString> myvect;
475 myvect.push_back(UnicodeString("blah"));
476 #endif
477 }
478
479 void
TestCharString()480 StringTest::TestCharString() {
481 IcuTestErrorCode errorCode(*this, "TestCharString()");
482 char expected[400];
483 static const char longStr[] =
484 "This is a long string that is meant to cause reallocation of the internal buffer of CharString.";
485 CharString chStr(longStr, errorCode);
486 if (0 != strcmp(longStr, chStr.data()) || (int32_t)strlen(longStr) != chStr.length()) {
487 errln("CharString(longStr) failed.");
488 }
489 CharString test("Test", errorCode);
490 CharString copy(test,errorCode);
491 copy.copyFrom(chStr, errorCode);
492 if (0 != strcmp(longStr, copy.data()) || (int32_t)strlen(longStr) != copy.length()) {
493 errln("CharString.copyFrom() failed.");
494 }
495 StringPiece sp(chStr.toStringPiece());
496 sp.remove_prefix(4);
497 chStr.append(sp, errorCode).append(chStr, errorCode);
498 strcpy(expected, longStr);
499 strcat(expected, longStr+4);
500 strcat(expected, longStr);
501 strcat(expected, longStr+4);
502 if (0 != strcmp(expected, chStr.data()) || (int32_t)strlen(expected) != chStr.length()) {
503 errln("CharString(longStr).append(substring of self).append(self) failed.");
504 }
505 chStr.clear().append("abc", errorCode).append("defghij", 3, errorCode);
506 if (0 != strcmp("abcdef", chStr.data()) || 6 != chStr.length()) {
507 errln("CharString.clear().append(abc).append(defghij, 3) failed.");
508 }
509 chStr.appendInvariantChars(UNICODE_STRING_SIMPLE(
510 "This is a long string that is meant to cause reallocation of the internal buffer of CharString."),
511 errorCode);
512 strcpy(expected, "abcdef");
513 strcat(expected, longStr);
514 if (0 != strcmp(expected, chStr.data()) || (int32_t)strlen(expected) != chStr.length()) {
515 errln("CharString.appendInvariantChars(longStr) failed.");
516 }
517 int32_t appendCapacity = 0;
518 char *buffer = chStr.getAppendBuffer(5, 10, appendCapacity, errorCode);
519 if (errorCode.isFailure()) {
520 return;
521 }
522 memcpy(buffer, "*****", 5);
523 chStr.append(buffer, 5, errorCode);
524 chStr.truncate(chStr.length()-3);
525 strcat(expected, "**");
526 if (0 != strcmp(expected, chStr.data()) || (int32_t)strlen(expected) != chStr.length()) {
527 errln("CharString.getAppendBuffer().append(**) failed.");
528 }
529
530 UErrorCode ec = U_ZERO_ERROR;
531 chStr.clear();
532 chStr.appendInvariantChars(UnicodeString("The '@' character is not invariant."), ec);
533 if (ec != U_INVARIANT_CONVERSION_ERROR) {
534 errln("%s:%d expected U_INVARIANT_CONVERSION_ERROR, got %s", __FILE__, __LINE__, u_errorName(ec));
535 }
536 if (chStr.length() != 0) {
537 errln("%s:%d expected length() = 0, got %d", __FILE__, __LINE__, chStr.length());
538 }
539 }
540
541 void
TestCStr()542 StringTest::TestCStr() {
543 const char *cs = "This is a test string.";
544 UnicodeString us(cs);
545 if (0 != strcmp(CStr(us)(), cs)) {
546 errln("%s:%d CStr(s)() failed. Expected \"%s\", got \"%s\"", __FILE__, __LINE__, cs, CStr(us)());
547 }
548 }
549
550 void
Testctou()551 StringTest::Testctou() {
552 const char *cs = "Fa\\u0127mu";
553 UnicodeString u = ctou(cs);
554 assertEquals("Testing unescape@0", (int32_t)0x0046, u.charAt(0));
555 assertEquals("Testing unescape@2", (int32_t)295, u.charAt(2));
556 }
557