Lines Matching defs:UnicodeString

75     UnicodeString   test1("Now is the time for all men to come swiftly to the aid of the party.\n");
76 UnicodeString expectedValue;
77 UnicodeString *c;
79 c=(UnicodeString *)test1.clone();
104 UnicodeString test2(temp, 15);
116 errln(UnicodeString("length() failed: expected 70, got ") + test1.length());
118 errln(UnicodeString("length() failed: expected 30, got ") + test2.length());
120 UnicodeString test3;
123 errln((UnicodeString)"append failed for UChar32, expected \"\\\\ud841\\\\udc02\", got " + prettify(test3));
126 errln(UnicodeString("append or length failed for UChar32, expected 2, got ") + test3.length());
130 errln((UnicodeString)"append failed for UChar32, expected \"\\\\uD841\\\\uDC02t\", got " + prettify(test3));
133 errln((UnicodeString)"append or length failed for UChar32, expected 2, got " + test3.length());
142 errln((UnicodeString)"simple UChar32 overloads for replace, insert, setTo or = failed");
147 UnicodeString s=UNICODE_STRING("\\U0002f999\\U0001d15f\\u00c4\\u1ed0", 32).unescape();
157 errln("UnicodeString::moveIndex32() failed");
161 errln("UnicodeString::getChar32Start() failed");
165 errln("UnicodeString::getChar32Limit() failed");
171 UnicodeString src("Hello folks how are you?");
172 UnicodeString target1("how are you?");
173 if (target1 != UnicodeString(src, 12)) {
174 errln("UnicodeString(const UnicodeString&, int32_t) failed");
176 UnicodeString target2("folks");
177 if (target2 != UnicodeString(src, 6, 5)) {
178 errln("UnicodeString(const UnicodeString&, int32_t, int32_t) failed");
181 errln("UnicodeString::setTo(const UnicodeString&, int32_t) failed");
187 UnicodeString s=UnicodeString("abc", "")+UnicodeString("def", "")+UnicodeString("ghi", "");
188 if(s!=UnicodeString("abcdefghi", "")) {
197 if(UnicodeString("abc", -1, "")!=UnicodeString("abc", "")) {
198 errln("UnicodeString(codepageData, dataLength, codepage) does not work with dataLength==-1");
202 UnicodeString s, t(buffer, -1, LENGTHOF(buffer));
205 errln("UnicodeString.setTo(buffer, length, capacity) does not work with length==-1");
208 errln("UnicodeString(buffer, length, capacity) does not work with length==-1");
212 errln("UnicodeString.caseCompare(const UChar *, length, options) does not work with length==-1");
215 errln("UnicodeString.caseCompare(start, _length, const UChar *, options) does not work");
219 UnicodeString u(buffer, -1, LENGTHOF(buffer));
221 errln("UnicodeString.setTo(buffer without NUL, length, capacity) does not work with length==-1");
224 errln("UnicodeString(buffer without NUL, length, capacity) does not work with length==-1");
232 UnicodeString v(cs, -1, cnv, errorCode);
235 errln("UnicodeString(const char *, length, cnv, errorCode) does not work with length==-1");
241 // Test the hardcoded-UTF-8 UnicodeString optimizations.
244 UnicodeString from8a = UnicodeString((const char *)utf8);
245 UnicodeString from8b = UnicodeString((const char *)utf8, (int32_t)sizeof(utf8)-1);
246 UnicodeString from16(FALSE, utf16, LENGTHOF(utf16));
248 errln("UnicodeString(const char * U_CHARSET_IS_UTF8) failed");
253 errln("UnicodeString::extract(char * U_CHARSET_IS_UTF8) failed");
257 errln("UnicodeString::extract(substring to char * U_CHARSET_IS_UTF8) failed");
266 UnicodeString test1("this is a test");
267 UnicodeString test2("this is a test");
268 UnicodeString test3("this is a test of the emergency broadcast system");
269 UnicodeString test4("never say, \"this is a test\"!!");
271 UnicodeString test5((UChar)0x5000);
272 UnicodeString test6((UChar)0x5100);
293 // test compare(UnicodeString)
295 errln("compare(UnicodeString) failed");
297 //test compare(offset, length, UnicodeString)
302 errln("compare(offset, length, UnicodeString) failes");
365 UnicodeString u[20]; // must be at least as long as strings[]
369 u[i]=UnicodeString(TRUE, strings[i], -1);
374 errln("error: UnicodeString::compareCodePointOrder() fails for string %d and the following one\n", i);
387 UnicodeString
432 UnicodeString s=UNICODE_STRING("a\\u0308b", 8).unescape();
435 errln("error UnicodeString::compare(..., const UChar *, srcLength=-1) does not work");
439 errln("error UnicodeString::compareCodePointOrder(..., const UChar *, srcLength=-1, ...) does not work");
443 errln("error UnicodeString::caseCompare(..., const UChar *, srcLength=-1, ...) does not work");
447 errln("error UnicodeString::indexOf(const UChar *, srcLength=-1, ...) does not work");
451 errln("error UnicodeString::lastIndexOf(const UChar *, srcLength=-1, ...) does not work");
454 UnicodeString s2, s3;
458 errln("error UnicodeString::replace(..., const UChar *, srcLength=-1, ...) does not work");
466 UnicodeString test1("Now is the time for all good men to come to the aid of their country.", "");
467 UnicodeString test2;
470 UnicodeString test5;
476 errln("UnicodeString.extract(char *) failed to return the correct size of destination buffer.");
482 errln("UnicodeString.extractBetween(-3, 7) did not pin properly.");
487 errln("UnicodeString.extract() failed to return the correct size of destination buffer for end of buffer.");
490 errln("UnicodeString.extract() failed to return the correct size of destination buffer.");
494 UnicodeString test4b(test4, 12);
497 errln("UnicodeString.extract(NULL) failed to return the correct size of destination buffer.");
500 errln("UnicodeString.extract(-1) failed to stop reading the string.");
505 errln(UnicodeString("extracting into a UnicodeString failed at position ") + i);
509 errln(UnicodeString("extracting into an array of UChar failed at position ") + i);
513 errln(UnicodeString("extracting into an array of char failed at position ") + i);
517 errln(UnicodeString("extracting with extractBetween failed at position ") + i);
524 errln("UnicodeString.extract(0, 10, (char *)NULL, \"\") != 10");
529 errln("UnicodeString.extract(0, 10, test4, 2, \"\") != 10");
532 errln("UnicodeString.extract(0, 10, test4, 2, \"\") overwrote test4[2]");
537 UnicodeString s("terminate", "");
548 errln("UnicodeString.extract(NULL, 0)==%d (%s) expected %d (U_BUFFER_OVERFLOW_ERROR)", length, s.length(), u_errorName(errorCode));
554 errln("UnicodeString.extract(dest too short)==%d (%s) expected %d (U_BUFFER_OVERFLOW_ERROR)",
561 errln("UnicodeString.extract(dest just right without NUL)==%d (%s) expected %d (U_STRING_NOT_TERMINATED_WARNING)",
565 errln("UnicodeString.extract(dest just right without NUL) did not extract the string correctly");
571 errln("UnicodeString.extract(dest large enough)==%d (%s) expected %d (U_ZERO_ERROR)",
575 errln("UnicodeString.extract(dest large enough) did not extract the string correctly");
581 UnicodeString s=UNICODE_STRING("\\U0002f999\\U0001d15f\\u00c4\\u1ed0", 32).unescape();
598 errln("UnicodeString::extract(NULL, UConverter) preflighting failed (length=%ld, %s)",
605 errln("UnicodeString::extract(too small, UConverter) preflighting failed (length=%ld, %s)",
612 errln("UnicodeString::extract(UConverter) succeeded with an illegal destination");
616 errln("UnicodeString::extract(UConverter) succeeded with a previous error code");
626 errln("UnicodeString::extract(UConverter) conversion failed (length=%ld, %s)",
635 errln("UnicodeString::extract(\"UTF-8\") conversion failed (length=%ld, %s)",
640 UnicodeString t(expect, sizeof(expect), cnv, errorCode);
642 errln("UnicodeString(UConverter) conversion failed (%s)",
654 UnicodeString test1("The rain in Spain stays mainly on the plain");
655 UnicodeString test2("eat SPAMburgers!");
658 UnicodeString& test5 = test1;
699 UnicodeString test1("test test ttest tetest testesteststt");
700 UnicodeString test2("test");
714 UnicodeString test3(testData);
715 UnicodeString test4(testChar32);
724 errln(UnicodeString("indexOf failed: expected to find 6 occurrences, found ") + occurrences);
731 errln(UnicodeString("indexOf with starting offset failed: "
740 errln(UnicodeString("indexOf with starting and ending offsets failed: "
749 errln((UnicodeString)"indexOf failed: expected to find 4 occurrences, found " + occurrences);
756 errln(UnicodeString("indexOf failed: expected to find 2 occurrences, found ") + occurrences);
764 errln(UnicodeString("indexOf with character failed: "
772 errln(UnicodeString("indexOf with character & start offset failed: "
780 errln(UnicodeString("indexOf with character & start & end offsets failed: "
784 UnicodeString subString;
793 errln((UnicodeString)"indexOf failed: expected to find 14 occurrences, found " + occurrences);
800 errln((UnicodeString)"indexOf failed: expected to find 4 occurrences, found " + occurrences);
808 errln((UnicodeString)"indexOf with character & start & end offsets failed: expected to find 2 occurrences, found " + occurrences);
824 errln(UnicodeString("lastIndexOf with starting and ending offsets failed: "
832 errln(UnicodeString("lastIndexOf with character & start & end offsets failed: "
842 errln((UnicodeString)"lastIndexOf with character & start & end offsets failed: expected to find 3 occurrences, found " + occurrences);
853 errln((UnicodeString)"indexOf failed: expected to find 18 occurrences, found " + occurrences);
861 errln("error: UnicodeString::indexOf(UChar32 surrogate) finds a partial supplementary code point");
863 if( UnicodeString(test3, 0, 17).lastIndexOf((UChar)0xd841, 0) != 4 ||
864 UnicodeString(test3, 0, 17).lastIndexOf((UChar32)0xd841, 2) != 4 ||
867 errln("error: UnicodeString::lastIndexOf(UChar32 surrogate) finds a partial supplementary code point");
874 UnicodeString test1("hello");
875 UnicodeString test2(" there");
876 UnicodeString test3("Hi! How ya doin'? Beautiful day, isn't it?");
877 UnicodeString test4;
879 UnicodeString expectedValue;
900 errln("trim(UnicodeString&) failed");
935 UnicodeString test1("Now is the time for all good men to come to the aid of their country.");
936 UnicodeString test2("Now");
937 UnicodeString test3("country.");
938 UnicodeString test4("count");
980 UnicodeString test("abcde");
992 UnicodeString test1("One potato, two potato, three potato, four\n");
993 UnicodeString test2("potato");
994 UnicodeString test3("MISSISSIPPI");
996 UnicodeString expectedValue;
1011 UnicodeString test("backwards words say to used I");
1031 // UnicodeString::reverse() failed to see a lead surrogate in the middle of
1034 UnicodeString expected=UNICODE_STRING_SIMPLE("e\\U0001F4A9ba").unescape();
1044 UnicodeString test1("This is a test");
1045 UnicodeString test2("This is a test");
1046 UnicodeString test3("Me too!");
1049 test1=UnicodeString(); // make sure that it starts with its stackBuffer
1052 errln("UnicodeString::getBuffer(20).getCapacity()<20");
1062 errln("UnicodeString::getBuffer(minCapacity) allows read or write access to the UnicodeString");
1072 errln("UnicodeString::releaseBuffer(newLength) does not properly reallow access to the UnicodeString");
1078 errln("UnicodeString::releaseBuffer(newLength) without getBuffer(minCapacity) changed the UnicodeString");
1087 errln("UnicodeString::getBuffer(const) does not return a usable buffer pointer");
1094 errln("UnicodeString::releaseBuffer(-1) does not properly set the length of the UnicodeString");
1104 errln("UnicodeString::releaseBuffer(-1 but no NUL) does not properly set the length of the UnicodeString");
1108 test1=UnicodeString("This is another test.", "");
1109 test2=UnicodeString("This is another test.", "");
1119 errln("UnicodeString(u[3]).getTerminatedBuffer() returns a bad buffer");
1125 errln("UnicodeString(u[-1]).getTerminatedBuffer() returns a bad buffer");
1131 errln("UnicodeString::append(const UChar *, start, length) failed");
1136 errln("UnicodeString::insert(start, const UniStr &, start, length) failed");
1142 errln("UnicodeString::insert(start, const UChar *, length) failed");
1147 errln("UnicodeString::replace(start, length, UChar) failed");
1150 if(test1.hasMetaData() || UnicodeString().hasMetaData()) {
1151 errln("UnicodeString::hasMetaData() returns TRUE");
1160 errln("UnicodeString(shared buffer).truncate() failed");
1163 errln("UnicodeString(shared buffer).truncate().getTerminatedBuffer() "
1171 errln("UnicodeString(shared buffer).remove() failed");
1174 errln("UnicodeString(shared buffer).remove().getTerminatedBuffer() "
1193 UnicodeString* test = 0;
1195 test = new UnicodeString(testString);
1220 test = new UnicodeString(workingBuffer, 35, 100);
1228 errln("insert() on stack-allocated UnicodeString didn't work right");
1230 errln("insert() on stack-allocated UnicodeString overwrote guard word!");
1233 errln("insert() on stack-allocated UnicodeString didn't affect backing store");
1237 errln("Stack-allocated UnicodeString overflow didn't work");
1239 errln("Stack-allocated UnicodeString overflow overwrote guard word!");
1243 errln("Assignment to stack-allocated UnicodeString didn't work");
1245 errln("Change to UnicodeString after overflow are still affecting original buffer");
1247 errln("Change to UnicodeString after overflow overwrote guard word!");
1255 errln("UnicodeString.setTo(readonly alias) does not alias correctly");
1258 UnicodeString *c=(UnicodeString *)test->clone();
1262 errln("UnicodeString.setTo(readonly alias) made a copy: did not see change in buffer");
1272 errln("UnicodeString.setTo(readonly alias, length -1) does not alias correctly");
1277 errln("UnicodeString.setTo(unterminated readonly alias, length -1) does not result in isBogus()");
1282 test=new UnicodeString();
1287 errln((UnicodeString)"UnicodeString.setTo(UChar*, length, capacity) does not work correctly\n" + prettify(*test));
1293 UnicodeString c32Test((UChar32)0x10ff2a);
1297 errln("The UnicodeString(UChar32) constructor does not work with a 0x10ff2a filler");
1301 UnicodeString capTest(5, (UChar32)0x2a, 5);
1306 errln("The UnicodeString capacity constructor does not work with an ASCII filler");
1309 capTest = UnicodeString(5, (UChar32)0x10ff2a, 5);
1314 errln("The UnicodeString capacity constructor does not work with a 0x10ff2a filler");
1317 capTest = UnicodeString(5, (UChar32)0, 0);
1319 errln("The UnicodeString capacity constructor does not work with a 0x10ff2a filler");
1327 UnicodeString IN("abc\\u4567 \\n\\r \\U00101234xyz\\x1\\x{5289}\\x1b", -1, US_INV);
1328 UnicodeString OUT("abc");
1337 UnicodeString result = IN.unescape();
1352 /* reference implementation of UnicodeString::hasMoreChar32Than() */
1354 _refUnicodeStringHasMoreChar32Than(const UnicodeString &s, int32_t start, int32_t length, int32_t number) {
1361 UnicodeStringTest::_testUnicodeStringHasMoreChar32Than(const UnicodeString &s, int32_t start, int32_t length, int32_t number) {
1371 UnicodeString s=UNICODE_STRING("\\U0002f999\\U0001d15f\\u00c4\\u1ed0", 32).unescape();
1382 errln("UnicodeString::countChar32() failed");
1413 UnicodeString string(str, LENGTHOF(str));
1445 UnicodeString test1("This is a test");
1446 UnicodeString test2("This is a test");
1447 UnicodeString test3("Me too!");
1487 test3.findAndReplace(UnicodeString((UChar)0x61), test2);
1546 if(!test3.isBogus() || test3.setTo((UChar)0x2028).isBogus() || test3!=UnicodeString((UChar)0x2028)) {
1551 if(!test3.isBogus() || test3.setTo((UChar32)0x1d157).isBogus() || test3!=UnicodeString((UChar32)0x1d157)) {
1568 if(!test3.isBogus() || (test3=UnicodeString()).isBogus() || !test3.isEmpty()) {
1569 errln("bogus.operator=(UnicodeString()) failed");
1573 if(!test3.isBogus() || test3.setTo(UnicodeString()).isBogus() || !test3.isEmpty()) {
1574 errln("bogus.setTo(UnicodeString()) failed");
1622 UnicodeString
1670 virtual const UnicodeString *snext(UErrorCode &status) {
1672 unistr=UnicodeString(testEnumStrings[i++], "");
1700 UnicodeString s;
1712 s=UnicodeString(testEnumStrings[i], "");
1713 if(U_FAILURE(status) || pc==NULL || length!=s.length() || UnicodeString(pc, length, "")!=s) {
1727 s=UnicodeString(testEnumStrings[i], "");
1728 if(U_FAILURE(status) || pu==NULL || length!=s.length() || UnicodeString(TRUE, pu, length)!=s) {
1770 s=UnicodeString(testEnumStrings[i], "");
1771 if(U_FAILURE(status) || pu==NULL || length!=s.length() || UnicodeString(TRUE, pu, length)!=s) {
1787 * Define a (bogus) UnicodeString class in another namespace and check for ambiguity.
1790 class UnicodeString {
1793 UnicodeString() : i(1) {}
1794 UnicodeString(UBool /*isTerminated*/, const UChar * /*text*/, int32_t textLength) : i(textLength) {(void)i;}
1795 UnicodeString(const char * /*src*/, int32_t length, enum EInvariant /*inv*/
1804 // Provoke name collision unless the UnicodeString macros properly
1805 // qualify the icu::UnicodeString class.
1808 // Use all UnicodeString macros from unistr.h.
1809 icu::UnicodeString s1=icu::UnicodeString("abc", 3, US_INV);
1810 icu::UnicodeString s2=UNICODE_STRING("def", 3);
1811 icu::UnicodeString s3=UNICODE_STRING_SIMPLE("ghi");
1814 icu::UnicodeString s4=s1+s2+s3;
1816 errln("Something wrong with UnicodeString::operator+().");
1832 UnicodeString from32 = UnicodeString::fromUTF32(utf32, LENGTHOF(utf32));
1833 UnicodeString expected(FALSE, expected_utf16, LENGTHOF(expected_utf16));
1835 errln("UnicodeString::fromUTF32() did not create the expected string.");
1847 UnicodeString(FALSE, utf16, LENGTHOF(utf16)).
1853 errln("UnicodeString::toUTF32() did not create the expected string.");
1890 UnicodeString from8 = UnicodeString::fromUTF8(StringPiece((const char *)utf8, (int32_t)sizeof(utf8)));
1891 UnicodeString expected(FALSE, expected_utf16, LENGTHOF(expected_utf16));
1894 errln("UnicodeString::fromUTF8(StringPiece) did not create the expected string.");
1898 UnicodeString from8b = UnicodeString::fromUTF8(utf8_string);
1900 errln("UnicodeString::fromUTF8(std::string) did not create the expected string.");
1911 UnicodeString us(FALSE, utf16, LENGTHOF(utf16));
1919 errln("UnicodeString::toUTF8() did not create the expected string.");
1922 errln("UnicodeString::toUTF8(sink) did not sink.Flush().");
1931 errln("UnicodeString::toUTF8String() did not create the expected string.");
1937 static UnicodeString wrapUChars(const UChar *uchars) {
1938 return UnicodeString(TRUE, uchars, -1);
1944 UnicodeString alias(TRUE, uchars, 2);
1946 errln("UnicodeString read-only-aliasing constructor does not behave as expected.");
1951 errln("UnicodeString(read-only-alias).truncate() did not preserve aliasing as expected.");
1954 errln("UnicodeString(read-only-alias).truncate().getTerminatedBuffer() "
1958 errln("UnicodeString(read-only-alias).truncate().getTerminatedBuffer() "
1962 errln("UnicodeString(read-only-alias).truncate().getTerminatedBuffer() "
1968 errln("UnicodeString read-only-aliasing setTo() does not behave as expected.");
1973 errln("UnicodeString(read-only-alias).remove() did not work.");
1976 errln("UnicodeString(read-only-alias).remove().getTerminatedBuffer() "
1980 errln("UnicodeString(read-only-alias).remove().getTerminatedBuffer() "
1984 errln("UnicodeString.setTo(read-only-alias).remove().getTerminatedBuffer() "
1988 UnicodeString longString=UNICODE_STRING_SIMPLE("abcdefghijklmnopqrstuvwxyz0123456789");
1992 errln("UnicodeString.setTo(read-only-alias).remove(0, 10) did not preserve aliasing as expected.");
1997 errln("UnicodeString.setTo(read-only-alias).remove(27, 99) did not preserve aliasing as expected.");
2002 errln("UnicodeString.setTo(read-only-alias).retainBetween(6, 30) did not preserve aliasing as expected.");
2008 UnicodeString temp;
2011 errln("UnicodeString.tempSubString() failed");
2015 errln("UnicodeString.tempSubString(-3, 5) failed");
2019 errln("UnicodeString.tempSubString(17) failed");
2023 errln("UnicodeString.tempSubString(99) failed");
2027 errln("UnicodeString.tempSubStringBetween(6) failed");
2031 errln("UnicodeString.tempSubStringBetween(8, 18) failed");
2033 UnicodeString bogusString;
2037 errln("UnicodeString.setToBogus().tempSubStringBetween(8, 18) failed");
2042 UnicodeStringTest::doTestAppendable(UnicodeString &dest, Appendable &app) {
2079 explicit SimpleAppendable(UnicodeString &dest) : str(dest) {}
2083 UnicodeString &str;
2088 UnicodeString dest;
2095 UnicodeString dest;
2102 // See the comments in unistr.h near the declaration of UnicodeString's fields.
2103 size_t sizeofUniStr=sizeof(UnicodeString);
2117 errln("sizeof(UnicodeString)=%d, expected %d", (int)sizeofUniStr, (int)expected);