Bump for 3.6-28
[LibreOffice.git] / sal / qa / rtl_strings / rtl_OUStringBuffer.cxx
blob7a9871c041e4a9f01e2beca28702fdf6e2d8764a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #ifndef _SAL_TYPES_H_
31 #include <sal/types.h>
32 #endif
34 #include <testshl/tresstatewrapper.hxx>
36 #ifndef _RTL_STRING_HXX_
37 #include <rtl/string.hxx>
38 #endif
40 #ifndef _RTL_USTRING_H_
41 #include <rtl/ustring.h>
42 #endif
44 #ifndef _RTL_USTRING_HXX_
45 #include <rtl/ustring.hxx>
46 #endif
48 #ifndef _RTL_USTRBUF_H_
49 #include <rtl/ustrbuf.h>
50 #endif
52 #ifndef _RTL_USTRBUF_HXX
53 #include <rtl/ustrbuf.hxx>
54 #endif
56 #ifndef _OSL_THREAD_H_
57 #include <osl/thread.h>
58 #endif
60 #ifndef _RTL_STRING_CONST_H_
61 #include <rtl_String_Const.h>
62 #endif
64 #ifndef _RTL_STRING_UTILS_HXX_
65 #include <rtl_String_Utils.hxx>
66 #endif
68 #include "stdio.h"
70 using ::rtl::OUString;
71 using ::rtl::OUStringBuffer;
73 //------------------------------------------------------------------------
74 // test classes
75 //------------------------------------------------------------------------
76 const int MAXBUFLENGTH = 255;
77 //------------------------------------------------------------------------
78 // helper functions
79 //------------------------------------------------------------------------
80 static void unused()
82 (void)kBinaryNumsStr;
83 (void)kOctolNumsStr;
84 (void)kDecimalNumsStr;
85 (void)kHexDecimalNumsStr;
86 (void)kBase36NumsStr;
87 (void)inputChar;
88 (void)input1StrDefault;
89 (void)input1StrNormal;
90 (void)input1StrLastDefault;
91 (void)input1StrLastNormal;
92 unused();
95 //------------------------------------------------------------------------
96 // testing constructors
97 //------------------------------------------------------------------------
98 static sal_Bool test_rtl_OUStringBuffer_ctor_001( hTestResult hRtlTestResult )
101 ::rtl::OUStringBuffer aUStrBuf;
103 bool b1 =
104 aUStrBuf.getLength() == 0 &&
105 ! *(aUStrBuf.getStr()) && aUStrBuf.getCapacity() == 16;
107 ::rtl::OUStringBuffer aUStrBuf2(0);
109 bool b2 =
110 aUStrBuf2.getLength() == 0 &&
111 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: !!! */ 0;
113 return
115 c_rtl_tres_state
117 hRtlTestResult,
118 b1 && b2,
119 "New OUStringBuffer containing no characters",
120 "ctor_001"
125 //------------------------------------------------------------------------
127 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_002(
128 hTestResult hRtlTestResult )
130 ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 );
131 ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp );
132 sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr());
133 return
135 c_rtl_tres_state
137 hRtlTestResult,
138 aUStrBuf.getLength()==aUStrBuftmp.getLength() &&
139 aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() && res ,
140 "New OUStringBuffer from another OUStringBuffer",
141 "ctor_002"
145 //------------------------------------------------------------------------
147 /* static */
148 sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_003(
149 hTestResult hRtlTestResult )
151 ::rtl::OUStringBuffer aUStrBuf1(kTestStr2Len);
152 ::rtl::OUStringBuffer aUStrBuf2(0);
153 ::rtl::OUStringBuffer aUStrBuf3(kNonSInt32Max);
156 bool b1 =
157 aUStrBuf1.getLength() == 0 &&
158 ! *(aUStrBuf1.getStr()) && aUStrBuf1.getCapacity() == kTestStr2Len ;
160 bool b2 =
161 aUStrBuf2.getLength() == 0 &&
162 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: ??? 16 */ 0;
164 bool b3 =
165 aUStrBuf3.getLength() == 0 &&
166 ! *(aUStrBuf3.getStr()) && aUStrBuf3.getCapacity() == kNonSInt32Max;
168 return
170 c_rtl_tres_state
172 hRtlTestResult,
173 b1 && b2 && b3,
174 "New OUStringBuffer containing no characters and contain assigned capacity",
175 "ctor_003( will core dump,because the kSInt32Max )"
181 //------------------------------------------------------------------------
183 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_004(
184 hTestResult hRtlTestResult)
186 ::rtl::OUString aUStrtmp( aUStr1 );
187 ::rtl::OUStringBuffer aUStrBuf( aUStrtmp );
188 sal_Int32 leg = aUStrBuf.getLength();
189 return
191 c_rtl_tres_state
193 hRtlTestResult,
194 aUStrBuf.getStr() == aUStrtmp &&
195 leg == aUStrtmp.pData->length &&
196 aUStrBuf.getCapacity() == leg+16 ,
197 "New OUStringBuffer from OUstring",
198 "ctor_004"
203 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_005(
204 hTestResult hRtlTestResult)
206 ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 );
207 ::rtl::OUString aUStrtmp = aUStrBuftmp.makeStringAndClear();
208 ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp );
209 sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr());
210 sal_Int32 leg = aUStrBuf.getLength();
211 return
213 c_rtl_tres_state
215 hRtlTestResult,
216 aUStrBuf.getLength()==aUStrBuftmp.getLength() &&
217 aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() &&
218 res && leg == 0,
219 "New OUStringBuffer from another OUStringBuffer after makeClearFromString",
220 "ctor_005"
225 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ctors(
226 hTestResult hRtlTestResult )
228 c_rtl_tres_state_start( hRtlTestResult, "ctors");
229 sal_Bool DCState = test_ini_uString();
230 (void)DCState;
231 sal_Bool bTSState = test_rtl_OUStringBuffer_ctor_001( hRtlTestResult );
232 bTSState &= test_rtl_OUStringBuffer_ctor_002( hRtlTestResult);
233 bTSState &= test_rtl_OUStringBuffer_ctor_003( hRtlTestResult);
234 bTSState &= test_rtl_OUStringBuffer_ctor_004( hRtlTestResult);
235 bTSState &= test_rtl_OUStringBuffer_ctor_005( hRtlTestResult);
237 c_rtl_tres_state_end( hRtlTestResult, "ctors");
238 // return( bTSState );
241 //------------------------------------------------------------------------
242 // testing the method makeStringAndClear()
243 //------------------------------------------------------------------------
244 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_makeStringAndClear(
245 hTestResult hRtlTestResult )
247 c_rtl_tres_state_start( hRtlTestResult, "makeStringAndClear");
248 sal_Char methName[MAXBUFLENGTH];
249 sal_Char* pMeth = methName;
251 typedef struct TestCase
253 sal_Char* comments;
254 OUString* expVal;
255 OUStringBuffer* input1;
257 ~TestCase() { delete input1;}
258 } TestCase;
260 OUString arrOUS[6]={
261 OUString( aUStr1 ),
262 OUString( aUStr14 ),
263 OUString( aUStr25 ),
264 OUString( aUStr27 ),
265 OUString( aUStr29 ),
266 OUString( "\0",1,
267 kEncodingRTLTextUSASCII,
268 kConvertFlagsOStringToOUString)
271 TestCase arrTestCase[]={
273 {"two empty strings(def. constructor)", new OUString(),
274 new OUStringBuffer()},
275 {"two empty strings(with a argu)", new OUString(),
276 new OUStringBuffer(26)},
277 {"normal string", new OUString(arrOUS[0]),
278 new OUStringBuffer(arrOUS[0])},
279 {"string with space ", new OUString(arrOUS[1]),
280 new OUStringBuffer(arrOUS[1])},
281 {"empty string", new OUString(arrOUS[2]),
282 new OUStringBuffer(arrOUS[2])},
283 {"string with a character", new OUString(arrOUS[3]),
284 new OUStringBuffer(arrOUS[3])},
285 {"string with special characters", new OUString(arrOUS[4]),
286 new OUStringBuffer(arrOUS[4])},
287 {"string only with (\0)", new OUString(arrOUS[5]),
288 new OUStringBuffer(arrOUS[5])}
291 sal_Bool res = sal_True;
292 sal_uInt32 i;
294 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
296 sal_Bool lastRes =
297 ( arrTestCase[i].input1->makeStringAndClear() ==
298 *( arrTestCase[i].expVal ));
299 lastRes = lastRes && ( arrTestCase[i].input1->getCapacity() == 0 );
300 lastRes = lastRes && ( *(arrTestCase[i].input1->getStr()) == '\0' );
302 c_rtl_tres_state
304 hRtlTestResult,
305 lastRes,
306 arrTestCase[i].comments,
307 createName( pMeth, "makeStringAndClear", i )
310 res &= lastRes;
312 c_rtl_tres_state_end( hRtlTestResult, "makeStringAndClear");
313 // return (res);
315 //------------------------------------------------------------------------
316 // testing the method getLength
317 //------------------------------------------------------------------------
319 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getLength(
320 hTestResult hRtlTestResult)
322 c_rtl_tres_state_start( hRtlTestResult, "getLength");
323 sal_Char methName[MAXBUFLENGTH];
324 sal_Char* pMeth = methName;
326 OUString arrOUS[6]={OUString( aUStr1 ),
327 OUString( "1",1,
328 kEncodingRTLTextUSASCII,
329 kConvertFlagsOStringToOUString),
330 OUString(),
331 OUString( "",0,
332 kEncodingRTLTextUSASCII,
333 kConvertFlagsOStringToOUString),
334 OUString( "\0",1,
335 kEncodingRTLTextUSASCII,
336 kConvertFlagsOStringToOUString),
337 OUString( aUStr2 )};
339 typedef struct TestCase
341 sal_Char* comments;
342 sal_Int32 expVal;
343 OUStringBuffer* input;
344 ~TestCase() { delete input;}
345 } TestCase;
347 TestCase arrTestCase[]={
349 {"length of ascii string", kTestStr1Len,
350 new OUStringBuffer(arrOUS[0]) },
351 {"length of ascci string of size 1", 1,
352 new OUStringBuffer(arrOUS[1])},
353 {"length of empty string", 0,
354 new OUStringBuffer(arrOUS[2])},
355 {"length of empty string (empty ascii string arg)",0,
356 new OUStringBuffer(arrOUS[3])},
357 {"length of empty string (string arg = \"\\0\")", 1,
358 new OUStringBuffer(arrOUS[4])},
359 {"length(>16) of ascii string", kTestStr2Len,
360 new OUStringBuffer(arrOUS[5]) },
361 {"length of empty string (default constructor)", 0,
362 new OUStringBuffer()},
363 {"length of empty string (with capacity)", 0,
364 new OUStringBuffer(26)}
368 sal_Bool res = sal_True;
369 sal_uInt32 i;
371 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
373 sal_Int32 length = arrTestCase[i].input->getLength();
374 sal_Bool lastRes = (length == arrTestCase[i].expVal);
375 c_rtl_tres_state
377 hRtlTestResult,
378 lastRes,
379 arrTestCase[i].comments,
380 createName( pMeth, "getLength", i )
383 res &= lastRes;
385 c_rtl_tres_state_end( hRtlTestResult, "getLength");
386 // return ( res );
388 //------------------------------------------------------------------------
389 // testing the method getCapacity()
390 //------------------------------------------------------------------------
392 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getCapacity(
393 hTestResult hRtlTestResult)
395 c_rtl_tres_state_start( hRtlTestResult, "getCapacity");
396 sal_Char methName[MAXBUFLENGTH];
397 sal_Char* pMeth = methName;
399 OUString arrOUS[6]={OUString( aUStr1 ),
400 OUString( "1",1,
401 kEncodingRTLTextUSASCII,
402 kConvertFlagsOStringToOUString),
403 OUString(),
404 OUString( "",0,
405 kEncodingRTLTextUSASCII,
406 kConvertFlagsOStringToOUString),
407 OUString( "\0",1,
408 kEncodingRTLTextUSASCII,
409 kConvertFlagsOStringToOUString),
410 OUString( aUStr2 )};
412 typedef struct TestCase
414 sal_Char* comments;
415 sal_Int32 expVal;
416 OUStringBuffer* input;
417 ~TestCase() { delete input;}
418 } TestCase;
420 TestCase arrTestCase[]={
422 {"capacity of ascii string", kTestStr1Len+16,
423 new OUStringBuffer(arrOUS[0]) },
424 {"capacity of ascci string of size 1", 1+16,
425 new OUStringBuffer(arrOUS[1]) },
426 {"capacity of empty string", 0+16,
427 new OUStringBuffer(arrOUS[2]) },
428 {"capacity of empty string (empty ascii string arg)",0+16,
429 new OUStringBuffer(arrOUS[3]) },
430 {"capacity of empty string (string arg = \"\\0\")", 1+16,
431 new OUStringBuffer(arrOUS[4]) },
432 {"capacity(>16) of ascii string", kTestStr2Len+16,
433 new OUStringBuffer(arrOUS[5]) },
434 {"capacity of empty string (default constructor)", 16,
435 new OUStringBuffer() },
436 {"capacity of empty string (with capacity -2147483648)", kNonSInt32Max,
437 new OUStringBuffer(kNonSInt32Max) },
438 {"capacity of empty string (with capacity 16)", 16,
439 new OUStringBuffer(16) },
440 {"capacity of empty string (with capacity 6)", 6,
441 new OUStringBuffer(6) },
442 {"capacity of empty string (with capacity 0)", 0,
443 new OUStringBuffer(0) },
444 {"capacity of empty string (with capacity -2)", -2,
445 new OUStringBuffer(-2) }
449 sal_Bool res = sal_True;
450 sal_uInt32 i;
452 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
454 sal_Int32 length = arrTestCase[i].input->getCapacity();
455 sal_Bool lastRes = (length == arrTestCase[i].expVal);
456 c_rtl_tres_state
458 hRtlTestResult,
459 lastRes,
460 arrTestCase[i].comments,
461 createName( pMeth, "getCapacity", i )
464 res &= lastRes;
466 c_rtl_tres_state_end( hRtlTestResult, "getCapacity");
467 // return ( res );
469 //------------------------------------------------------------------------
470 // testing the method ensureCapacity(sal_Int32 minimumCapacity)
471 //------------------------------------------------------------------------
473 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ensureCapacity(
474 hTestResult hRtlTestResult)
476 c_rtl_tres_state_start( hRtlTestResult, "ensureCapacity");
477 sal_Char methName[MAXBUFLENGTH];
478 sal_Char* pMeth = methName;
480 typedef struct TestCase
482 sal_Char* comments;
483 sal_Int32 expVal;
484 OUStringBuffer* input1;
485 sal_Int32 input2;
486 ~TestCase() { delete input1;}
487 } TestCase;
489 TestCase arrTestCase[]={
491 {"capacity equal to 16, minimum is 5 ", 16,
492 new OUStringBuffer(), 5 },
493 {"capacity equal to 16, minimum is -5", 16,
494 new OUStringBuffer(), -5},
495 {"capacity equal to 16, minimum is 0", 16,
496 new OUStringBuffer(), 0},
497 {"capacity equal to 16, minimum is 20", 20, //the testcase is based on comments
498 new OUStringBuffer(), 20},
499 {"capacity equal to 16, minimum is 50", 50,
500 new OUStringBuffer(), 50},
501 {"capacity equal to 6, minimum is 20", 20,
502 new OUStringBuffer(6), 20 },
503 {"capacity equal to 6, minimum is 2", 6,
504 new OUStringBuffer(6), 2},
505 {"capacity equal to 6, minimum is -6", 6,
506 new OUStringBuffer(6), -6},
507 {"capacity equal to 6, minimum is -6", 10, //the testcase is based on comments
508 new OUStringBuffer(6), 10},
509 {"capacity equal to 0, minimum is 6", 6,
510 new OUStringBuffer(0), 6},
511 {"capacity equal to 0, minimum is 1", 2, //the testcase is based on comments
512 new OUStringBuffer(0), 1},
514 {"capacity equal to 0, minimum is -1", 0,
515 new OUStringBuffer(0), -1},
517 {"capacity equal to -2147483648, minimum is 65535", 65535,
518 new OUStringBuffer(kNonSInt32Max), 65535},
519 {"capacity equal to -2147483648, minimum is -1", 2,
520 new OUStringBuffer(kNonSInt32Max), -1},
521 {"capacity equal to -2147483648, minimum is 0", 2,
522 new OUStringBuffer(kNonSInt32Max), 0},
523 {"capacity equal to -2147483648, minimum is -2147483648", kNonSInt32Max,
524 new OUStringBuffer(kNonSInt32Max), kNonSInt32Max}
528 sal_Bool res = sal_True;
529 sal_uInt32 i;
531 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
533 arrTestCase[i].input1->ensureCapacity(arrTestCase[i].input2);
534 sal_Int32 length = arrTestCase[i].input1->getCapacity();
535 sal_Bool lastRes = (length == arrTestCase[i].expVal);
537 c_rtl_tres_state
539 hRtlTestResult,
540 lastRes,
541 arrTestCase[i].comments,
542 createName( pMeth, "ensureCapacity", i )
545 res &= lastRes;
547 c_rtl_tres_state_end( hRtlTestResult, "ensureCapacity");
548 // return ( res );
550 //------------------------------------------------------------------------
551 // testing the method setLength(sal_Int32 newLength)
552 //------------------------------------------------------------------------
554 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_setLength(
555 hTestResult hRtlTestResult)
557 c_rtl_tres_state_start( hRtlTestResult, "setLength");
558 sal_Char methName[MAXBUFLENGTH];
559 sal_Char* pMeth = methName;
561 OUString arrOUS[6]={OUString( aUStr1 ),
562 OUString( aUStr27),
563 OUString(),
564 OUString( "",0,
565 kEncodingRTLTextUSASCII,
566 kConvertFlagsOStringToOUString),
567 OUString( "\0",1,
568 kEncodingRTLTextUSASCII,
569 kConvertFlagsOStringToOUString),
570 OUString( aUStr2 )};
572 typedef struct TestCase
574 sal_Char* comments;
575 sal_Int32 expVal1;
576 OUString* expVal2;
577 sal_Int32 expVal3;
578 OUStringBuffer* input1;
579 sal_Int32 input2;
580 ~TestCase() { delete input1; delete expVal2;}
581 } TestCase;
583 TestCase arrTestCase[]={
585 {"newLength more than the capacity of OUStringBuffer(aUStr1)",
586 50, new OUString(aUStr1), 50,
587 new OUStringBuffer(arrOUS[0]), 50 },
588 {"newLength more than the length of OUStringBuffer(aUStr1)",
589 kTestStr13Len, new OUString(aUStr1), 32,
590 new OUStringBuffer(arrOUS[0]), kTestStr13Len },
591 {"newLength equal to the length of OUStringBuffer(aUStr1)",
592 kTestStr1Len, new OUString(aUStr1), 32,
593 new OUStringBuffer(arrOUS[0]), kTestStr1Len },
594 {"newLength less than the length of OUStringBuffer(aUStr1)",
595 kTestStr7Len, new OUString(aUStr7), 32,
596 new OUStringBuffer(arrOUS[0]), kTestStr7Len},
597 {"newLength equal to 0",
598 0, new OUString(), 32,
599 new OUStringBuffer(arrOUS[0]), 0},
600 {"newLength more than the capacity of OUStringBuffer(1)",
601 25, new OUString(arrOUS[1]), 25,
602 new OUStringBuffer(arrOUS[1]), 25},
603 {"newLength more than the length of OUStringBuffer(1)",
604 5, new OUString(arrOUS[1]), 17,
605 new OUStringBuffer(arrOUS[1]), 5},
606 {"newLength equal to the length of OUStringBuffer(1)",
607 kTestStr27Len, new OUString(arrOUS[1]), 17,
608 new OUStringBuffer(arrOUS[1]), kTestStr27Len},
609 {"newLength less than the length of OUStringBuffer(1)",
610 0, new OUString(), 17,
611 new OUStringBuffer(arrOUS[1]), 0},
612 {"newLength more than the capacity of OUStringBuffer()",
613 20, new OUString(), 20,
614 new OUStringBuffer(arrOUS[2]), 20},
615 {"newLength more than the length of OUStringBuffer()",
616 3, new OUString(), 16,
617 new OUStringBuffer(arrOUS[2]), 3},
618 {"newLength less than the length of OUStringBuffer()",
619 0, new OUString(), 16,
620 new OUStringBuffer(arrOUS[2]), 0},
621 {"newLength more than the capacity of OUStringBuffer("")",
622 20, new OUString(), 20,
623 new OUStringBuffer(arrOUS[3]), 20},
624 {"newLength more than the length of OUStringBuffer("")",
625 5, new OUString(), 16,
626 new OUStringBuffer(arrOUS[3]), 5},
627 {"newLength less than the length of OUStringBuffer("")",
628 0, new OUString(), 16,
629 new OUStringBuffer(arrOUS[3]), 0},
630 {"newLength more than the length of OUStringBuffer(\0)",
631 20, new OUString(), 20,
632 new OUStringBuffer(arrOUS[4]), 20},
633 {"newLength more than the length of OUStringBuffer(\0)",
634 5, new OUString(), 16,
635 new OUStringBuffer(arrOUS[4]), 5},
636 {"newLength less than the length of OUStringBuffer(\0)",
637 0, new OUString(), 16,
638 new OUStringBuffer(arrOUS[4]), 0},
639 {"newLength more than the capacity of OUStringBuffer(aUStr2)",
640 50, new OUString(aUStr2), 66,
641 new OUStringBuffer(arrOUS[5]), 50,},
642 {"newLength more than the length of OUStringBuffer(aUStr2)",
643 40, new OUString(aUStr2), 48,
644 new OUStringBuffer(arrOUS[5]), 40,},
645 {"newLength equal to the length of OUStringBuffer(aUStr2)",
646 kTestStr2Len, new OUString(aUStr2), 48,
647 new OUStringBuffer(arrOUS[5]), kTestStr2Len,},
648 {"newLength less than the length of OUStringBuffer(aUStr2)",
649 kTestStr7Len, new OUString(aUStr7), 48,
650 new OUStringBuffer(arrOUS[5]), kTestStr7Len},
651 {"newLength equal to 0",
652 0, new OUString(), 48,
653 new OUStringBuffer(arrOUS[5]), 0}
658 sal_Bool res = sal_True;
659 sal_uInt32 i;
661 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
663 arrTestCase[i].input1->setLength(arrTestCase[i].input2);
664 sal_Bool lastRes =
665 ( arrTestCase[i].input1->getStr() == *(arrTestCase[i].expVal2) &&
666 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal1 &&
667 arrTestCase[i].input1->getCapacity() == arrTestCase[i].expVal3 );
669 c_rtl_tres_state
671 hRtlTestResult,
672 lastRes,
673 arrTestCase[i].comments,
674 createName( pMeth, "setLength", i )
677 res &= lastRes;
679 c_rtl_tres_state_end( hRtlTestResult, "setLength");
680 // return ( res );
682 //------------------------------------------------------------------------
683 // testing the operator const sal_Unicode * (csuc for short)
684 //------------------------------------------------------------------------
685 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_csuc(
686 hTestResult hRtlTestResult)
688 c_rtl_tres_state_start( hRtlTestResult, "csuc");
689 sal_Char methName[MAXBUFLENGTH];
690 sal_Char* pMeth = methName;
692 const sal_Unicode tmpUC=0x0;
693 rtl_uString* tmpUstring = NULL;
694 const sal_Char *tmpStr=kTestStr1;
695 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
696 //sal_Int32 cmpLen = 0;
697 OUString tempString(aUStr1);
699 rtl_string2UString( &tmpUstring, tmpStr, tmpLen,
700 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
701 OSL_ASSERT(tmpUstring != NULL);
704 typedef struct TestCase
706 sal_Char* comments;
707 const sal_Unicode* expVal;
708 sal_Int32 cmpLen;
709 OUStringBuffer* input1;
710 ~TestCase() { delete input1; }
711 } TestCase;
713 TestCase arrTestCase[] =
715 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
716 new OUStringBuffer(tempString)},
717 {"test empty ustring",&tmpUC, 1, new OUStringBuffer()}
720 sal_Bool res = sal_True;
721 sal_uInt32 i;
722 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
724 const sal_Unicode* pstr = *arrTestCase[i].input1;
726 res &= c_rtl_tres_state
728 hRtlTestResult,
729 cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ),
730 arrTestCase[i].comments,
731 createName( pMeth, "const sal_Unicode*", i )
734 c_rtl_tres_state_end( hRtlTestResult, "csuc");
735 // return ( res );
737 //------------------------------------------------------------------------
738 // testing the method const sal_Unicode * getStr()
739 //------------------------------------------------------------------------
740 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getStr(
741 hTestResult hRtlTestResult)
743 c_rtl_tres_state_start( hRtlTestResult, "getStr");
744 sal_Char methName[MAXBUFLENGTH];
745 sal_Char* pMeth = methName;
747 const sal_Unicode tmpUC=0x0;
748 rtl_uString* tmpUstring = NULL;
749 const sal_Char *tmpStr=kTestStr1;
750 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
751 //sal_Int32 cmpLen = 0;
752 OUString tempString(aUStr1);
754 rtl_string2UString( &tmpUstring, tmpStr, tmpLen,
755 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
756 OSL_ASSERT(tmpUstring != NULL);
759 typedef struct TestCase
761 sal_Char* comments;
762 const sal_Unicode* expVal;
763 sal_Int32 cmpLen;
764 OUStringBuffer* input1;
765 ~TestCase() { delete input1;}
766 } TestCase;
768 TestCase arrTestCase[] =
770 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
771 new OUStringBuffer(tempString)},
772 {"test empty ustring",&tmpUC, 1, new OUStringBuffer()}
775 sal_Bool res = sal_True;
776 sal_uInt32 i;
777 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
779 const sal_Unicode* pstr = arrTestCase[i].input1->getStr();
781 res &= c_rtl_tres_state
783 hRtlTestResult,
784 cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ),
785 arrTestCase[i].comments,
786 createName( pMeth, "getStr", i )
789 c_rtl_tres_state_end( hRtlTestResult, "getStr");
790 // return ( res );
792 //------------------------------------------------------------------------
793 // testing the method append(const OUString &str)
794 //------------------------------------------------------------------------
796 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_001(
797 hTestResult hRtlTestResult)
799 sal_Char methName[MAXBUFLENGTH];
800 sal_Char* pMeth = methName;
802 OUString arrOUS[5]={OUString( aUStr7 ),
803 OUString(),
804 OUString( aUStr25 ),
805 OUString( "\0",1,
806 kEncodingRTLTextUSASCII,
807 kConvertFlagsOStringToOUString),
808 OUString( aUStr28 )};
810 typedef struct TestCase
812 sal_Char* comments;
813 OUString* expVal;
814 OUStringBuffer* input1;
815 OUString* input2;
817 ~TestCase() { delete input1; delete input2; delete expVal; }
818 } TestCase;
820 TestCase arrTestCase[]={
822 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
823 new OUString(aUStr1),
824 new OUStringBuffer(arrOUS[0]), new OUString(aUStr8) },
825 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
826 new OUString(aUStr2),
827 new OUStringBuffer(arrOUS[0]), new OUString(aUStr36) },
828 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
829 new OUString(aUStr37),
830 new OUStringBuffer(arrOUS[0]), new OUString(aUStr23) },
831 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
832 new OUString(aUStr7),
833 new OUStringBuffer(arrOUS[0]), new OUString()},
834 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
835 new OUString(aUStr7),
836 new OUStringBuffer(arrOUS[1]), new OUString(aUStr7)},
837 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
838 new OUString(aUStr2),
839 new OUStringBuffer(arrOUS[1]), new OUString(aUStr2)},
840 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
841 new OUString(aUStr1),
842 new OUStringBuffer(arrOUS[1]), new OUString(aUStr1) },
843 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
844 new OUString(),
845 new OUStringBuffer(arrOUS[1]), new OUString()},
846 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
847 new OUString(aUStr7),
848 new OUStringBuffer(arrOUS[2]), new OUString(aUStr7)},
849 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
850 new OUString(aUStr2),
851 new OUStringBuffer(arrOUS[2]), new OUString(aUStr2)},
852 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
853 new OUString(aUStr1),
854 new OUStringBuffer(arrOUS[2]), new OUString(aUStr1) },
855 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
856 new OUString(),
857 new OUStringBuffer(arrOUS[2]), new OUString()},
858 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
859 new OUString(aUStr7),
860 new OUStringBuffer(arrOUS[3]), new OUString(aUStr7)},
861 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
862 new OUString(aUStr2),
863 new OUStringBuffer(arrOUS[3]), new OUString(aUStr2)},
864 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
865 new OUString(aUStr1),
866 new OUStringBuffer(arrOUS[3]), new OUString(aUStr1) },
867 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
868 new OUString(),
869 new OUStringBuffer(arrOUS[3]), new OUString()},
870 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
871 new OUString(aUStr29),
872 new OUStringBuffer(arrOUS[4]), new OUString(aUStr38)},
873 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
874 new OUString(aUStr39),
875 new OUStringBuffer(arrOUS[4]), new OUString(aUStr17)},
876 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
877 new OUString(aUStr40),
878 new OUStringBuffer(arrOUS[4]), new OUString(aUStr31) },
879 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
880 new OUString(aUStr28),
881 new OUStringBuffer(arrOUS[4]), new OUString()}
885 sal_Bool res = sal_True;
886 sal_uInt32 i;
888 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
890 arrTestCase[i].input1->append( *(arrTestCase[i].input2) );
891 sal_Bool lastRes =
892 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
893 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
895 c_rtl_tres_state
897 hRtlTestResult,
898 lastRes,
899 arrTestCase[i].comments,
900 createName( pMeth, "append(const OUString &str)_001", i )
904 res &= lastRes;
907 return ( res );
909 //------------------------------------------------------------------------
910 // testing the method append( const sal_Unicode * str )
911 //------------------------------------------------------------------------
913 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_002(
914 hTestResult hRtlTestResult)
916 sal_Char methName[MAXBUFLENGTH];
917 sal_Char* pMeth = methName;
919 OUString arrOUS[5]={OUString( aUStr7 ),
920 OUString(),
921 OUString( aUStr25 ),
922 OUString( "\0",1,
923 kEncodingRTLTextUSASCII,
924 kConvertFlagsOStringToOUString),
925 OUString( aUStr28 )};
927 typedef struct TestCase
929 sal_Char* comments;
930 OUString* expVal;
931 OUStringBuffer* input1;
932 sal_Unicode* input2;
934 ~TestCase() { delete input1; delete expVal; }
935 } TestCase;
937 TestCase arrTestCase[]={
939 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
940 new OUString(aUStr1),
941 new OUStringBuffer(arrOUS[0]), aUStr8 },
942 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
943 new OUString(aUStr2),
944 new OUStringBuffer(arrOUS[0]), aUStr36 },
945 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
946 new OUString(aUStr37),
947 new OUStringBuffer(arrOUS[0]), aUStr23 },
948 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
949 new OUString(aUStr7),
950 new OUStringBuffer(arrOUS[0]), aUStr25 },
951 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
952 new OUString(aUStr7),
953 new OUStringBuffer(arrOUS[1]), aUStr7 },
954 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
955 new OUString(aUStr2),
956 new OUStringBuffer(arrOUS[1]), aUStr2 },
957 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
958 new OUString(aUStr1),
959 new OUStringBuffer(arrOUS[1]), aUStr1 },
960 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
961 new OUString(),
962 new OUStringBuffer(arrOUS[1]), aUStr25 },
963 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
964 new OUString(aUStr7),
965 new OUStringBuffer(arrOUS[2]), aUStr7 },
966 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
967 new OUString(aUStr2),
968 new OUStringBuffer(arrOUS[2]), aUStr2 },
969 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
970 new OUString(aUStr1),
971 new OUStringBuffer(arrOUS[2]), aUStr1 },
972 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
973 new OUString(),
974 new OUStringBuffer(arrOUS[2]), aUStr25 },
975 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
976 new OUString(aUStr7),
977 new OUStringBuffer(arrOUS[3]), aUStr7 },
978 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
979 new OUString(aUStr2),
980 new OUStringBuffer(arrOUS[3]), aUStr2 },
981 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
982 new OUString(aUStr1),
983 new OUStringBuffer(arrOUS[3]), aUStr1 },
984 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
985 new OUString(),
986 new OUStringBuffer(arrOUS[3]), aUStr25 },
987 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
988 new OUString(aUStr29),
989 new OUStringBuffer(arrOUS[4]), aUStr38 },
990 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
991 new OUString(aUStr39),
992 new OUStringBuffer(arrOUS[4]), aUStr17 },
993 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
994 new OUString(aUStr40),
995 new OUStringBuffer(arrOUS[4]), aUStr31 },
996 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
997 new OUString(aUStr28),
998 new OUStringBuffer(arrOUS[4]), aUStr25 }
1002 sal_Bool res = sal_True;
1003 sal_uInt32 i;
1005 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1007 arrTestCase[i].input1->append( arrTestCase[i].input2 );
1008 sal_Bool lastRes =
1009 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1010 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1012 c_rtl_tres_state
1014 hRtlTestResult,
1015 lastRes,
1016 arrTestCase[i].comments,
1017 createName( pMeth, "append( const sal_Unicode * str )_002", i )
1021 res &= lastRes;
1024 return ( res );
1026 //------------------------------------------------------------------------
1027 // testing the method append( const sal_Unicode * str, sal_Int32 len)
1028 //------------------------------------------------------------------------
1030 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_003(
1031 hTestResult hRtlTestResult)
1033 sal_Char methName[MAXBUFLENGTH];
1034 sal_Char* pMeth = methName;
1036 OUString arrOUS[5]={OUString( aUStr7 ),
1037 OUString(),
1038 OUString( aUStr25 ),
1039 OUString( "\0",1,
1040 kEncodingRTLTextUSASCII,
1041 kConvertFlagsOStringToOUString),
1042 OUString( aUStr28 )};
1044 typedef struct TestCase
1046 sal_Char* comments;
1047 OUString* expVal;
1048 OUStringBuffer* input1;
1049 sal_Unicode* input2;
1050 sal_Int32 input3;
1052 ~TestCase() { delete input1; delete expVal; }
1053 } TestCase;
1055 TestCase arrTestCase[]={
1057 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1058 new OUString(aUStr1),
1059 new OUStringBuffer(arrOUS[0]), aUStr36, 12 },
1060 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1061 new OUString(aUStr2),
1062 new OUStringBuffer(arrOUS[0]), aUStr36, 28 },
1063 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1064 new OUString(aUStr37),
1065 new OUStringBuffer(arrOUS[0]), aUStr23, 16 },
1066 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1067 new OUString(aUStr7),
1068 new OUStringBuffer(arrOUS[0]), aUStr2, 0 },
1069 /* LLA: input3 must null < 0
1070 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1071 new OUString(aUStr41),
1072 new OUStringBuffer(arrOUS[0]), aUStr2, -1 },
1074 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1075 new OUString(aUStr7),
1076 new OUStringBuffer(arrOUS[1]), aUStr2, 4 },
1077 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1078 new OUString(aUStr2),
1079 new OUStringBuffer(arrOUS[1]), aUStr2, 32 },
1080 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1081 new OUString(aUStr1),
1082 new OUStringBuffer(arrOUS[1]), aUStr2, 16 },
1083 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1084 new OUString(),
1085 new OUStringBuffer(arrOUS[1]), aUStr2, 0 },
1086 /* LLA: input3 must null < 0
1087 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1088 new OUString(),
1089 new OUStringBuffer(arrOUS[1]), aUStr2, -1 },
1091 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1092 new OUString(aUStr7),
1093 new OUStringBuffer(arrOUS[2]), aUStr2, 4 },
1094 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1095 new OUString(aUStr2),
1096 new OUStringBuffer(arrOUS[2]), aUStr2, 32 },
1097 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1098 new OUString(aUStr1),
1099 new OUStringBuffer(arrOUS[2]), aUStr2, 16 },
1100 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1101 new OUString(),
1102 new OUStringBuffer(arrOUS[2]), aUStr2, 0 },
1103 /* LLA: input3 must null < 0
1104 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1105 new OUString(),
1106 new OUStringBuffer(arrOUS[2]), aUStr2, -1 },
1108 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1109 new OUString(aUStr7),
1110 new OUStringBuffer(arrOUS[3]), aUStr2, 4 },
1111 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1112 new OUString(aUStr2),
1113 new OUStringBuffer(arrOUS[3]), aUStr2, 32 },
1114 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1115 new OUString(aUStr1),
1116 new OUStringBuffer(arrOUS[3]), aUStr2, 16 },
1117 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1118 new OUString(),
1119 new OUStringBuffer(arrOUS[3]), aUStr2, 0 },
1120 /* LLA: input3 must null < 0
1121 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1122 new OUString(),
1123 new OUStringBuffer(arrOUS[3]), aUStr2, -1 },
1125 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1126 new OUString(aUStr29),
1127 new OUStringBuffer(arrOUS[4]), aUStr38, 7 },
1128 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1129 new OUString(aUStr39),
1130 new OUStringBuffer(arrOUS[4]), aUStr17, 22 },
1131 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1132 new OUString(aUStr40),
1133 new OUStringBuffer(arrOUS[4]), aUStr31, 16 },
1134 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1135 new OUString(aUStr28),
1136 new OUStringBuffer(arrOUS[4]), aUStr2, 0 },
1140 sal_Bool res = sal_True;
1141 sal_uInt32 i;
1143 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1145 arrTestCase[i].input1->append(
1146 arrTestCase[i].input2, arrTestCase[i].input3);
1147 sal_Bool lastRes =
1148 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1149 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1151 c_rtl_tres_state
1153 hRtlTestResult,
1154 lastRes,
1155 arrTestCase[i].comments,
1156 createName( pMeth, "append( const sal_Unicode * str, sal_Int32 len)_003", i )
1160 res &= lastRes;
1163 return ( res );
1165 //------------------------------------------------------------------------
1166 // testing the method append(sal_Bool b)
1167 //------------------------------------------------------------------------
1169 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_004(
1170 hTestResult hRtlTestResult)
1172 sal_Char methName[MAXBUFLENGTH];
1173 sal_Char* pMeth = methName;
1175 OUString arrOUS[5]={OUString( aUStr7 ),
1176 OUString(),
1177 OUString( aUStr25 ),
1178 OUString( "\0",1,
1179 kEncodingRTLTextUSASCII,
1180 kConvertFlagsOStringToOUString),
1181 OUString( aUStr28 )};
1183 typedef struct TestCase
1185 sal_Char* comments;
1186 OUString* expVal;
1187 OUStringBuffer* input1;
1188 sal_Bool input2;
1190 ~TestCase() { delete input1; delete expVal; }
1191 } TestCase;
1193 TestCase arrTestCase[]={
1195 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[0]",
1196 new OUString(aUStr45),
1197 new OUStringBuffer(arrOUS[0]), sal_True },
1198 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[0]",
1199 new OUString(aUStr46),
1200 new OUStringBuffer(arrOUS[0]), sal_False },
1201 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[1]",
1202 new OUString(aUStr47),
1203 new OUStringBuffer(arrOUS[1]), sal_True },
1204 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[1]",
1205 new OUString(aUStr48),
1206 new OUStringBuffer(arrOUS[1]), sal_False },
1207 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[2]",
1208 new OUString(aUStr47),
1209 new OUStringBuffer(arrOUS[2]), sal_True },
1210 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[2]",
1211 new OUString(aUStr48),
1212 new OUStringBuffer(arrOUS[2]), sal_False },
1213 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[3]",
1214 new OUString(aUStr47),
1215 new OUStringBuffer(arrOUS[3]), sal_True },
1216 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[3]",
1217 new OUString(aUStr48),
1218 new OUStringBuffer(arrOUS[3]), sal_False },
1219 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[4]",
1220 new OUString(aUStr49),
1221 new OUStringBuffer(arrOUS[4]), sal_True },
1222 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[4]",
1223 new OUString(aUStr50),
1224 new OUStringBuffer(arrOUS[4]), sal_False }
1228 sal_Bool res = sal_True;
1229 sal_uInt32 i;
1231 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1233 arrTestCase[i].input1->append(
1234 arrTestCase[i].input2 );
1235 sal_Bool lastRes =
1236 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1237 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1239 c_rtl_tres_state
1241 hRtlTestResult,
1242 lastRes,
1243 arrTestCase[i].comments,
1244 createName( pMeth, "append( sal_Bool b)_004", i )
1248 res &= lastRes;
1251 return ( res );
1254 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appends(
1255 hTestResult hRtlTestResult )
1257 c_rtl_tres_state_start( hRtlTestResult, "appends");
1258 sal_Bool bTSState = test_rtl_OUStringBuffer_append_001( hRtlTestResult );
1259 bTSState &= test_rtl_OUStringBuffer_append_002( hRtlTestResult);
1260 bTSState &= test_rtl_OUStringBuffer_append_003( hRtlTestResult);
1261 bTSState &= test_rtl_OUStringBuffer_append_004( hRtlTestResult);
1263 c_rtl_tres_state_end( hRtlTestResult, "appends");
1264 // return( bTSState );
1266 //------------------------------------------------------------------------
1267 // testing the method appendAscii( const sal_Char * str )
1268 //------------------------------------------------------------------------
1270 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_001(
1271 hTestResult hRtlTestResult)
1273 sal_Char methName[MAXBUFLENGTH];
1274 sal_Char* pMeth = methName;
1276 OUString arrOUS[5]={OUString( aUStr7 ),
1277 OUString(),
1278 OUString( aUStr25 ),
1279 OUString( "\0",1,
1280 kEncodingRTLTextUSASCII,
1281 kConvertFlagsOStringToOUString),
1282 OUString( aUStr28 )};
1284 typedef struct TestCase
1286 sal_Char* comments;
1287 OUString* expVal;
1288 OUStringBuffer* input1;
1289 const sal_Char* input2;
1291 ~TestCase() { delete input1; delete expVal; }
1292 } TestCase;
1294 TestCase arrTestCase[]={
1296 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1297 new OUString(aUStr1),
1298 new OUStringBuffer(arrOUS[0]), kTestStr8 },
1299 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1300 new OUString(aUStr2),
1301 new OUStringBuffer(arrOUS[0]), kTestStr36 },
1302 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1303 new OUString(aUStr37),
1304 new OUStringBuffer(arrOUS[0]), kTestStr23 },
1305 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1306 new OUString(aUStr7),
1307 new OUStringBuffer(arrOUS[0]), kTestStr25 },
1308 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1309 new OUString(aUStr7),
1310 new OUStringBuffer(arrOUS[1]), kTestStr7 },
1311 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1312 new OUString(aUStr2),
1313 new OUStringBuffer(arrOUS[1]), kTestStr2 },
1314 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1315 new OUString(aUStr1),
1316 new OUStringBuffer(arrOUS[1]), kTestStr1 },
1317 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1318 new OUString(),
1319 new OUStringBuffer(arrOUS[1]), kTestStr25 },
1320 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1321 new OUString(aUStr7),
1322 new OUStringBuffer(arrOUS[2]), kTestStr7 },
1323 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1324 new OUString(aUStr2),
1325 new OUStringBuffer(arrOUS[2]), kTestStr2 },
1326 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1327 new OUString(aUStr1),
1328 new OUStringBuffer(arrOUS[2]), kTestStr1 },
1329 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1330 new OUString(),
1331 new OUStringBuffer(arrOUS[2]), kTestStr25 },
1332 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1333 new OUString(aUStr7),
1334 new OUStringBuffer(arrOUS[3]), kTestStr7 },
1335 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1336 new OUString(aUStr2),
1337 new OUStringBuffer(arrOUS[3]), kTestStr2 },
1338 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1339 new OUString(aUStr1),
1340 new OUStringBuffer(arrOUS[3]), kTestStr1 },
1341 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1342 new OUString(),
1343 new OUStringBuffer(arrOUS[3]), kTestStr25 },
1344 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1345 new OUString(aUStr29),
1346 new OUStringBuffer(arrOUS[4]), kTestStr38 },
1347 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1348 new OUString(aUStr39),
1349 new OUStringBuffer(arrOUS[4]), kTestStr17 },
1350 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1351 new OUString(aUStr40),
1352 new OUStringBuffer(arrOUS[4]), kTestStr31 },
1353 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1354 new OUString(aUStr28),
1355 new OUStringBuffer(arrOUS[4]), kTestStr25 }
1359 sal_Bool res = sal_True;
1360 sal_uInt32 i;
1362 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1364 arrTestCase[i].input1->appendAscii( arrTestCase[i].input2 );
1365 sal_Bool lastRes =
1366 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1367 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1369 c_rtl_tres_state
1371 hRtlTestResult,
1372 lastRes,
1373 arrTestCase[i].comments,
1374 createName( pMeth, "appendAscii_001", i )
1377 res &= lastRes;
1379 return ( res );
1381 //------------------------------------------------------------------------
1382 // testing the method appendAscii( const sal_Char * str, sal_Int32 len)
1383 //------------------------------------------------------------------------
1385 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_002(
1386 hTestResult hRtlTestResult)
1388 sal_Char methName[MAXBUFLENGTH];
1389 sal_Char* pMeth = methName;
1391 OUString arrOUS[5]={OUString( aUStr7 ),
1392 OUString(),
1393 OUString( aUStr25 ),
1394 OUString( "\0",1,
1395 kEncodingRTLTextUSASCII,
1396 kConvertFlagsOStringToOUString),
1397 OUString( aUStr28 )};
1399 typedef struct TestCase
1401 sal_Char* comments;
1402 OUString* expVal;
1403 OUStringBuffer* input1;
1404 const sal_Char* input2;
1405 sal_Int32 input3;
1407 ~TestCase() { delete input1; delete expVal; }
1408 } TestCase;
1410 TestCase arrTestCase[]={
1412 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1413 new OUString(aUStr1),
1414 new OUStringBuffer(arrOUS[0]), kTestStr36, 12 },
1415 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1416 new OUString(aUStr2),
1417 new OUStringBuffer(arrOUS[0]), kTestStr36, 28 },
1418 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1419 new OUString(aUStr37),
1420 new OUStringBuffer(arrOUS[0]), kTestStr23, 16 },
1421 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1422 new OUString(aUStr7),
1423 new OUStringBuffer(arrOUS[0]), kTestStr2, 0 },
1424 /* LLA: input3 must null < 0
1425 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1426 new OUString(aUStr41),
1427 new OUStringBuffer(arrOUS[0]), kTestStr2, -1 },
1429 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1430 new OUString(aUStr7),
1431 new OUStringBuffer(arrOUS[1]), kTestStr2, 4 },
1432 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1433 new OUString(aUStr2),
1434 new OUStringBuffer(arrOUS[1]), kTestStr2, 32 },
1435 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1436 new OUString(aUStr1),
1437 new OUStringBuffer(arrOUS[1]), kTestStr2, 16 },
1438 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1439 new OUString(),
1440 new OUStringBuffer(arrOUS[1]), kTestStr2, 0 },
1441 /* LLA: input3 must null < 0
1442 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1443 new OUString(),
1444 new OUStringBuffer(arrOUS[1]), kTestStr2, -1 },
1446 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1447 new OUString(aUStr7),
1448 new OUStringBuffer(arrOUS[2]), kTestStr2, 4 },
1449 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1450 new OUString(aUStr2),
1451 new OUStringBuffer(arrOUS[2]), kTestStr2, 32 },
1452 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1453 new OUString(aUStr1),
1454 new OUStringBuffer(arrOUS[2]), kTestStr2, 16 },
1455 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1456 new OUString(),
1457 new OUStringBuffer(arrOUS[2]), kTestStr2, 0 },
1458 /* LLA: input3 must null < 0
1459 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1460 new OUString(),
1461 new OUStringBuffer(arrOUS[2]), kTestStr2, -1 },
1463 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1464 new OUString(aUStr7),
1465 new OUStringBuffer(arrOUS[3]), kTestStr2, 4 },
1466 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1467 new OUString(aUStr2),
1468 new OUStringBuffer(arrOUS[3]), kTestStr2, 32 },
1469 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1470 new OUString(aUStr1),
1471 new OUStringBuffer(arrOUS[3]), kTestStr2, 16 },
1472 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1473 new OUString(),
1474 new OUStringBuffer(arrOUS[3]), kTestStr2, 0 },
1475 /* LLA: input3 must null < 0
1476 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1477 new OUString(),
1478 new OUStringBuffer(arrOUS[3]), kTestStr2, -1 },
1480 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1481 new OUString(aUStr29),
1482 new OUStringBuffer(arrOUS[4]), kTestStr38, 7 },
1483 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1484 new OUString(aUStr39),
1485 new OUStringBuffer(arrOUS[4]), kTestStr17, 22 },
1486 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1487 new OUString(aUStr40),
1488 new OUStringBuffer(arrOUS[4]), kTestStr31, 16 },
1489 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1490 new OUString(aUStr28),
1491 new OUStringBuffer(arrOUS[4]), kTestStr2, 0 },
1495 sal_Bool res = sal_True;
1496 sal_uInt32 i;
1498 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1500 arrTestCase[i].input1->appendAscii(
1501 arrTestCase[i].input2, arrTestCase[i].input3);
1502 sal_Bool lastRes =
1503 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1504 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1506 c_rtl_tres_state
1508 hRtlTestResult,
1509 lastRes,
1510 arrTestCase[i].comments,
1511 createName( pMeth, "appendAscii_002", i )
1515 res &= lastRes;
1517 return ( res );
1519 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appendAsciis(
1520 hTestResult hRtlTestResult )
1522 c_rtl_tres_state_start( hRtlTestResult, "appendAsciis");
1523 sal_Bool bTSState = test_rtl_OUStringBuffer_appendAscii_001( hRtlTestResult );
1524 bTSState &= test_rtl_OUStringBuffer_appendAscii_002( hRtlTestResult);
1526 c_rtl_tres_state_end( hRtlTestResult, "appendAsciis");
1527 // return( bTSState );
1529 // -----------------------------------------------------------------------------
1530 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer( hTestResult hRtlTestResult )
1533 c_rtl_tres_state_start(hRtlTestResult, "rtl_OUStringBuffer" );
1535 test_rtl_OUStringBuffer_ctors( hRtlTestResult );
1536 test_rtl_OUStringBuffer_makeStringAndClear( hRtlTestResult );
1537 test_rtl_OUStringBuffer_getLength( hRtlTestResult );
1538 test_rtl_OUStringBuffer_getCapacity( hRtlTestResult );
1539 test_rtl_OUStringBuffer_ensureCapacity( hRtlTestResult );
1540 test_rtl_OUStringBuffer_setLength( hRtlTestResult );
1541 test_rtl_OUStringBuffer_csuc( hRtlTestResult );
1542 test_rtl_OUStringBuffer_getStr( hRtlTestResult );
1543 test_rtl_OUStringBuffer_appends( hRtlTestResult );
1544 test_rtl_OUStringBuffer_appendAsciis( hRtlTestResult );
1546 c_rtl_tres_state_end(hRtlTestResult, "rtl_OUStringBuffer");
1549 // -----------------------------------------------------------------------------
1550 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
1552 if (_pFunc)
1554 (_pFunc)(&test_rtl_OUStringBuffer, "");
1558 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */