VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstIprtMiniString.cpp@ 36501

Last change on this file since 36501 was 36501, checked in by vboxsync, 14 years ago

IPRT: add join/split and + operators to the string class

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.8 KB
Line 
1/* $Id: tstIprtMiniString.cpp 36501 2011-04-01 13:40:21Z vboxsync $ */
2/** @file
3 * IPRT Testcase - iprt::MiniString.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include <iprt/cpp/ministring.h>
31
32#include <iprt/err.h>
33#include <iprt/mem.h>
34#include <iprt/string.h>
35#include <iprt/test.h>
36#include <iprt/uni.h>
37
38
39static void test1Hlp1(const char *pszExpect, const char *pszFormat, ...)
40{
41#if 0
42 va_list va;
43 va_start(va, pszFormat);
44 iprt::MiniString strTst(pszFormat, va);
45 va_end(va);
46 RTTESTI_CHECK_MSG(strTst.equals(pszExpect), ("strTst='%s' expected='%s'\n", strTst.c_str(), pszExpect));
47#endif
48}
49
50static void test1(RTTEST hTest)
51{
52 RTTestSub(hTest, "Basics");
53
54#define CHECK(expr) RTTESTI_CHECK(expr)
55#define CHECK_DUMP(expr, value) \
56 do { \
57 if (!(expr)) \
58 RTTestFailed(hTest, "%d: FAILED %s, got \"%s\"", __LINE__, #expr, value); \
59 } while (0)
60
61#define CHECK_DUMP_I(expr) \
62 do { \
63 if (!(expr)) \
64 RTTestFailed(hTest, "%d: FAILED %s, got \"%d\"", __LINE__, #expr, expr); \
65 } while (0)
66#define CHECK_EQUAL(Str, szExpect) \
67 do { \
68 if (!(Str).equals(szExpect)) \
69 RTTestIFailed("line %u: expected \"%s\" got \"%s\"", __LINE__, szExpect, (Str).c_str()); \
70 } while (0)
71
72 iprt::MiniString empty;
73 CHECK(empty.length() == 0);
74 CHECK(empty.capacity() == 0);
75
76 iprt::MiniString sixbytes("12345");
77 CHECK(sixbytes.length() == 5);
78 CHECK(sixbytes.capacity() == 6);
79
80 sixbytes.append(iprt::MiniString("678"));
81 CHECK(sixbytes.length() == 8);
82 CHECK(sixbytes.capacity() >= 9);
83
84 sixbytes.append("9a");
85 CHECK(sixbytes.length() == 10);
86 CHECK(sixbytes.capacity() >= 11);
87
88 char *psz = sixbytes.mutableRaw();
89 // 123456789a
90 // ^
91 // 0123456
92 psz[6] = '\0';
93 sixbytes.jolt();
94 CHECK(sixbytes.length() == 6);
95 CHECK(sixbytes.capacity() == 7);
96
97 iprt::MiniString morebytes("tobereplaced");
98 morebytes = "newstring ";
99 morebytes.append(sixbytes);
100
101 CHECK_DUMP(morebytes == "newstring 123456", morebytes.c_str());
102
103 iprt::MiniString third(morebytes);
104 third.reserve(100 * 1024); // 100 KB
105 CHECK_DUMP(third == "newstring 123456", morebytes.c_str() );
106 CHECK(third.capacity() == 100 * 1024);
107 CHECK(third.length() == morebytes.length()); // must not have changed
108
109 iprt::MiniString copy1(morebytes);
110 iprt::MiniString copy2 = morebytes;
111 CHECK(copy1 == copy2);
112
113 copy1 = NULL;
114 CHECK(copy1.length() == 0);
115
116 copy1 = "";
117 CHECK(copy1.length() == 0);
118
119 CHECK(iprt::MiniString("abc") < iprt::MiniString("def"));
120 CHECK(iprt::MiniString("") < iprt::MiniString("def"));
121 CHECK(iprt::MiniString("abc") > iprt::MiniString(""));
122 CHECK(iprt::MiniString("abc") != iprt::MiniString("def"));
123 CHECK_DUMP_I(iprt::MiniString("def") > iprt::MiniString("abc"));
124 CHECK(iprt::MiniString("abc") == iprt::MiniString("abc"));
125 CHECK(iprt::MiniString("").compare("") == 0);
126 CHECK(iprt::MiniString("").compare(NULL) == 0);
127 CHECK(iprt::MiniString("").compare("a") < 0);
128 CHECK(iprt::MiniString("a").compare("") > 0);
129 CHECK(iprt::MiniString("a").compare(NULL) > 0);
130
131 CHECK(iprt::MiniString("abc") < "def");
132 CHECK(iprt::MiniString("abc") != "def");
133 CHECK_DUMP_I(iprt::MiniString("def") > "abc");
134 CHECK(iprt::MiniString("abc") == "abc");
135
136 CHECK(iprt::MiniString("abc").equals("abc"));
137 CHECK(!iprt::MiniString("abc").equals("def"));
138 CHECK(iprt::MiniString("abc").equalsIgnoreCase("Abc"));
139 CHECK(iprt::MiniString("abc").equalsIgnoreCase("ABc"));
140 CHECK(iprt::MiniString("abc").equalsIgnoreCase("ABC"));
141 CHECK(!iprt::MiniString("abc").equalsIgnoreCase("dBC"));
142 CHECK(iprt::MiniString("").equals(""));
143 CHECK(iprt::MiniString("").equals(NULL));
144 CHECK(!iprt::MiniString("").equals("a"));
145 CHECK(!iprt::MiniString("a").equals(""));
146 CHECK(!iprt::MiniString("a").equals(NULL));
147 CHECK(iprt::MiniString("").equalsIgnoreCase(""));
148 CHECK(iprt::MiniString("").equalsIgnoreCase(NULL));
149 CHECK(!iprt::MiniString("").equalsIgnoreCase("a"));
150 CHECK(!iprt::MiniString("a").equalsIgnoreCase(""));
151
152 copy2.setNull();
153 for (int i = 0; i < 100; ++i)
154 {
155 copy2.reserve(50); // should be ignored after 50 loops
156 copy2.append("1");
157 }
158 CHECK(copy2.length() == 100);
159
160 copy2.setNull();
161 for (int i = 0; i < 100; ++i)
162 {
163 copy2.reserve(50); // should be ignored after 50 loops
164 copy2.append('1');
165 }
166 CHECK(copy2.length() == 100);
167
168 /* printf */
169 iprt::MiniString StrFmt;
170 CHECK(StrFmt.printf("%s-%s-%d", "abc", "def", 42).equals("abc-def-42"));
171 test1Hlp1("abc-42-def", "%s-%d-%s", "abc", 42, "def");
172 test1Hlp1("", "");
173 test1Hlp1("1", "1");
174 test1Hlp1("foobar", "%s", "foobar");
175
176 /* substring constructors */
177 iprt::MiniString SubStr1("", (size_t)0);
178 CHECK_EQUAL(SubStr1, "");
179
180 iprt::MiniString SubStr2("abcdef", 2);
181 CHECK_EQUAL(SubStr2, "ab");
182
183 iprt::MiniString SubStr3("abcdef", 1);
184 CHECK_EQUAL(SubStr3, "a");
185
186 iprt::MiniString SubStr4("abcdef", 6);
187 CHECK_EQUAL(SubStr4, "abcdef");
188
189 iprt::MiniString SubStr5("abcdef", 7);
190 CHECK_EQUAL(SubStr5, "abcdef");
191
192
193 iprt::MiniString SubStrBase("abcdef");
194
195 iprt::MiniString SubStr10(SubStrBase, 0);
196 CHECK_EQUAL(SubStr10, "abcdef");
197
198 iprt::MiniString SubStr11(SubStrBase, 1);
199 CHECK_EQUAL(SubStr11, "bcdef");
200
201 iprt::MiniString SubStr12(SubStrBase, 1, 1);
202 CHECK_EQUAL(SubStr12, "b");
203
204 iprt::MiniString SubStr13(SubStrBase, 2, 3);
205 CHECK_EQUAL(SubStr13, "cde");
206
207 iprt::MiniString SubStr14(SubStrBase, 2, 4);
208 CHECK_EQUAL(SubStr14, "cdef");
209
210 iprt::MiniString SubStr15(SubStrBase, 2, 5);
211 CHECK_EQUAL(SubStr15, "cdef");
212
213 /* substr() and substrCP() functions */
214 iprt::MiniString strTest("");
215 CHECK_EQUAL(strTest.substr(0), "");
216 CHECK_EQUAL(strTest.substrCP(0), "");
217 CHECK_EQUAL(strTest.substr(1), "");
218 CHECK_EQUAL(strTest.substrCP(1), "");
219
220 /* now let's have some non-ASCII to chew on */
221 strTest = "abcdefßäbcdef";
222 // 13 codepoints, but 15 bytes (excluding null terminator);
223 // "ß" and "ä" consume two bytes each
224 CHECK_EQUAL(strTest.substr(0), strTest.c_str());
225 CHECK_EQUAL(strTest.substrCP(0), strTest.c_str());
226
227 CHECK_EQUAL(strTest.substr(2), "cdefßäbcdef");
228 CHECK_EQUAL(strTest.substrCP(2), "cdefßäbcdef");
229
230 CHECK_EQUAL(strTest.substr(2, 2), "cd");
231 CHECK_EQUAL(strTest.substrCP(2, 2), "cd");
232
233 CHECK_EQUAL(strTest.substr(6), "ßäbcdef");
234 CHECK_EQUAL(strTest.substrCP(6), "ßäbcdef");
235
236 CHECK_EQUAL(strTest.substr(6, 2), "ß"); // UTF-8 "ß" consumes two bytes
237 CHECK_EQUAL(strTest.substrCP(6, 1), "ß");
238
239 CHECK_EQUAL(strTest.substr(8), "äbcdef"); // UTF-8 "ß" consumes two bytes
240 CHECK_EQUAL(strTest.substrCP(7), "äbcdef");
241
242 CHECK_EQUAL(strTest.substr(8, 3), "äb"); // UTF-8 "ä" consumes two bytes
243 CHECK_EQUAL(strTest.substrCP(7, 2), "äb");
244
245 CHECK_EQUAL(strTest.substr(14, 1), "f");
246 CHECK_EQUAL(strTest.substrCP(12, 1), "f");
247
248 CHECK_EQUAL(strTest.substr(15, 1), "");
249 CHECK_EQUAL(strTest.substrCP(13, 1), "");
250
251 CHECK_EQUAL(strTest.substr(16, 1), "");
252 CHECK_EQUAL(strTest.substrCP(15, 1), "");
253
254 /* and check cooperation with find() */
255 size_t pos = strTest.find("ß");
256 CHECK_EQUAL(strTest.substr(pos), "ßäbcdef");
257
258 /* split */
259 iprt::list<iprt::MiniString> spList1 = iprt::MiniString("##abcdef##abcdef####abcdef##").split("##", iprt::MiniString::RemoveEmptyParts);
260 RTTESTI_CHECK(spList1.size() == 3);
261 for (size_t i = 0; i < spList1.size(); ++i)
262 RTTESTI_CHECK(spList1.at(i) == "abcdef");
263 iprt::list<iprt::MiniString> spList2 = iprt::MiniString("##abcdef##abcdef####abcdef##").split("##", iprt::MiniString::KeepEmptyParts);
264 RTTESTI_CHECK_RETV(spList2.size() == 5);
265 RTTESTI_CHECK(spList2.at(0) == "");
266 RTTESTI_CHECK(spList2.at(1) == "abcdef");
267 RTTESTI_CHECK(spList2.at(2) == "abcdef");
268 RTTESTI_CHECK(spList2.at(3) == "");
269 RTTESTI_CHECK(spList2.at(4) == "abcdef");
270 iprt::list<iprt::MiniString> spList3 = iprt::MiniString().split("##", iprt::MiniString::KeepEmptyParts);
271 RTTESTI_CHECK(spList3.size() == 0);
272 iprt::list<iprt::MiniString> spList4 = iprt::MiniString().split("");
273 RTTESTI_CHECK(spList4.size() == 0);
274 iprt::list<iprt::MiniString> spList5 = iprt::MiniString("abcdef").split("");
275 RTTESTI_CHECK_RETV(spList5.size() == 1);
276 RTTESTI_CHECK(spList5.at(0) == "abcdef");
277
278 /* join */
279 iprt::list<iprt::MiniString> jnList;
280 strTest = iprt::MiniString::join(jnList);
281 RTTESTI_CHECK(strTest == "");
282 strTest = iprt::MiniString::join(jnList, "##");
283 RTTESTI_CHECK(strTest == "");
284 for (size_t i = 0; i < 5; ++i)
285 jnList.append("abcdef");
286 strTest = iprt::MiniString::join(jnList);
287 RTTESTI_CHECK(strTest == "abcdefabcdefabcdefabcdefabcdef");
288 strTest = iprt::MiniString::join(jnList, "##");
289 RTTESTI_CHECK(strTest == "abcdef##abcdef##abcdef##abcdef##abcdef");
290
291 /* special constructor and assignment arguments */
292 iprt::MiniString StrCtor1("");
293 RTTESTI_CHECK(StrCtor1.isEmpty());
294 RTTESTI_CHECK(StrCtor1.length() == 0);
295
296 iprt::MiniString StrCtor2(NULL);
297 RTTESTI_CHECK(StrCtor2.isEmpty());
298 RTTESTI_CHECK(StrCtor2.length() == 0);
299
300 iprt::MiniString StrCtor1d(StrCtor1);
301 RTTESTI_CHECK(StrCtor1d.isEmpty());
302 RTTESTI_CHECK(StrCtor1d.length() == 0);
303
304 iprt::MiniString StrCtor2d(StrCtor2);
305 RTTESTI_CHECK(StrCtor2d.isEmpty());
306 RTTESTI_CHECK(StrCtor2d.length() == 0);
307
308 for (unsigned i = 0; i < 2; i++)
309 {
310 iprt::MiniString StrAssign;
311 if (i) StrAssign = "abcdef";
312 StrAssign = (char *)NULL;
313 RTTESTI_CHECK(StrAssign.isEmpty());
314 RTTESTI_CHECK(StrAssign.length() == 0);
315
316 if (i) StrAssign = "abcdef";
317 StrAssign = "";
318 RTTESTI_CHECK(StrAssign.isEmpty());
319 RTTESTI_CHECK(StrAssign.length() == 0);
320
321 if (i) StrAssign = "abcdef";
322 StrAssign = StrCtor1;
323 RTTESTI_CHECK(StrAssign.isEmpty());
324 RTTESTI_CHECK(StrAssign.length() == 0);
325
326 if (i) StrAssign = "abcdef";
327 StrAssign = StrCtor2;
328 RTTESTI_CHECK(StrAssign.isEmpty());
329 RTTESTI_CHECK(StrAssign.length() == 0);
330 }
331
332#undef CHECK
333#undef CHECK_DUMP
334#undef CHECK_DUMP_I
335#undef CHECK_EQUAL
336}
337
338
339static int mymemcmp(const char *psz1, const char *psz2, size_t cch)
340{
341 for (size_t off = 0; off < cch; off++)
342 if (psz1[off] != psz2[off])
343 {
344 RTTestIFailed("off=%#x psz1=%.*Rhxs psz2=%.*Rhxs\n", off,
345 RT_MIN(cch - off, 8), &psz1[off],
346 RT_MIN(cch - off, 8), &psz2[off]);
347 return psz1[off] > psz2[off] ? 1 : -1;
348 }
349 return 0;
350}
351
352static void test2(RTTEST hTest)
353{
354 RTTestSub(hTest, "UTF-8 upper/lower encoding assumption");
355
356#define CHECK_EQUAL(str1, str2) \
357 do \
358 { \
359 RTTESTI_CHECK(strlen((str1).c_str()) == (str1).length()); \
360 RTTESTI_CHECK((str1).length() == (str2).length()); \
361 RTTESTI_CHECK(mymemcmp((str1).c_str(), (str2).c_str(), (str2).length() + 1) == 0); \
362 } while (0)
363
364 iprt::MiniString strTmp;
365 char szDst[16];
366
367 /* Collect all upper and lower case code points. */
368 iprt::MiniString strLower("");
369 strLower.reserve(_4M);
370
371 iprt::MiniString strUpper("");
372 strUpper.reserve(_4M);
373
374 for (RTUNICP uc = 1; uc <= 0x10fffd; uc++)
375 {
376 if (RTUniCpIsLower(uc))
377 {
378 RTTESTI_CHECK_MSG(uc < 0xd800 || (uc > 0xdfff && uc != 0xfffe && uc != 0xffff), ("%#x\n", uc));
379 strLower.appendCodePoint(uc);
380 }
381 if (RTUniCpIsUpper(uc))
382 {
383 RTTESTI_CHECK_MSG(uc < 0xd800 || (uc > 0xdfff && uc != 0xfffe && uc != 0xffff), ("%#x\n", uc));
384 strUpper.appendCodePoint(uc);
385 }
386 }
387 RTTESTI_CHECK(strlen(strLower.c_str()) == strLower.length());
388 RTTESTI_CHECK(strlen(strUpper.c_str()) == strUpper.length());
389
390 /* Fold each code point in the lower case string and check that it encodes
391 into the same or less number of bytes. */
392 size_t cch = 0;
393 const char *pszCur = strLower.c_str();
394 iprt::MiniString strUpper2("");
395 strUpper2.reserve(strLower.length() + 64);
396 for (;;)
397 {
398 RTUNICP ucLower;
399 const char * const pszPrev = pszCur;
400 RTTESTI_CHECK_RC_BREAK(RTStrGetCpEx(&pszCur, &ucLower), VINF_SUCCESS);
401 size_t const cchSrc = pszCur - pszPrev;
402 if (!ucLower)
403 break;
404
405 RTUNICP const ucUpper = RTUniCpToUpper(ucLower);
406 const char *pszDstEnd = RTStrPutCp(szDst, ucUpper);
407 size_t const cchDst = pszDstEnd - &szDst[0];
408 RTTESTI_CHECK_MSG(cchSrc >= cchDst,
409 ("ucLower=%#x %u bytes; ucUpper=%#x %u bytes\n",
410 ucLower, cchSrc, ucUpper, cchDst));
411 cch += cchDst;
412 strUpper2.appendCodePoint(ucUpper);
413
414 /* roundtrip stability */
415 RTUNICP const ucUpper2 = RTUniCpToUpper(ucUpper);
416 RTTESTI_CHECK_MSG(ucUpper2 == ucUpper, ("ucUpper2=%#x ucUpper=%#x\n", ucUpper2, ucUpper));
417
418 RTUNICP const ucLower2 = RTUniCpToLower(ucUpper);
419 RTUNICP const ucUpper3 = RTUniCpToUpper(ucLower2);
420 RTTESTI_CHECK_MSG(ucUpper3 == ucUpper, ("ucUpper3=%#x ucUpper=%#x\n", ucUpper3, ucUpper));
421
422 pszDstEnd = RTStrPutCp(szDst, ucLower2);
423 size_t const cchLower2 = pszDstEnd - &szDst[0];
424 RTTESTI_CHECK_MSG(cchDst == cchLower2,
425 ("ucLower2=%#x %u bytes; ucUpper=%#x %u bytes\n",
426 ucLower2, cchLower2, ucUpper, cchDst));
427 }
428 RTTESTI_CHECK(strlen(strUpper2.c_str()) == strUpper2.length());
429 RTTESTI_CHECK_MSG(cch == strUpper2.length(), ("cch=%u length()=%u\n", cch, strUpper2.length()));
430
431 /* the toUpper method shall do the same thing. */
432 strTmp = strLower; CHECK_EQUAL(strTmp, strLower);
433 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
434
435 /* Ditto for the upper case string. */
436 cch = 0;
437 pszCur = strUpper.c_str();
438 iprt::MiniString strLower2("");
439 strLower2.reserve(strUpper.length() + 64);
440 for (;;)
441 {
442 RTUNICP ucUpper;
443 const char * const pszPrev = pszCur;
444 RTTESTI_CHECK_RC_BREAK(RTStrGetCpEx(&pszCur, &ucUpper), VINF_SUCCESS);
445 size_t const cchSrc = pszCur - pszPrev;
446 if (!ucUpper)
447 break;
448
449 RTUNICP const ucLower = RTUniCpToLower(ucUpper);
450 const char *pszDstEnd = RTStrPutCp(szDst, ucLower);
451 size_t const cchDst = pszDstEnd - &szDst[0];
452 RTTESTI_CHECK_MSG(cchSrc >= cchDst,
453 ("ucUpper=%#x %u bytes; ucLower=%#x %u bytes\n",
454 ucUpper, cchSrc, ucLower, cchDst));
455
456 cch += cchDst;
457 strLower2.appendCodePoint(ucLower);
458
459 /* roundtrip stability */
460 RTUNICP const ucLower2 = RTUniCpToLower(ucLower);
461 RTTESTI_CHECK_MSG(ucLower2 == ucLower, ("ucLower2=%#x ucLower=%#x\n", ucLower2, ucLower));
462
463 RTUNICP const ucUpper2 = RTUniCpToUpper(ucLower);
464 RTUNICP const ucLower3 = RTUniCpToLower(ucUpper2);
465 RTTESTI_CHECK_MSG(ucLower3 == ucLower, ("ucLower3=%#x ucLower=%#x\n", ucLower3, ucLower));
466
467 pszDstEnd = RTStrPutCp(szDst, ucUpper2);
468 size_t const cchUpper2 = pszDstEnd - &szDst[0];
469 RTTESTI_CHECK_MSG(cchDst == cchUpper2,
470 ("ucUpper2=%#x %u bytes; ucLower=%#x %u bytes\n",
471 ucUpper2, cchUpper2, ucLower, cchDst));
472 }
473 RTTESTI_CHECK(strlen(strLower2.c_str()) == strLower2.length());
474 RTTESTI_CHECK_MSG(cch == strLower2.length(), ("cch=%u length()=%u\n", cch, strLower2.length()));
475
476 strTmp = strUpper; CHECK_EQUAL(strTmp, strUpper);
477 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
478
479 /* Checks of folding stability when nothing shall change. */
480 strTmp = strUpper; CHECK_EQUAL(strTmp, strUpper);
481 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper);
482 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper);
483 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper);
484
485 strTmp = strUpper2; CHECK_EQUAL(strTmp, strUpper2);
486 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
487 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
488 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
489
490 strTmp = strLower; CHECK_EQUAL(strTmp, strLower);
491 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower);
492 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower);
493 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower);
494
495 strTmp = strLower2; CHECK_EQUAL(strTmp, strLower2);
496 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
497 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
498 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
499
500 /* Check folding stability for roundtrips. */
501 strTmp = strUpper; CHECK_EQUAL(strTmp, strUpper);
502 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
503 strTmp.toUpper();
504 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
505 strTmp.toUpper();
506 strTmp.toLower(); CHECK_EQUAL(strTmp, strLower2);
507
508 strTmp = strLower; CHECK_EQUAL(strTmp, strLower);
509 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
510 strTmp.toLower();
511 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
512 strTmp.toLower();
513 strTmp.toUpper(); CHECK_EQUAL(strTmp, strUpper2);
514}
515
516
517int main()
518{
519 RTTEST hTest;
520 RTEXITCODE rcExit = RTTestInitAndCreate("tstIprtMiniString", &hTest);
521 if (rcExit == RTEXITCODE_SUCCESS)
522 {
523 RTTestBanner(hTest);
524
525 test1(hTest);
526 test2(hTest);
527
528 rcExit = RTTestSummaryAndDestroy(hTest);
529 }
530 return rcExit;
531}
532
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette