Home | History | Annotate | Download | only in intltest

Lines Matching refs:UnicodeString

67     UnicodeString   test1("Now is the time for all men to come swiftly to the aid of the party.\n");
68 UnicodeString expectedValue;
69 UnicodeString *c;
71 c=(UnicodeString *)test1.clone();
96 UnicodeString test2(temp, 15);
108 errln(UnicodeString("length() failed: expected 70, got ") + test1.length());
110 errln(UnicodeString("length() failed: expected 30, got ") + test2.length());
112 UnicodeString test3;
115 errln((UnicodeString)"append failed for UChar32, expected \"\\\\ud841\\\\udc02\", got " + prettify(test3));
118 errln(UnicodeString("append or length failed for UChar32, expected 2, got ") + test3.length());
122 errln((UnicodeString)"append failed for UChar32, expected \"\\\\uD841\\\\uDC02t\", got " + prettify(test3));
125 errln((UnicodeString)"append or length failed for UChar32, expected 2, got " + test3.length());
134 errln((UnicodeString)"simple UChar32 overloads for replace, insert, setTo or = failed");
139 UnicodeString s=UNICODE_STRING("\\U0002f999\\U0001d15f\\u00c4\\u1ed0", 32).unescape();
149 errln("UnicodeString::moveIndex32() failed");
153 errln("UnicodeString::getChar32Start() failed");
157 errln("UnicodeString::getChar32Limit() failed");
163 UnicodeString src("Hello folks how are you?");
164 UnicodeString target1("how are you?");
165 if (target1 != UnicodeString(src, 12)) {
166 errln("UnicodeString(const UnicodeString&, int32_t) failed");
168 UnicodeString target2("folks");
169 if (target2 != UnicodeString(src, 6, 5)) {
170 errln("UnicodeString(const UnicodeString&, int32_t, int32_t) failed");
173 errln("UnicodeString::setTo(const UnicodeString&, int32_t) failed");
179 UnicodeString s=UnicodeString("abc", "")+UnicodeString("def", "")+UnicodeString("ghi", "");
180 if(s!=UnicodeString("abcdefghi", "")) {
189 if(UnicodeString("abc", -1, "")!=UnicodeString("abc", "")) {
190 errln("UnicodeString(codepageData, dataLength, codepage) does not work with dataLength==-1");
194 UnicodeString s, t(buffer, -1, UPRV_LENGTHOF(buffer));
197 errln("UnicodeString.setTo(buffer, length, capacity) does not work with length==-1");
200 errln("UnicodeString(buffer, length, capacity) does not work with length==-1");
204 errln("UnicodeString.caseCompare(const UChar *, length, options) does not work with length==-1");
207 errln("UnicodeString.caseCompare(start, _length, const UChar *, options) does not work");
211 UnicodeString u(buffer, -1, UPRV_LENGTHOF(buffer));
213 errln("UnicodeString.setTo(buffer without NUL, length, capacity) does not work with length==-1");
216 errln("UnicodeString(buffer without NUL, length, capacity) does not work with length==-1");
224 UnicodeString v(cs, -1, cnv, errorCode);
227 errln("UnicodeString(const char *, length, cnv, errorCode) does not work with length==-1");
233 // Test the hardcoded-UTF-8 UnicodeString optimizations.
236 UnicodeString from8a = UnicodeString((const char *)utf8);
237 UnicodeString from8b = UnicodeString((const char *)utf8, (int32_t)sizeof(utf8)-1);
238 UnicodeString from16(FALSE, utf16, UPRV_LENGTHOF(utf16));
240 errln("UnicodeString(const char * U_CHARSET_IS_UTF8) failed");
245 errln("UnicodeString::extract(char * U_CHARSET_IS_UTF8) failed");
249 errln("UnicodeString::extract(substring to char * U_CHARSET_IS_UTF8) failed");
258 UnicodeString test1("this is a test");
259 UnicodeString test2("this is a test");
260 UnicodeString test3("this is a test of the emergency broadcast system");
261 UnicodeString test4("never say, \"this is a test\"!!");
263 UnicodeString test5((UChar)0x5000);
264 UnicodeString test6((UChar)0x5100);
285 // test compare(UnicodeString)
287 errln("compare(UnicodeString) failed");
289 //test compare(offset, length, UnicodeString)
294 errln("compare(offset, length, UnicodeString) failes");
357 UnicodeString u[20]; // must be at least as long as strings[]
361 u[i]=UnicodeString(TRUE, strings[i], -1);
366 errln("error: UnicodeString::compareCodePointOrder() fails for string %d and the following one\n", i);
379 UnicodeString
424 UnicodeString s=UNICODE_STRING("a\\u0308b", 8).unescape();
427 errln("error UnicodeString::compare(..., const UChar *, srcLength=-1) does not work");
431 errln("error UnicodeString::compareCodePointOrder(..., const UChar *, srcLength=-1, ...) does not work");
435 errln("error UnicodeString::caseCompare(..., const UChar *, srcLength=-1, ...) does not work");
439 errln("error UnicodeString::indexOf(const UChar *, srcLength=-1, ...) does not work");
443 errln("error UnicodeString::lastIndexOf(const UChar *, srcLength=-1, ...) does not work");
446 UnicodeString s2, s3;
450 errln("error UnicodeString::replace(..., const UChar *, srcLength=-1, ...) does not work");
458 UnicodeString test1("Now is the time for all good men to come to the aid of their country.", "");
459 UnicodeString test2;
462 UnicodeString test5;
468 errln("UnicodeString.extract(char *) failed to return the correct size of destination buffer.");
474 errln("UnicodeString.extractBetween(-3, 7) did not pin properly.");
479 errln("UnicodeString.extract() failed to return the correct size of destination buffer for end of buffer.");
482 errln("UnicodeString.extract() failed to return the correct size of destination buffer.");
486 UnicodeString test4b(test4, 12);
489 errln("UnicodeString.extract(NULL) failed to return the correct size of destination buffer.");
492 errln("UnicodeString.extract(-1) failed to stop reading the string.");
497 errln(UnicodeString("extracting into a UnicodeString failed at position ") + i);
501 errln(UnicodeString("extracting into an array of UChar failed at position ") + i);
505 errln(UnicodeString("extracting into an array of char failed at position ") + i);
509 errln(UnicodeString("extracting with extractBetween failed at position ") + i);
516 errln("UnicodeString.extract(0, 10, (char *)NULL, \"\") != 10");
521 errln("UnicodeString.extract(0, 10, test4, 2, \"\") != 10");
524 errln("UnicodeString.extract(0, 10, test4, 2, \"\") overwrote test4[2]");
529 UnicodeString s("terminate", "");
540 errln("UnicodeString.extract(NULL, 0)==%d (%s) expected %d (U_BUFFER_OVERFLOW_ERROR)", length, s.length(), u_errorName(errorCode));
546 errln("UnicodeString.extract(dest too short)==%d (%s) expected %d (U_BUFFER_OVERFLOW_ERROR)",
553 errln("UnicodeString.extract(dest just right without NUL)==%d (%s) expected %d (U_STRING_NOT_TERMINATED_WARNING)",
557 errln("UnicodeString.extract(dest just right without NUL) did not extract the string correctly");
563 errln("UnicodeString.extract(dest large enough)==%d (%s) expected %d (U_ZERO_ERROR)",
567 errln("UnicodeString.extract(dest large enough) did not extract the string correctly");
573 UnicodeString s=UNICODE_STRING("\\U0002f999\\U0001d15f\\u00c4\\u1ed0", 32).unescape();
590 errln("UnicodeString::extract(NULL, UConverter) preflighting failed (length=%ld, %s)",
597 errln("UnicodeString::extract(too small, UConverter) preflighting failed (length=%ld, %s)",
604 errln("UnicodeString::extract(UConverter) succeeded with an illegal destination");
608 errln("UnicodeString::extract(UConverter) succeeded with a previous error code");
618 errln("UnicodeString::extract(UConverter) conversion failed (length=%ld, %s)",
627 errln("UnicodeString::extract(\"UTF-8\") conversion failed (length=%ld, %s)",
632 UnicodeString t(expect, sizeof(expect), cnv, errorCode);
634 errln("UnicodeString(UConverter) conversion failed (%s)",
646 UnicodeString test1("The rain in Spain stays mainly on the plain");
647 UnicodeString test2("eat SPAMburgers!");
650 UnicodeString& test5 = test1;
691 UnicodeString test1("test test ttest tetest testesteststt");
692 UnicodeString test2("test");
706 UnicodeString test3(testData);
707 UnicodeString test4(testChar32);
716 errln(UnicodeString("indexOf failed: expected to find 6 occurrences, found ") + occurrences);
723 errln(UnicodeString("indexOf with starting offset failed: "
732 errln(UnicodeString("indexOf with starting and ending offsets failed: "
741 errln((UnicodeString)"indexOf failed: expected to find 4 occurrences, found " + occurrences);
748 errln(UnicodeString("indexOf failed: expected to find 2 occurrences, found ") + occurrences);
756 errln(UnicodeString("indexOf with character failed: "
764 errln(UnicodeString("indexOf with character & start offset failed: "
772 errln(UnicodeString("indexOf with character & start & end offsets failed: "
776 UnicodeString subString;
785 errln((UnicodeString)"indexOf failed: expected to find 14 occurrences, found " + occurrences);
792 errln((UnicodeString)"indexOf failed: expected to find 4 occurrences, found " + occurrences);
800 errln((UnicodeString)"indexOf with character & start & end offsets failed: expected to find 2 occurrences, found " + occurrences);
816 errln(UnicodeString("lastIndexOf with starting and ending offsets failed: "
824 errln(UnicodeString("lastIndexOf with character & start & end offsets failed: "
834 errln((UnicodeString)"lastIndexOf with character & start & end offsets failed: expected to find 3 occurrences, found " + occurrences);
845 errln((UnicodeString)"indexOf failed: expected to find 18 occurrences, found " + occurrences);
853 errln("error: UnicodeString::indexOf(UChar32 surrogate) finds a partial supplementary code point");
855 if( UnicodeString(test3, 0, 17).lastIndexOf((UChar)0xd841, 0) != 4 ||
856 UnicodeString(test3, 0, 17).lastIndexOf((UChar32)0xd841, 2) != 4 ||
859 errln("error: UnicodeString::lastIndexOf(UChar32 surrogate) finds a partial supplementary code point");
866 UnicodeString test1("hello");
867 UnicodeString test2(" there");
868 UnicodeString test3("Hi! How ya doin'? Beautiful day, isn't it?");
869 UnicodeString test4;
871 UnicodeString expectedValue;
892 errln("trim(UnicodeString&) failed");
927 UnicodeString test1("Now is the time for all good men to come to the aid of their country.");
928 UnicodeString test2("Now");
929 UnicodeString test3("country.");
930 UnicodeString test4("count");
972 UnicodeString test("abcde");
984 UnicodeString test1("One potato, two potato, three potato, four\n");
985 UnicodeString test2("potato");
986 UnicodeString test3("MISSISSIPPI");
988 UnicodeString expectedValue;
1003 UnicodeString test("backwards words say to used I");
1023 // UnicodeString::reverse() failed to see a lead surrogate in the middle of
1026 UnicodeString expected=UNICODE_STRING_SIMPLE("e\\U0001F4A9ba").unescape();
1036 UnicodeString test1("This is a test");
1037 UnicodeString test2("This is a test");
1038 UnicodeString test3("Me too!");
1041 test1=UnicodeString(); // make sure that it starts with its stackBuffer
1044 errln("UnicodeString::getBuffer(20).getCapacity()<20");
1054 errln("UnicodeString::getBuffer(minCapacity) allows read or write access to the UnicodeString");
1064 errln("UnicodeString::releaseBuffer(newLength) does not properly reallow access to the UnicodeString");
1070 errln("UnicodeString::releaseBuffer(newLength) without getBuffer(minCapacity) changed the UnicodeString");
1079 errln("UnicodeString::getBuffer(const) does not return a usable buffer pointer");
1086 errln("UnicodeString::releaseBuffer(-1) does not properly set the length of the UnicodeString");
1096 errln("UnicodeString::releaseBuffer(-1 but no NUL) does not properly set the length of the UnicodeString");
1100 test1=UnicodeString("This is another test.", "");
1101 test2=UnicodeString("This is another test.", "");
1111 errln("UnicodeString(u[3]).getTerminatedBuffer() returns a bad buffer");
1117 errln("UnicodeString(u[-1]).getTerminatedBuffer() returns a bad buffer");
1123 errln("UnicodeString::append(const UChar *, start, length) failed");
1128 errln("UnicodeString::insert(start, const UniStr &, start, length) failed");
1134 errln("UnicodeString::insert(start, const UChar *, length) failed");
1139 errln("UnicodeString::replace(start, length, UChar) failed");
1142 if(test1.hasMetaData() || UnicodeString().hasMetaData()) {
1143 errln("UnicodeString::hasMetaData() returns TRUE");
1152 errln("UnicodeString(shared buffer).truncate() failed");
1155 errln("UnicodeString(shared buffer).truncate().getTerminatedBuffer() "
1163 errln("UnicodeString(shared buffer).remove() failed");
1166 errln("UnicodeString(shared buffer).remove().getTerminatedBuffer() "
1185 UnicodeString* test = 0;
1187 test = new UnicodeString(testString);
1212 test = new UnicodeString(workingBuffer, 35, 100);
1220 errln("insert() on stack-allocated UnicodeString didn't work right");
1222 errln("insert() on stack-allocated UnicodeString overwrote guard word!");
1225 errln("insert() on stack-allocated UnicodeString didn't affect backing store");
1229 errln("Stack-allocated UnicodeString overflow didn't work");
1231 errln("Stack-allocated UnicodeString overflow overwrote guard word!");
1235 errln("Assignment to stack-allocated UnicodeString didn't work");
1237 errln("Change to UnicodeString after overflow are still affecting original buffer");
1239 errln("Change to UnicodeString after overflow overwrote guard word!");
1247 errln("UnicodeString.setTo(readonly alias) does not alias correctly");
1250 UnicodeString *c=(UnicodeString *)test->clone();
1254 errln("UnicodeString.setTo(readonly alias) made a copy: did not see change in buffer");
1264 errln("UnicodeString.setTo(readonly alias, length -1) does not alias correctly");
1269 errln("UnicodeString.setTo(unterminated readonly alias, length -1) does not result in isBogus()");
1274 test=new UnicodeString();
1279 errln((UnicodeString)"UnicodeString.setTo(UChar*, length, capacity) does not work correctly\n" + prettify(*test));
1285 UnicodeString c32Test((UChar32)0x10ff2a);
1289 errln("The UnicodeString(UChar32) constructor does not work with a 0x10ff2a filler");
1293 UnicodeString capTest(5, (UChar32)0x2a, 5);
1298 errln("The UnicodeString capacity constructor does not work with an ASCII filler");
1301 capTest = UnicodeString(5, (UChar32)0x10ff2a, 5);
1306 errln("The UnicodeString capacity constructor does not work with a 0x10ff2a filler");
1309 capTest = UnicodeString(5, (UChar32)0, 0);
1311 errln("The UnicodeString capacity constructor does not work with a 0x10ff2a filler");
1319 UnicodeString IN("abc\\u4567 \\n\\r \\U00101234xyz\\x1\\x{5289}\\x1b", -1, US_INV);
1320 UnicodeString OUT("abc");
1329 UnicodeString result = IN.unescape();
1344 /* reference implementation of UnicodeString::hasMoreChar32Than() */
1346 _refUnicodeStringHasMoreChar32Than(const UnicodeString &s, int32_t start, int32_t length, int32_t number) {
1353 UnicodeStringTest::_testUnicodeStringHasMoreChar32Than(const UnicodeString &s, int32_t start, int32_t length, int32_t number) {
1363 UnicodeString s=UNICODE_STRING("\\U0002f999\\U0001d15f\\u00c4\\u1ed0", 32).unescape();
1374 errln("UnicodeString::countChar32() failed");
1405 UnicodeString string(str, UPRV_LENGTHOF(str));
1437 UnicodeString test1("This is a test");
1438 UnicodeString test2("This is a test");
1439 UnicodeString test3("Me too!");
1479 test3.findAndReplace(UnicodeString((UChar)0x61), test2);
1538 if(!test3.isBogus() || test3.setTo((UChar)0x2028).isBogus() || test3!=UnicodeString((UChar)0x2028)) {
1543 if(!test3.isBogus() || test3.setTo((UChar32)0x1d157).isBogus() || test3!=UnicodeString((UChar32)0x1d157)) {
1560 if(!test3.isBogus() || (test3=UnicodeString()).isBogus() || !test3.isEmpty()) {
1561 errln("bogus.operator=(UnicodeString()) failed");
1565 if(!test3.isBogus() || test3.setTo(UnicodeString()).isBogus() || !test3.isEmpty()) {
1566 errln("bogus.setTo(UnicodeString()) failed");
1614 UnicodeString
1662 virtual const UnicodeString *snext(UErrorCode &status) {
1664 unistr=UnicodeString(testEnumStrings[i++], "");
1692 UnicodeString s;
1704 s=UnicodeString(testEnumStrings[i], "");
1705 if(U_FAILURE(status) || pc==NULL || length!=s.length() || UnicodeString(pc, length, "")!=s) {
1719 s=UnicodeString(testEnumStrings[i], "");
1720 if(U_FAILURE(status) || pu==NULL || length!=s.length() || UnicodeString(TRUE, pu, length)!=s) {
1762 s=UnicodeString(testEnumStrings[i], "");
1763 if(U_FAILURE(status) || pu==NULL || length!=s.length() || UnicodeString(TRUE, pu, length)!=s) {
1779 * Define a (bogus) UnicodeString class in another namespace and check for ambiguity.
1782 class UnicodeString {
1785 UnicodeString() : i(1) {}
1786 UnicodeString(UBool /*isTerminated*/, const UChar * /*text*/, int32_t textLength) : i(textLength) {(void)i;}
1787 UnicodeString(const char * /*src*/, int32_t length, enum EInvariant /*inv*/
1796 // Provoke name collision unless the UnicodeString macros properly
1797 // qualify the icu::UnicodeString class.
1800 // Use all UnicodeString macros from unistr.h.
1801 icu::UnicodeString s1=icu::UnicodeString("abc", 3, US_INV);
1802 icu::UnicodeString s2=UNICODE_STRING("def", 3);
1803 icu::UnicodeString s3=UNICODE_STRING_SIMPLE("ghi");
1806 icu::UnicodeString s4=s1+s2+s3;
1808 errln("Something wrong with UnicodeString::operator+().");
1824 UnicodeString from32 = UnicodeString::fromUTF32(utf32, UPRV_LENGTHOF(utf32));
1825 UnicodeString expected(FALSE, expected_utf16, UPRV_LENGTHOF(expected_utf16));
1827 errln("UnicodeString::fromUTF32() did not create the expected string.");
1839 UnicodeString(FALSE, utf16, UPRV_LENGTHOF(utf16)).
1845 errln("UnicodeString::toUTF32() did not create the expected string.");
1882 UnicodeString from8 = UnicodeString::fromUTF8(StringPiece((const char *)utf8, (int32_t)sizeof(utf8)));
1883 UnicodeString expected(FALSE, expected_utf16, UPRV_LENGTHOF(expected_utf16));
1886 errln("UnicodeString::fromUTF8(StringPiece) did not create the expected string.");
1890 UnicodeString from8b = UnicodeString::fromUTF8(utf8_string);
1892 errln("UnicodeString::fromUTF8(std::string) did not create the expected string.");
1903 UnicodeString us(FALSE, utf16, UPRV_LENGTHOF(utf16));
1911 errln("UnicodeString::toUTF8() did not create the expected string.");
1914 errln("UnicodeString::toUTF8(sink) did not sink.Flush().");
1923 errln("UnicodeString::toUTF8String() did not create the expected string.");
1929 static UnicodeString wrapUChars(const UChar *uchars) {
1930 return UnicodeString(TRUE, uchars, -1);
1936 UnicodeString alias(TRUE, uchars, 2);
1938 errln("UnicodeString read-only-aliasing constructor does not behave as expected.");
1943 errln("UnicodeString(read-only-alias).truncate() did not preserve aliasing as expected.");
1946 errln("UnicodeString(read-only-alias).truncate().getTerminatedBuffer() "
1950 errln("UnicodeString(read-only-alias).truncate().getTerminatedBuffer() "
1954 errln("UnicodeString(read-only-alias).truncate().getTerminatedBuffer() "
1960 errln("UnicodeString read-only-aliasing setTo() does not behave as expected.");
1965 errln("UnicodeString(read-only-alias).remove() did not work.");
1968 errln("UnicodeString(read-only-alias).remove().getTerminatedBuffer() "
1972 errln("UnicodeString(read-only-alias).remove().getTerminatedBuffer() "
1976 errln("UnicodeString.setTo(read-only-alias).remove().getTerminatedBuffer() "
1980 UnicodeString longString=UNICODE_STRING_SIMPLE("abcdefghijklmnopqrstuvwxyz0123456789");
1984 errln("UnicodeString.setTo(read-only-alias).remove(0, 10) did not preserve aliasing as expected.");
1989 errln("UnicodeString.setTo(read-only-alias).remove(27, 99) did not preserve aliasing as expected.");
1994 errln("UnicodeString.setTo(read-only-alias).retainBetween(6, 30) did not preserve aliasing as expected.");
2000 UnicodeString temp;
2003 errln("UnicodeString.tempSubString() failed");
2007 errln("UnicodeString.tempSubString(-3, 5) failed");
2011 errln("UnicodeString.tempSubString(17) failed");
2015 errln("UnicodeString.tempSubString(99) failed");
2019 errln("UnicodeString.tempSubStringBetween(6) failed");
2023 errln("UnicodeString.tempSubStringBetween(8, 18) failed");
2025 UnicodeString bogusString;
2029 errln("UnicodeString.setToBogus().tempSubStringBetween(8, 18) failed");
2034 UnicodeStringTest::doTestAppendable(UnicodeString &dest, Appendable &app) {
2071 explicit SimpleAppendable(UnicodeString &dest) : str(dest) {}
2075 UnicodeString &str;
2080 UnicodeString dest;
2087 UnicodeString dest;
2094 // See the comments in unistr.h near the declaration of UnicodeString's fields.
2096 size_t sizeofUniStr=sizeof(UnicodeString);
2101 errln("sizeof(UnicodeString)=%d, expected UNISTR_OBJECT_SIZE=%d",
2105 errln("sizeof(UnicodeString)=%d < 32, probably too small", (int)sizeofUniStr);
2107 // We assume that the entire UnicodeString object,
2111 UnicodeString s;
2131 UnicodeString s1(FALSE, abc, UPRV_LENGTHOF(abc)); // read-only alias
2132 UnicodeString s2(100, 0x7a, 100); // 100 * 'z' should be on the heap
2133 UnicodeString s3("defg", 4, US_INV); // in stack buffer
2137 errln("UnicodeString.swap() did not swap");
2141 errln("swap(UnicodeString) did not swap back");
2143 UnicodeString s4;
2146 errln("UnicodeString.moveFrom(heap) did not move");
2148 UnicodeString s5;
2151 errln("UnicodeString.moveFrom(stack) did not move");
2153 UnicodeString s6;
2156 errln("UnicodeString.moveFrom(alias) did not move");
2160 s1 = static_cast<UnicodeString &&>(s6);
2162 errln("UnicodeString move assignment operator did not move");
2164 UnicodeString s7(static_cast<UnicodeString &&>(s4));
2166 errln("UnicodeString move constructor did not move");
2170 UnicodeString s7;
2184 UnicodeString simple = UNICODE_STRING_SIMPLE("simple");
2187 errln("UnicodeString copy after self-move did not work");