1351 */ |
1351 */ |
1352 |
1352 |
1353 LOCAL_C void testSurrogateAwareInterfaces() |
1353 LOCAL_C void testSurrogateAwareInterfaces() |
1354 { |
1354 { |
1355 test.Next(_L("new TDesC interfaces")); |
1355 test.Next(_L("new TDesC interfaces")); |
1356 TInt count; |
|
1357 |
|
1358 // string 1: all BMP characters |
|
1359 _LIT(KBmpString1, "abcdcf"); |
|
1360 TBuf16<128> s01(KBmpString1); |
|
1361 test(s01.FindCorruptSurrogate() == KErrNotFound); |
|
1362 test(s01.Locate2('f') == 5); |
|
1363 test(s01.LocateReverse2('c') == 4); |
|
1364 test(s01.Match(_L("*cdc*")) == 2); |
|
1365 test(s01.Match2(_L("*bcdc*")) == 1); |
|
1366 test(s01.Match2(_L("*c?c*")) == 2); |
|
1367 |
|
1368 // string 2: all non-BMP characters |
|
1369 _LIT(KSurrogateString1, "\xD840\xDDAA\xD840\xDDAB\xD840\xDDAC\xD840\xDDAD\xD840\xDDAE\xD840\xDDAF"); |
|
1370 TBuf16<128> s02(KSurrogateString1); |
|
1371 for (count=0; count<=11; count++) |
|
1372 test(s02.FindCorruptSurrogate() == KErrNotFound); |
|
1373 test(s02.Locate2(0x201AE) == 8); |
|
1374 test(s02.LocateReverse2(0x201AC) == 4); |
|
1375 test(s02.Match2(_L("*\xD840\xDDAB\xD840\xDDAC*")) == 2); |
|
1376 test(s02.Match2(_L("*\xD840\xDDBB*")) == KErrNotFound); |
|
1377 test(s02.Match2(_L("*\xD840\xDDAD*")) == 6); |
|
1378 |
|
1379 // string 3: mixed |
|
1380 _LIT(KMixedString1, "ab\xD840\xDDAD e\xD801\xDC27"); |
|
1381 TBuf16<128> s03(KMixedString1); |
|
1382 test(s03.FindCorruptSurrogate() == KErrNotFound); |
|
1383 test(s03.Locate2(0x10427) == 6); |
|
1384 test(s03.Locate2('e') == 5); |
|
1385 test(s03.LocateF2(0x1044F) == 6); // lower case=U+1044F(D801, DC4F), upper case=U+10427(D801, DC27), title case=U+10427 |
|
1386 TBuf16<128> s03a; |
|
1387 s03a.CopyLC2(s03); |
|
1388 s03a.Append2(0x21000); |
|
1389 TBuf16<128> s03b; |
|
1390 s03b.Copy(s03); |
|
1391 |
|
1392 s03b.AppendFill2(0x21000, 2); |
|
1393 test(s03a != s03b); |
|
1394 test(s03.Match2(_L("*b\xD840\xDDAD*")) == 1); |
|
1395 test(s03.Match2(_L("* e*")) == 4); |
|
1396 test(s03.Match2(_L("*\xD840\xDDAD?*")) == 2); |
|
1397 |
|
1398 // string 4: mixed, with corrupt surrogate |
|
1399 _LIT(KCorruptString1, "ab\xD840\xDDAD e\xDDAD\xD840"); |
|
1400 TBuf16<128> s04(KCorruptString1); |
|
1401 test(s04.FindCorruptSurrogate() == 6); |
|
1402 |
|
1403 // string 5: fill |
|
1404 _LIT(KOddString5, "0123456"); |
|
1405 TBuf16<128> s05(KOddString5); |
|
1406 s05.Fill2(0x21000); |
|
1407 test(s05 == _L("\xD844\xDC00\xD844\xDC00\xD844\xDC00\xD844")); |
|
1408 s05.Fill2(' '); |
|
1409 test(s05 == _L(" ")); |
|
1410 s05.AppendFill2(0x22222, 2); |
|
1411 s05.AppendFill2(0x22222, 3); |
|
1412 test(s05 == _L(" \xD848\xDE22\xD848\xDE22\xD848")); |
|
1413 |
|
1414 // string 6: locate |
|
1415 // from Unicode 5.0, CaseFolding.txt |
|
1416 // 10400; C; 10428; # DESERET CAPITAL LETTER LONG I |
|
1417 // 0x10400's fold is 0x10428 |
|
1418 TCharF f06(0x10400); |
|
1419 test(f06 == 0x10428); // just to ensure the property is correct |
|
1420 // 0x10400: D801, DC00 |
|
1421 // 0x10428: D801, DC28 |
|
1422 _LIT(KMixedString6, "ab\xD801\xDC00 e\xD801\xDC27"); |
|
1423 TBuf16<128> s06(KMixedString6); |
|
1424 TInt pos6 = s06.LocateReverseF2(0x10428); |
|
1425 test(pos6 == 2); |
|
1426 } |
1356 } |
1427 |
1357 |
1428 |
1358 |
1429 #ifndef _DEBUG |
1359 #ifndef _DEBUG |
1430 #pragma warning (disable: 4702)// Unreachable code |
1360 #pragma warning (disable: 4702)// Unreachable code |