1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtl_OUStringBuffer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
35 #include <sal/types.h>
38 // #ifndef _RTL_TRES_H_
39 // #include <rtl/tres.h>
41 #include <testshl/tresstatewrapper.hxx>
43 #ifndef _RTL_STRING_HXX_
44 #include <rtl/string.hxx>
47 #ifndef _RTL_USTRING_H_
48 #include <rtl/ustring.h>
51 #ifndef _RTL_USTRING_HXX_
52 #include <rtl/ustring.hxx>
55 #ifndef _RTL_USTRBUF_H_
56 #include <rtl/ustrbuf.h>
59 #ifndef _RTL_USTRBUF_HXX
60 #include <rtl/ustrbuf.hxx>
62 //------------------------------------------------------------------------
63 //------------------------------------------------------------------------
64 #ifndef _OSL_THREAD_H_
65 #include <osl/thread.h>
68 #ifndef _RTL_STRING_CONST_H_
69 #include <rtl_String_Const.h>
72 #ifndef _RTL_STRING_UTILS_HXX_
73 #include <rtl_String_Utils.hxx>
79 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
82 const int MAXBUFLENGTH
= 255;
83 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
90 (void)kDecimalNumsStr
;
91 (void)kHexDecimalNumsStr
;
94 (void)input1StrDefault
;
95 (void)input1StrNormal
;
96 (void)input1StrLastDefault
;
97 (void)input1StrLastNormal
;
101 //------------------------------------------------------------------------
102 // testing constructors
103 //------------------------------------------------------------------------
104 static sal_Bool
test_rtl_OUStringBuffer_ctor_001( hTestResult hRtlTestResult
)
107 ::rtl::OUStringBuffer aUStrBuf
;
110 aUStrBuf
.getLength() == 0 &&
111 ! *(aUStrBuf
.getStr()) && aUStrBuf
.getCapacity() == 16;
113 ::rtl::OUStringBuffer
aUStrBuf2(0);
116 aUStrBuf2
.getLength() == 0 &&
117 ! *(aUStrBuf2
.getStr()) && aUStrBuf2
.getCapacity() == /* LLA: !!! */ 0;
125 "New OUStringBuffer containing no characters",
131 //------------------------------------------------------------------------
133 static sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_002(
134 hTestResult hRtlTestResult
)
136 ::rtl::OUStringBuffer
aUStrBuftmp( aUStr1
);
137 ::rtl::OUStringBuffer
aUStrBuf( aUStrBuftmp
);
138 sal_Bool res
= cmpustr(aUStrBuftmp
.getStr(),aUStrBuf
.getStr());
144 aUStrBuf
.getLength()==aUStrBuftmp
.getLength() &&
145 aUStrBuf
.getCapacity() == aUStrBuftmp
.getCapacity() && res
,
146 "New OUStringBuffer from another OUStringBuffer",
151 //------------------------------------------------------------------------
154 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_003(
155 hTestResult hRtlTestResult
)
157 ::rtl::OUStringBuffer
aUStrBuf1(kTestStr2Len
);
159 ::rtl::OUStringBuffer
aUStrBuf2(kSInt32Max
); //will core dump
161 ::rtl::OUStringBuffer
aUStrBuf2(0);
163 ::rtl::OUStringBuffer
aUStrBuf3(kNonSInt32Max
);
167 aUStrBuf1
.getLength() == 0 &&
168 ! *(aUStrBuf1
.getStr()) && aUStrBuf1
.getCapacity() == kTestStr2Len
;
172 aUStrBuf2
.getLength() == 0 &&
173 ! *(aUStrBuf2
.getStr()) && aUStrBuf2
.getCapacity() == kSInt32Max
;
175 aUStrBuf2
.getLength() == 0 &&
176 ! *(aUStrBuf2
.getStr()) && aUStrBuf2
.getCapacity() == /* LLA: ??? 16 */ 0;
179 aUStrBuf3
.getLength() == 0 &&
180 ! *(aUStrBuf3
.getStr()) && aUStrBuf3
.getCapacity() == kNonSInt32Max
;
188 "New OUStringBuffer containing no characters and contain assigned capacity",
189 "ctor_003( will core dump,because the kSInt32Max )"
195 //------------------------------------------------------------------------
197 static sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_004(
198 hTestResult hRtlTestResult
)
200 ::rtl::OUString
aUStrtmp( aUStr1
);
201 ::rtl::OUStringBuffer
aUStrBuf( aUStrtmp
);
202 sal_Int32 leg
= aUStrBuf
.getLength();
208 aUStrBuf
.getStr() == aUStrtmp
&&
209 leg
== aUStrtmp
.pData
->length
&&
210 aUStrBuf
.getCapacity() == leg
+16 ,
211 "New OUStringBuffer from OUstring",
217 static sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_005(
218 hTestResult hRtlTestResult
)
220 ::rtl::OUStringBuffer
aUStrBuftmp( aUStr1
);
221 ::rtl::OUString aUStrtmp
= aUStrBuftmp
.makeStringAndClear();
222 ::rtl::OUStringBuffer
aUStrBuf( aUStrBuftmp
);
223 sal_Bool res
= cmpustr(aUStrBuftmp
.getStr(),aUStrBuf
.getStr());
224 sal_Int32 leg
= aUStrBuf
.getLength();
230 aUStrBuf
.getLength()==aUStrBuftmp
.getLength() &&
231 aUStrBuf
.getCapacity() == aUStrBuftmp
.getCapacity() &&
233 "New OUStringBuffer from another OUStringBuffer after makeClearFromString",
239 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_ctors(
240 hTestResult hRtlTestResult
)
242 c_rtl_tres_state_start( hRtlTestResult
, "ctors");
243 sal_Bool DCState
= test_ini_uString();
245 sal_Bool bTSState
= test_rtl_OUStringBuffer_ctor_001( hRtlTestResult
);
246 bTSState
&= test_rtl_OUStringBuffer_ctor_002( hRtlTestResult
);
247 bTSState
&= test_rtl_OUStringBuffer_ctor_003( hRtlTestResult
);
248 bTSState
&= test_rtl_OUStringBuffer_ctor_004( hRtlTestResult
);
249 bTSState
&= test_rtl_OUStringBuffer_ctor_005( hRtlTestResult
);
251 c_rtl_tres_state_end( hRtlTestResult
, "ctors");
252 // return( bTSState );
255 //------------------------------------------------------------------------
256 // testing the method makeStringAndClear()
257 //------------------------------------------------------------------------
258 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_makeStringAndClear(
259 hTestResult hRtlTestResult
)
261 c_rtl_tres_state_start( hRtlTestResult
, "makeStringAndClear");
262 sal_Char methName
[MAXBUFLENGTH
];
263 sal_Char
* pMeth
= methName
;
265 typedef struct TestCase
269 OUStringBuffer
* input1
;
271 ~TestCase() { delete input1
;}
281 kEncodingRTLTextUSASCII
,
282 kConvertFlagsOStringToOUString
)
285 TestCase arrTestCase
[]={
287 {"two empty strings(def. constructor)", new OUString(),
288 new OUStringBuffer()},
289 {"two empty strings(with a argu)", new OUString(),
290 new OUStringBuffer(26)},
291 {"normal string", new OUString(arrOUS
[0]),
292 new OUStringBuffer(arrOUS
[0])},
293 {"string with space ", new OUString(arrOUS
[1]),
294 new OUStringBuffer(arrOUS
[1])},
295 {"empty string", new OUString(arrOUS
[2]),
296 new OUStringBuffer(arrOUS
[2])},
297 {"string with a character", new OUString(arrOUS
[3]),
298 new OUStringBuffer(arrOUS
[3])},
299 {"string with special characters", new OUString(arrOUS
[4]),
300 new OUStringBuffer(arrOUS
[4])},
301 {"string only with (\0)", new OUString(arrOUS
[5]),
302 new OUStringBuffer(arrOUS
[5])}
305 sal_Bool res
= sal_True
;
308 for(i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
311 ( arrTestCase
[i
].input1
->makeStringAndClear() ==
312 *( arrTestCase
[i
].expVal
));
313 lastRes
= lastRes
&& ( arrTestCase
[i
].input1
->getCapacity() == 0 );
314 lastRes
= lastRes
&& ( *(arrTestCase
[i
].input1
->getStr()) == '\0' );
320 arrTestCase
[i
].comments
,
321 createName( pMeth
, "makeStringAndClear", i
)
326 c_rtl_tres_state_end( hRtlTestResult
, "makeStringAndClear");
329 //------------------------------------------------------------------------
330 // testing the method getLength
331 //------------------------------------------------------------------------
333 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_getLength(
334 hTestResult hRtlTestResult
)
336 c_rtl_tres_state_start( hRtlTestResult
, "getLength");
337 sal_Char methName
[MAXBUFLENGTH
];
338 sal_Char
* pMeth
= methName
;
340 OUString arrOUS
[6]={OUString( aUStr1
),
342 kEncodingRTLTextUSASCII
,
343 kConvertFlagsOStringToOUString
),
346 kEncodingRTLTextUSASCII
,
347 kConvertFlagsOStringToOUString
),
349 kEncodingRTLTextUSASCII
,
350 kConvertFlagsOStringToOUString
),
353 typedef struct TestCase
357 OUStringBuffer
* input
;
358 ~TestCase() { delete input
;}
361 TestCase arrTestCase
[]={
363 {"length of ascii string", kTestStr1Len
,
364 new OUStringBuffer(arrOUS
[0]) },
365 {"length of ascci string of size 1", 1,
366 new OUStringBuffer(arrOUS
[1])},
367 {"length of empty string", 0,
368 new OUStringBuffer(arrOUS
[2])},
369 {"length of empty string (empty ascii string arg)",0,
370 new OUStringBuffer(arrOUS
[3])},
371 {"length of empty string (string arg = '\\0')", 0,
372 new OUStringBuffer(arrOUS
[4])},
373 {"length(>16) of ascii string", kTestStr2Len
,
374 new OUStringBuffer(arrOUS
[5]) },
375 {"length of empty string (default constructor)", 0,
376 new OUStringBuffer()},
377 {"length of empty string (with capacity)", 0,
378 new OUStringBuffer(26)}
382 sal_Bool res
= sal_True
;
385 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
387 sal_Int32 length
= arrTestCase
[i
].input
->getLength();
388 sal_Bool lastRes
= (length
== arrTestCase
[i
].expVal
);
393 arrTestCase
[i
].comments
,
394 createName( pMeth
, "getLength", i
)
399 c_rtl_tres_state_end( hRtlTestResult
, "getLength");
402 //------------------------------------------------------------------------
403 // testing the method getCapacity()
404 //------------------------------------------------------------------------
406 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_getCapacity(
407 hTestResult hRtlTestResult
)
409 c_rtl_tres_state_start( hRtlTestResult
, "getCapacity");
410 sal_Char methName
[MAXBUFLENGTH
];
411 sal_Char
* pMeth
= methName
;
413 OUString arrOUS
[6]={OUString( aUStr1
),
415 kEncodingRTLTextUSASCII
,
416 kConvertFlagsOStringToOUString
),
419 kEncodingRTLTextUSASCII
,
420 kConvertFlagsOStringToOUString
),
422 kEncodingRTLTextUSASCII
,
423 kConvertFlagsOStringToOUString
),
426 typedef struct TestCase
430 OUStringBuffer
* input
;
431 ~TestCase() { delete input
;}
434 TestCase arrTestCase
[]={
436 {"capacity of ascii string", kTestStr1Len
+16,
437 new OUStringBuffer(arrOUS
[0]) },
438 {"capacity of ascci string of size 1", 1+16,
439 new OUStringBuffer(arrOUS
[1]) },
440 {"capacity of empty string", 0+16,
441 new OUStringBuffer(arrOUS
[2]) },
442 {"capacity of empty string (empty ascii string arg)",0+16,
443 new OUStringBuffer(arrOUS
[3]) },
444 {"capacity of empty string (string arg = '\\0')", 0+16,
445 new OUStringBuffer(arrOUS
[4]) },
446 {"capacity(>16) of ascii string", kTestStr2Len
+16,
447 new OUStringBuffer(arrOUS
[5]) },
448 {"capacity of empty string (default constructor)", 16,
449 new OUStringBuffer() },
451 {"capacity of empty string (with capacity 2147483647)(code will core dump)", kSInt32Max
,
452 new OUStringBuffer(kSInt32Max
) },// will core dump
454 {"capacity of empty string (with capacity -2147483648)", kNonSInt32Max
,
455 new OUStringBuffer(kNonSInt32Max
) },
456 {"capacity of empty string (with capacity 16)", 16,
457 new OUStringBuffer(16) },
458 {"capacity of empty string (with capacity 6)", 6,
459 new OUStringBuffer(6) },
460 {"capacity of empty string (with capacity 0)", 0,
461 new OUStringBuffer(0) },
462 {"capacity of empty string (with capacity -2)", -2,
463 new OUStringBuffer(-2) }
467 sal_Bool res
= sal_True
;
470 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
472 sal_Int32 length
= arrTestCase
[i
].input
->getCapacity();
473 sal_Bool lastRes
= (length
== arrTestCase
[i
].expVal
);
478 arrTestCase
[i
].comments
,
479 createName( pMeth
, "getCapacity", i
)
484 c_rtl_tres_state_end( hRtlTestResult
, "getCapacity");
487 //------------------------------------------------------------------------
488 // testing the method ensureCapacity(sal_Int32 minimumCapacity)
489 //------------------------------------------------------------------------
491 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_ensureCapacity(
492 hTestResult hRtlTestResult
)
494 c_rtl_tres_state_start( hRtlTestResult
, "ensureCapacity");
495 sal_Char methName
[MAXBUFLENGTH
];
496 sal_Char
* pMeth
= methName
;
498 typedef struct TestCase
502 OUStringBuffer
* input1
;
504 ~TestCase() { delete input1
;}
507 TestCase arrTestCase
[]={
509 {"capacity equal to 16, minimum is 5 ", 16,
510 new OUStringBuffer(), 5 },
511 {"capacity equal to 16, minimum is -5", 16,
512 new OUStringBuffer(), -5},
513 {"capacity equal to 16, minimum is 0", 16,
514 new OUStringBuffer(), 0},
515 {"capacity equal to 16, minimum is 20", 20, //the testcase is based on comments
516 new OUStringBuffer(), 20},
517 {"capacity equal to 16, minimum is 50", 50,
518 new OUStringBuffer(), 50},
519 {"capacity equal to 6, minimum is 20", 20,
520 new OUStringBuffer(6), 20 },
521 {"capacity equal to 6, minimum is 2", 6,
522 new OUStringBuffer(6), 2},
523 {"capacity equal to 6, minimum is -6", 6,
524 new OUStringBuffer(6), -6},
525 {"capacity equal to 6, minimum is -6", 10, //the testcase is based on comments
526 new OUStringBuffer(6), 10},
527 {"capacity equal to 0, minimum is 6", 6,
528 new OUStringBuffer(0), 6},
529 {"capacity equal to 0, minimum is 1", 2, //the testcase is based on comments
530 new OUStringBuffer(0), 1},
532 {"capacity equal to 0, minimum is -1", 0,
533 new OUStringBuffer(0), -1},
536 {"capacity equal to 2147483647, minimum is 65535", kSInt32Max
,//will core dump
537 new OUStringBuffer(kSInt32Max
), 65535},
538 {"capacity equal to 2147483647, minimum is 2147483647", kSInt32Max
,//will core dump
539 new OUStringBuffer(kSInt32Max
), kSInt32Max
},
540 {"capacity equal to 2147483647, minimum is -1", kSInt32Max
,//will core dump
541 new OUStringBuffer(kSInt32Max
), -1},
542 {"capacity equal to 2147483647, minimum is 0", kSInt32Max
,//will core dump
543 new OUStringBuffer(kSInt32Max
), 0},
544 {"capacity equal to 2147483647, minimum is -2147483648", kSInt32Max
,//will core dump
545 new OUStringBuffer(kSInt32Max
), kNonSInt32Max
},
547 {"capacity equal to -2147483648, minimum is 65535", 65535,
548 new OUStringBuffer(kNonSInt32Max
), 65535},
550 {"capacity equal to -2147483648, minimum is 2147483647", 2147483647,//will core dump
551 new OUStringBuffer(kNonSInt32Max
), 2147483647},
553 {"capacity equal to -2147483648, minimum is -1", 2,
554 new OUStringBuffer(kNonSInt32Max
), -1},
555 {"capacity equal to -2147483648, minimum is 0", 2,
556 new OUStringBuffer(kNonSInt32Max
), 0},
557 {"capacity equal to -2147483648, minimum is -2147483648", kNonSInt32Max
,
558 new OUStringBuffer(kNonSInt32Max
), kNonSInt32Max
}
562 sal_Bool res
= sal_True
;
565 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
567 arrTestCase
[i
].input1
->ensureCapacity(arrTestCase
[i
].input2
);
568 sal_Int32 length
= arrTestCase
[i
].input1
->getCapacity();
569 sal_Bool lastRes
= (length
== arrTestCase
[i
].expVal
);
575 arrTestCase
[i
].comments
,
576 createName( pMeth
, "ensureCapacity", i
)
581 c_rtl_tres_state_end( hRtlTestResult
, "ensureCapacity");
584 //------------------------------------------------------------------------
585 // testing the method setLength(sal_Int32 newLength)
586 //------------------------------------------------------------------------
588 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_setLength(
589 hTestResult hRtlTestResult
)
591 c_rtl_tres_state_start( hRtlTestResult
, "setLength");
592 sal_Char methName
[MAXBUFLENGTH
];
593 sal_Char
* pMeth
= methName
;
595 OUString arrOUS
[6]={OUString( aUStr1
),
599 kEncodingRTLTextUSASCII
,
600 kConvertFlagsOStringToOUString
),
602 kEncodingRTLTextUSASCII
,
603 kConvertFlagsOStringToOUString
),
606 typedef struct TestCase
612 OUStringBuffer
* input1
;
614 ~TestCase() { delete input1
; delete expVal2
;}
617 TestCase arrTestCase
[]={
619 {"newLength more than the capacity of OUStringBuffer(aUStr1)",
620 50, new OUString(aUStr1
), 50,
621 new OUStringBuffer(arrOUS
[0]), 50 },
622 {"newLength more than the length of OUStringBuffer(aUStr1)",
623 kTestStr13Len
, new OUString(aUStr1
), 32,
624 new OUStringBuffer(arrOUS
[0]), kTestStr13Len
},
625 {"newLength equal to the length of OUStringBuffer(aUStr1)",
626 kTestStr1Len
, new OUString(aUStr1
), 32,
627 new OUStringBuffer(arrOUS
[0]), kTestStr1Len
},
628 {"newLength less than the length of OUStringBuffer(aUStr1)",
629 kTestStr7Len
, new OUString(aUStr7
), 32,
630 new OUStringBuffer(arrOUS
[0]), kTestStr7Len
},
631 {"newLength equal to 0",
632 0, new OUString(), 32,
633 new OUStringBuffer(arrOUS
[0]), 0},
634 {"newLength more than the capacity of OUStringBuffer(1)",
635 25, new OUString(arrOUS
[1]), 25,
636 new OUStringBuffer(arrOUS
[1]), 25},
637 {"newLength more than the length of OUStringBuffer(1)",
638 5, new OUString(arrOUS
[1]), 17,
639 new OUStringBuffer(arrOUS
[1]), 5},
640 {"newLength equal to the length of OUStringBuffer(1)",
641 kTestStr27Len
, new OUString(arrOUS
[1]), 17,
642 new OUStringBuffer(arrOUS
[1]), kTestStr27Len
},
643 {"newLength less than the length of OUStringBuffer(1)",
644 0, new OUString(), 17,
645 new OUStringBuffer(arrOUS
[1]), 0},
646 {"newLength more than the capacity of OUStringBuffer()",
647 20, new OUString(), 20,
648 new OUStringBuffer(arrOUS
[2]), 20},
649 {"newLength more than the length of OUStringBuffer()",
650 3, new OUString(), 16,
651 new OUStringBuffer(arrOUS
[2]), 3},
652 {"newLength less than the length of OUStringBuffer()",
653 0, new OUString(), 16,
654 new OUStringBuffer(arrOUS
[2]), 0},
655 {"newLength more than the capacity of OUStringBuffer("")",
656 20, new OUString(), 20,
657 new OUStringBuffer(arrOUS
[3]), 20},
658 {"newLength more than the length of OUStringBuffer("")",
659 5, new OUString(), 16,
660 new OUStringBuffer(arrOUS
[3]), 5},
661 {"newLength less than the length of OUStringBuffer("")",
662 0, new OUString(), 16,
663 new OUStringBuffer(arrOUS
[3]), 0},
664 {"newLength more than the length of OUStringBuffer(\0)",
665 20, new OUString(), 20,
666 new OUStringBuffer(arrOUS
[4]), 20},
667 {"newLength more than the length of OUStringBuffer(\0)",
668 5, new OUString(), 16,
669 new OUStringBuffer(arrOUS
[4]), 5},
670 {"newLength less than the length of OUStringBuffer(\0)",
671 0, new OUString(), 16,
672 new OUStringBuffer(arrOUS
[4]), 0},
673 {"newLength more than the capacity of OUStringBuffer(aUStr2)",
674 50, new OUString(aUStr2
), 66,
675 new OUStringBuffer(arrOUS
[5]), 50,},
676 {"newLength more than the length of OUStringBuffer(aUStr2)",
677 40, new OUString(aUStr2
), 48,
678 new OUStringBuffer(arrOUS
[5]), 40,},
679 {"newLength equal to the length of OUStringBuffer(aUStr2)",
680 kTestStr2Len
, new OUString(aUStr2
), 48,
681 new OUStringBuffer(arrOUS
[5]), kTestStr2Len
,},
682 {"newLength less than the length of OUStringBuffer(aUStr2)",
683 kTestStr7Len
, new OUString(aUStr7
), 48,
684 new OUStringBuffer(arrOUS
[5]), kTestStr7Len
},
685 {"newLength equal to 0",
686 0, new OUString(), 48,
687 new OUStringBuffer(arrOUS
[5]), 0}
692 sal_Bool res
= sal_True
;
695 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
697 arrTestCase
[i
].input1
->setLength(arrTestCase
[i
].input2
);
699 ( arrTestCase
[i
].input1
->getStr() == *(arrTestCase
[i
].expVal2
) &&
700 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal1
&&
701 arrTestCase
[i
].input1
->getCapacity() == arrTestCase
[i
].expVal3
);
707 arrTestCase
[i
].comments
,
708 createName( pMeth
, "setLength", i
)
713 c_rtl_tres_state_end( hRtlTestResult
, "setLength");
716 //------------------------------------------------------------------------
717 // testing the method charAt( sal_Int32 index )
718 //------------------------------------------------------------------------
720 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_charAt(
721 hTestResult hRtlTestResult
)
723 c_rtl_tres_state_start( hRtlTestResult
, "charAt");
724 sal_Char methName
[MAXBUFLENGTH
];
725 sal_Char
* pMeth
= methName
;
727 OUString arrOUS
[4]={OUString( aUStr1
), // "Sun Microsystems";
728 OUString( aUStr27
), // "s";
729 OUString( aUStr28
), // "\50\3\5\7\11\13\15\17sun";
732 typedef struct TestCase
736 OUStringBuffer
* input1
;
738 ~TestCase() { delete input1
;}
741 TestCase arrTestCase
[]={
743 {"return the first character of OUStringBuffer(aUStr1)",
744 83, new OUStringBuffer(arrOUS
[0]), 0 },
745 {"return the middle character of OUStringBuffer(aUStr1)",
746 32, new OUStringBuffer(arrOUS
[0]), 3 },
747 {"return the last character of OUStringBuffer(aUStr1)",
748 115, new OUStringBuffer(arrOUS
[0]), 15 },
749 {"return the only character of OUStringBuffer(aUStr27)",
750 115, new OUStringBuffer(arrOUS
[1]), 0},
751 {"return the first of OUStringBuffer(aUStr28) with special character",
752 40, new OUStringBuffer(arrOUS
[2]), 0},
754 {"return the mid of OUStringBuffer(aUStr28) with special character",
755 11, new OUStringBuffer(arrOUS[2]), 5},
758 {"invalid character of OUStringBuffer()",
759 0, new OUStringBuffer(arrOUS[3]), 0},
762 {"invalid character of OUStringBuffer()",
763 0, new OUStringBuffer(arrOUS[3]), -2}
769 sal_Bool res
= sal_True
;
772 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
775 ( arrTestCase
[i
].input1
->charAt(arrTestCase
[i
].input2
) ==
776 arrTestCase
[i
].expVal
);
777 // LLA: last case removed, due to the fact of complexity of the test code :-(
784 arrTestCase
[i
].comments
,
785 createName( pMeth
, "charAt", i
)
791 // LLA: c_rtl_tres_state
793 // LLA: hRtlTestResult,
795 // LLA: arrTestCase[i].comments,
796 // LLA: createName( pMeth, "charAt", i )
802 c_rtl_tres_state_end( hRtlTestResult
, "charAt");
805 //------------------------------------------------------------------------
806 // testing the operator const sal_Unicode * (csuc for short)
807 //------------------------------------------------------------------------
808 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_csuc(
809 hTestResult hRtlTestResult
)
811 c_rtl_tres_state_start( hRtlTestResult
, "csuc");
812 sal_Char methName
[MAXBUFLENGTH
];
813 sal_Char
* pMeth
= methName
;
815 const sal_Unicode tmpUC
=0x0;
816 rtl_uString
* tmpUstring
= NULL
;
817 const sal_Char
*tmpStr
=kTestStr1
;
818 sal_Int32 tmpLen
=(sal_Int32
) kTestStr1Len
;
819 //sal_Int32 cmpLen = 0;
820 OUString
tempString(aUStr1
);
822 rtl_string2UString( &tmpUstring
, tmpStr
, tmpLen
,
823 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS
);
824 OSL_ASSERT(tmpUstring
!= NULL
);
827 typedef struct TestCase
830 const sal_Unicode
* expVal
;
832 OUStringBuffer
* input1
;
833 ~TestCase() { delete input1
; }
836 TestCase arrTestCase
[] =
838 {"test normal ustring",(*tmpUstring
).buffer
,kTestStr1Len
,
839 new OUStringBuffer(tempString
)},
840 {"test empty ustring",&tmpUC
, 1, new OUStringBuffer()}
843 sal_Bool res
= sal_True
;
845 for(i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
847 const sal_Unicode
* pstr
= *arrTestCase
[i
].input1
;
849 res
&= c_rtl_tres_state
852 cmpustr( pstr
, arrTestCase
[i
].expVal
, arrTestCase
[i
].cmpLen
),
853 arrTestCase
[i
].comments
,
854 createName( pMeth
, "const sal_Unicode*", i
)
857 c_rtl_tres_state_end( hRtlTestResult
, "csuc");
860 //------------------------------------------------------------------------
861 // testing the method const sal_Unicode * getStr()
862 //------------------------------------------------------------------------
863 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_getStr(
864 hTestResult hRtlTestResult
)
866 c_rtl_tres_state_start( hRtlTestResult
, "getStr");
867 sal_Char methName
[MAXBUFLENGTH
];
868 sal_Char
* pMeth
= methName
;
870 const sal_Unicode tmpUC
=0x0;
871 rtl_uString
* tmpUstring
= NULL
;
872 const sal_Char
*tmpStr
=kTestStr1
;
873 sal_Int32 tmpLen
=(sal_Int32
) kTestStr1Len
;
874 //sal_Int32 cmpLen = 0;
875 OUString
tempString(aUStr1
);
877 rtl_string2UString( &tmpUstring
, tmpStr
, tmpLen
,
878 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS
);
879 OSL_ASSERT(tmpUstring
!= NULL
);
882 typedef struct TestCase
885 const sal_Unicode
* expVal
;
887 OUStringBuffer
* input1
;
888 ~TestCase() { delete input1
;}
891 TestCase arrTestCase
[] =
893 {"test normal ustring",(*tmpUstring
).buffer
,kTestStr1Len
,
894 new OUStringBuffer(tempString
)},
895 {"test empty ustring",&tmpUC
, 1, new OUStringBuffer()}
898 sal_Bool res
= sal_True
;
900 for(i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
902 const sal_Unicode
* pstr
= arrTestCase
[i
].input1
->getStr();
904 res
&= c_rtl_tres_state
907 cmpustr( pstr
, arrTestCase
[i
].expVal
, arrTestCase
[i
].cmpLen
),
908 arrTestCase
[i
].comments
,
909 createName( pMeth
, "getStr", i
)
912 c_rtl_tres_state_end( hRtlTestResult
, "getStr");
915 //------------------------------------------------------------------------
916 // testing the method setCharAt(sal_Int32 index, sal_Unicode ch)
917 //------------------------------------------------------------------------
919 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_setCharAt(
920 hTestResult hRtlTestResult
)
922 c_rtl_tres_state_start( hRtlTestResult
, "setCharAt");
923 sal_Char methName
[MAXBUFLENGTH
];
924 sal_Char
* pMeth
= methName
;
926 OUString arrOUS
[4]={OUString( aUStr1
),
931 typedef struct TestCase
935 OUStringBuffer
* input1
;
938 ~TestCase() { delete input1
; delete expVal
; }
941 TestCase arrTestCase
[]={
943 {"set the first character of OUStringBuffer(aUStr1) with s",
944 new OUString(aUStr31
),
945 new OUStringBuffer(arrOUS
[0]), 0, 115 },
946 {"set the middle character of OUStringBuffer(aUStr1) with m",
947 new OUString(aUStr3
),
948 new OUStringBuffer(arrOUS
[0]), 4, 109 },
949 {"set the last character of OUStringBuffer(aUStr1) with ' '",
950 new OUString(aUStr32
),
951 new OUStringBuffer(arrOUS
[0]), 15, 32 },
952 {"set the only character of OUStringBuffer(aUStr27) with ' '",
953 new OUString(aUStr33
),
954 new OUStringBuffer(arrOUS
[1]), 0, 32},
955 {"set the only of OUStringBuffer(aUStr28) with special character",
956 new OUString(aUStr34
),
957 new OUStringBuffer(arrOUS
[2]), 1, 5},
959 {"set the only of OUStringBuffer(aUStr28) with special character",
960 new OUString(aUStr35),
961 new OUStringBuffer(arrOUS[2]), 1, -5}
964 ,{"invalid character of OUStringBuffer()",
966 new OUStringBuffer(arrOUS
[3]), 0, 5},
967 {"invalid character of OUStringBuffer()",
969 new OUStringBuffer(arrOUS
[3]), -2, 5},
970 {"invalid character of OUStringBuffer()",
972 new OUStringBuffer(arrOUS
[3]), 3, 5}
978 sal_Bool res
= sal_True
;
981 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
984 ( (arrTestCase
[i
].input1
->setCharAt(arrTestCase
[i
].input2
,
985 arrTestCase
[i
].input3
)).getStr() == *(arrTestCase
[i
].expVal
) );
992 arrTestCase
[i
].comments
,
993 createName( pMeth
, "setCharAt", i
)
1003 arrTestCase
[i
].comments
,
1004 createName( pMeth
, "setCharAt", i
)
1010 c_rtl_tres_state_end( hRtlTestResult
, "setCharAt");
1013 //------------------------------------------------------------------------
1014 // testing the method append(const OUString &str)
1015 //------------------------------------------------------------------------
1017 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_001(
1018 hTestResult hRtlTestResult
)
1020 sal_Char methName
[MAXBUFLENGTH
];
1021 sal_Char
* pMeth
= methName
;
1023 OUString arrOUS
[5]={OUString( aUStr7
),
1025 OUString( aUStr25
),
1027 kEncodingRTLTextUSASCII
,
1028 kConvertFlagsOStringToOUString
),
1029 OUString( aUStr28
)};
1031 typedef struct TestCase
1035 OUStringBuffer
* input1
;
1038 ~TestCase() { delete input1
; delete input2
; delete expVal
; }
1041 TestCase arrTestCase
[]={
1043 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1044 new OUString(aUStr1
),
1045 new OUStringBuffer(arrOUS
[0]), new OUString(aUStr8
) },
1046 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1047 new OUString(aUStr2
),
1048 new OUStringBuffer(arrOUS
[0]), new OUString(aUStr36
) },
1049 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1050 new OUString(aUStr37
),
1051 new OUStringBuffer(arrOUS
[0]), new OUString(aUStr23
) },
1052 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1053 new OUString(aUStr7
),
1054 new OUStringBuffer(arrOUS
[0]), new OUString()},
1055 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1056 new OUString(aUStr7
),
1057 new OUStringBuffer(arrOUS
[1]), new OUString(aUStr7
)},
1058 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1059 new OUString(aUStr2
),
1060 new OUStringBuffer(arrOUS
[1]), new OUString(aUStr2
)},
1061 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1062 new OUString(aUStr1
),
1063 new OUStringBuffer(arrOUS
[1]), new OUString(aUStr1
) },
1064 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1066 new OUStringBuffer(arrOUS
[1]), new OUString()},
1067 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1068 new OUString(aUStr7
),
1069 new OUStringBuffer(arrOUS
[2]), new OUString(aUStr7
)},
1070 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1071 new OUString(aUStr2
),
1072 new OUStringBuffer(arrOUS
[2]), new OUString(aUStr2
)},
1073 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1074 new OUString(aUStr1
),
1075 new OUStringBuffer(arrOUS
[2]), new OUString(aUStr1
) },
1076 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1078 new OUStringBuffer(arrOUS
[2]), new OUString()},
1079 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1080 new OUString(aUStr7
),
1081 new OUStringBuffer(arrOUS
[3]), new OUString(aUStr7
)},
1082 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1083 new OUString(aUStr2
),
1084 new OUStringBuffer(arrOUS
[3]), new OUString(aUStr2
)},
1085 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1086 new OUString(aUStr1
),
1087 new OUStringBuffer(arrOUS
[3]), new OUString(aUStr1
) },
1088 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1090 new OUStringBuffer(arrOUS
[3]), new OUString()},
1091 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1092 new OUString(aUStr29
),
1093 new OUStringBuffer(arrOUS
[4]), new OUString(aUStr38
)},
1094 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1095 new OUString(aUStr39
),
1096 new OUStringBuffer(arrOUS
[4]), new OUString(aUStr17
)},
1097 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1098 new OUString(aUStr40
),
1099 new OUStringBuffer(arrOUS
[4]), new OUString(aUStr31
) },
1100 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1101 new OUString(aUStr28
),
1102 new OUStringBuffer(arrOUS
[4]), new OUString()}
1104 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1106 new OUStringBuffer(kSInt32Max
), new OUString()}
1111 sal_Bool res
= sal_True
;
1114 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1116 arrTestCase
[i
].input1
->append( *(arrTestCase
[i
].input2
) );
1118 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1119 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1125 arrTestCase
[i
].comments
,
1126 createName( pMeth
, "append(const OUString &str)_001", i
)
1135 //------------------------------------------------------------------------
1136 // testing the method append( const sal_Unicode * str )
1137 //------------------------------------------------------------------------
1139 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_002(
1140 hTestResult hRtlTestResult
)
1142 sal_Char methName
[MAXBUFLENGTH
];
1143 sal_Char
* pMeth
= methName
;
1145 OUString arrOUS
[5]={OUString( aUStr7
),
1147 OUString( aUStr25
),
1149 kEncodingRTLTextUSASCII
,
1150 kConvertFlagsOStringToOUString
),
1151 OUString( aUStr28
)};
1153 typedef struct TestCase
1157 OUStringBuffer
* input1
;
1158 sal_Unicode
* input2
;
1160 ~TestCase() { delete input1
; delete expVal
; }
1163 TestCase arrTestCase
[]={
1165 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1166 new OUString(aUStr1
),
1167 new OUStringBuffer(arrOUS
[0]), aUStr8
},
1168 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1169 new OUString(aUStr2
),
1170 new OUStringBuffer(arrOUS
[0]), aUStr36
},
1171 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1172 new OUString(aUStr37
),
1173 new OUStringBuffer(arrOUS
[0]), aUStr23
},
1174 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1175 new OUString(aUStr7
),
1176 new OUStringBuffer(arrOUS
[0]), aUStr25
},
1177 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1178 new OUString(aUStr7
),
1179 new OUStringBuffer(arrOUS
[1]), aUStr7
},
1180 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1181 new OUString(aUStr2
),
1182 new OUStringBuffer(arrOUS
[1]), aUStr2
},
1183 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1184 new OUString(aUStr1
),
1185 new OUStringBuffer(arrOUS
[1]), aUStr1
},
1186 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1188 new OUStringBuffer(arrOUS
[1]), aUStr25
},
1189 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1190 new OUString(aUStr7
),
1191 new OUStringBuffer(arrOUS
[2]), aUStr7
},
1192 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1193 new OUString(aUStr2
),
1194 new OUStringBuffer(arrOUS
[2]), aUStr2
},
1195 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1196 new OUString(aUStr1
),
1197 new OUStringBuffer(arrOUS
[2]), aUStr1
},
1198 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1200 new OUStringBuffer(arrOUS
[2]), aUStr25
},
1201 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1202 new OUString(aUStr7
),
1203 new OUStringBuffer(arrOUS
[3]), aUStr7
},
1204 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1205 new OUString(aUStr2
),
1206 new OUStringBuffer(arrOUS
[3]), aUStr2
},
1207 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1208 new OUString(aUStr1
),
1209 new OUStringBuffer(arrOUS
[3]), aUStr1
},
1210 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1212 new OUStringBuffer(arrOUS
[3]), aUStr25
},
1213 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1214 new OUString(aUStr29
),
1215 new OUStringBuffer(arrOUS
[4]), aUStr38
},
1216 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1217 new OUString(aUStr39
),
1218 new OUStringBuffer(arrOUS
[4]), aUStr17
},
1219 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1220 new OUString(aUStr40
),
1221 new OUStringBuffer(arrOUS
[4]), aUStr31
},
1222 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1223 new OUString(aUStr28
),
1224 new OUStringBuffer(arrOUS
[4]), aUStr25
}
1226 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1228 new OUStringBuffer(kSInt32Max
), aUStr25
}
1233 sal_Bool res
= sal_True
;
1236 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1238 arrTestCase
[i
].input1
->append( arrTestCase
[i
].input2
);
1240 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1241 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1247 arrTestCase
[i
].comments
,
1248 createName( pMeth
, "append( const sal_Unicode * str )_002", i
)
1257 //------------------------------------------------------------------------
1258 // testing the method append( const sal_Unicode * str, sal_Int32 len)
1259 //------------------------------------------------------------------------
1261 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_003(
1262 hTestResult hRtlTestResult
)
1264 sal_Char methName
[MAXBUFLENGTH
];
1265 sal_Char
* pMeth
= methName
;
1267 OUString arrOUS
[5]={OUString( aUStr7
),
1269 OUString( aUStr25
),
1271 kEncodingRTLTextUSASCII
,
1272 kConvertFlagsOStringToOUString
),
1273 OUString( aUStr28
)};
1275 typedef struct TestCase
1279 OUStringBuffer
* input1
;
1280 sal_Unicode
* input2
;
1283 ~TestCase() { delete input1
; delete expVal
; }
1286 TestCase arrTestCase
[]={
1288 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1289 new OUString(aUStr1
),
1290 new OUStringBuffer(arrOUS
[0]), aUStr36
, 12 },
1291 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1292 new OUString(aUStr2
),
1293 new OUStringBuffer(arrOUS
[0]), aUStr36
, 28 },
1294 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1295 new OUString(aUStr37
),
1296 new OUStringBuffer(arrOUS
[0]), aUStr23
, 16 },
1297 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1298 new OUString(aUStr7
),
1299 new OUStringBuffer(arrOUS
[0]), aUStr2
, 0 },
1300 /* LLA: input3 must null < 0
1301 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1302 new OUString(aUStr41),
1303 new OUStringBuffer(arrOUS[0]), aUStr2, -1 },
1305 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1306 new OUString(aUStr7
),
1307 new OUStringBuffer(arrOUS
[1]), aUStr2
, 4 },
1308 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1309 new OUString(aUStr2
),
1310 new OUStringBuffer(arrOUS
[1]), aUStr2
, 32 },
1311 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1312 new OUString(aUStr1
),
1313 new OUStringBuffer(arrOUS
[1]), aUStr2
, 16 },
1314 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1316 new OUStringBuffer(arrOUS
[1]), aUStr2
, 0 },
1317 /* LLA: input3 must null < 0
1318 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1320 new OUStringBuffer(arrOUS[1]), aUStr2, -1 },
1322 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1323 new OUString(aUStr7
),
1324 new OUStringBuffer(arrOUS
[2]), aUStr2
, 4 },
1325 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1326 new OUString(aUStr2
),
1327 new OUStringBuffer(arrOUS
[2]), aUStr2
, 32 },
1328 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1329 new OUString(aUStr1
),
1330 new OUStringBuffer(arrOUS
[2]), aUStr2
, 16 },
1331 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1333 new OUStringBuffer(arrOUS
[2]), aUStr2
, 0 },
1334 /* LLA: input3 must null < 0
1335 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1337 new OUStringBuffer(arrOUS[2]), aUStr2, -1 },
1339 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1340 new OUString(aUStr7
),
1341 new OUStringBuffer(arrOUS
[3]), aUStr2
, 4 },
1342 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1343 new OUString(aUStr2
),
1344 new OUStringBuffer(arrOUS
[3]), aUStr2
, 32 },
1345 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1346 new OUString(aUStr1
),
1347 new OUStringBuffer(arrOUS
[3]), aUStr2
, 16 },
1348 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1350 new OUStringBuffer(arrOUS
[3]), aUStr2
, 0 },
1351 /* LLA: input3 must null < 0
1352 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1354 new OUStringBuffer(arrOUS[3]), aUStr2, -1 },
1356 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1357 new OUString(aUStr29
),
1358 new OUStringBuffer(arrOUS
[4]), aUStr38
, 7 },
1359 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1360 new OUString(aUStr39
),
1361 new OUStringBuffer(arrOUS
[4]), aUStr17
, 22 },
1362 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1363 new OUString(aUStr40
),
1364 new OUStringBuffer(arrOUS
[4]), aUStr31
, 16 },
1365 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1366 new OUString(aUStr28
),
1367 new OUStringBuffer(arrOUS
[4]), aUStr2
, 0 },
1368 /* LLA: input3 must null < 0
1369 {"Appends the string(length less than 0) to the string buffer arrOUS[4]",
1370 new OUString(aUStr42),
1371 new OUStringBuffer(arrOUS[4]), aUStr2, -1 }
1374 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1376 new OUStringBuffer(kSInt32Max
), aUStr25
}
1381 sal_Bool res
= sal_True
;
1384 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1386 arrTestCase
[i
].input1
->append(
1387 arrTestCase
[i
].input2
, arrTestCase
[i
].input3
);
1389 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1390 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1396 arrTestCase
[i
].comments
,
1397 createName( pMeth
, "append( const sal_Unicode * str, sal_Int32 len)_003", i
)
1406 //------------------------------------------------------------------------
1407 // testing the method append(sal_Bool b)
1408 //------------------------------------------------------------------------
1410 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_004(
1411 hTestResult hRtlTestResult
)
1413 sal_Char methName
[MAXBUFLENGTH
];
1414 sal_Char
* pMeth
= methName
;
1416 OUString arrOUS
[5]={OUString( aUStr7
),
1418 OUString( aUStr25
),
1420 kEncodingRTLTextUSASCII
,
1421 kConvertFlagsOStringToOUString
),
1422 OUString( aUStr28
)};
1424 typedef struct TestCase
1428 OUStringBuffer
* input1
;
1431 ~TestCase() { delete input1
; delete expVal
; }
1434 TestCase arrTestCase
[]={
1436 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[0]",
1437 new OUString(aUStr45
),
1438 new OUStringBuffer(arrOUS
[0]), sal_True
},
1439 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[0]",
1440 new OUString(aUStr46
),
1441 new OUStringBuffer(arrOUS
[0]), sal_False
},
1442 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[1]",
1443 new OUString(aUStr47
),
1444 new OUStringBuffer(arrOUS
[1]), sal_True
},
1445 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[1]",
1446 new OUString(aUStr48
),
1447 new OUStringBuffer(arrOUS
[1]), sal_False
},
1448 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[2]",
1449 new OUString(aUStr47
),
1450 new OUStringBuffer(arrOUS
[2]), sal_True
},
1451 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[2]",
1452 new OUString(aUStr48
),
1453 new OUStringBuffer(arrOUS
[2]), sal_False
},
1454 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[3]",
1455 new OUString(aUStr47
),
1456 new OUStringBuffer(arrOUS
[3]), sal_True
},
1457 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[3]",
1458 new OUString(aUStr48
),
1459 new OUStringBuffer(arrOUS
[3]), sal_False
},
1460 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[4]",
1461 new OUString(aUStr49
),
1462 new OUStringBuffer(arrOUS
[4]), sal_True
},
1463 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[4]",
1464 new OUString(aUStr50
),
1465 new OUStringBuffer(arrOUS
[4]), sal_False
}
1467 ,{"Appends the sal_Bool(sal_True) to the string buffer(with INT_MAX) ",
1468 new OUString(aUStr47
),
1469 new OUStringBuffer(kSInt32Max
), sal_True
},
1470 {"Appends the sal_Bool(sal_False) to the string buffer(with INT_MAX) ",
1471 new OUString(aUStr48
),
1472 new OUStringBuffer(kSInt32Max
), sal_False
}
1477 sal_Bool res
= sal_True
;
1480 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1482 arrTestCase
[i
].input1
->append(
1483 arrTestCase
[i
].input2
);
1485 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1486 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1492 arrTestCase
[i
].comments
,
1493 createName( pMeth
, "append( sal_Bool b)_004", i
)
1503 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_appends(
1504 hTestResult hRtlTestResult
)
1506 c_rtl_tres_state_start( hRtlTestResult
, "appends");
1507 sal_Bool bTSState
= test_rtl_OUStringBuffer_append_001( hRtlTestResult
);
1508 bTSState
&= test_rtl_OUStringBuffer_append_002( hRtlTestResult
);
1509 bTSState
&= test_rtl_OUStringBuffer_append_003( hRtlTestResult
);
1510 bTSState
&= test_rtl_OUStringBuffer_append_004( hRtlTestResult
);
1512 c_rtl_tres_state_end( hRtlTestResult
, "appends");
1513 // return( bTSState );
1515 //------------------------------------------------------------------------
1516 // testing the method appendAscii( const sal_Char * str )
1517 //------------------------------------------------------------------------
1519 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_appendAscii_001(
1520 hTestResult hRtlTestResult
)
1522 sal_Char methName
[MAXBUFLENGTH
];
1523 sal_Char
* pMeth
= methName
;
1525 OUString arrOUS
[5]={OUString( aUStr7
),
1527 OUString( aUStr25
),
1529 kEncodingRTLTextUSASCII
,
1530 kConvertFlagsOStringToOUString
),
1531 OUString( aUStr28
)};
1533 typedef struct TestCase
1537 OUStringBuffer
* input1
;
1538 const sal_Char
* input2
;
1540 ~TestCase() { delete input1
; delete expVal
; }
1543 TestCase arrTestCase
[]={
1545 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1546 new OUString(aUStr1
),
1547 new OUStringBuffer(arrOUS
[0]), kTestStr8
},
1548 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1549 new OUString(aUStr2
),
1550 new OUStringBuffer(arrOUS
[0]), kTestStr36
},
1551 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1552 new OUString(aUStr37
),
1553 new OUStringBuffer(arrOUS
[0]), kTestStr23
},
1554 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1555 new OUString(aUStr7
),
1556 new OUStringBuffer(arrOUS
[0]), kTestStr25
},
1557 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1558 new OUString(aUStr7
),
1559 new OUStringBuffer(arrOUS
[1]), kTestStr7
},
1560 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1561 new OUString(aUStr2
),
1562 new OUStringBuffer(arrOUS
[1]), kTestStr2
},
1563 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1564 new OUString(aUStr1
),
1565 new OUStringBuffer(arrOUS
[1]), kTestStr1
},
1566 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1568 new OUStringBuffer(arrOUS
[1]), kTestStr25
},
1569 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1570 new OUString(aUStr7
),
1571 new OUStringBuffer(arrOUS
[2]), kTestStr7
},
1572 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1573 new OUString(aUStr2
),
1574 new OUStringBuffer(arrOUS
[2]), kTestStr2
},
1575 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1576 new OUString(aUStr1
),
1577 new OUStringBuffer(arrOUS
[2]), kTestStr1
},
1578 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1580 new OUStringBuffer(arrOUS
[2]), kTestStr25
},
1581 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1582 new OUString(aUStr7
),
1583 new OUStringBuffer(arrOUS
[3]), kTestStr7
},
1584 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1585 new OUString(aUStr2
),
1586 new OUStringBuffer(arrOUS
[3]), kTestStr2
},
1587 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1588 new OUString(aUStr1
),
1589 new OUStringBuffer(arrOUS
[3]), kTestStr1
},
1590 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1592 new OUStringBuffer(arrOUS
[3]), kTestStr25
},
1593 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1594 new OUString(aUStr29
),
1595 new OUStringBuffer(arrOUS
[4]), kTestStr38
},
1596 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1597 new OUString(aUStr39
),
1598 new OUStringBuffer(arrOUS
[4]), kTestStr17
},
1599 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1600 new OUString(aUStr40
),
1601 new OUStringBuffer(arrOUS
[4]), kTestStr31
},
1602 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1603 new OUString(aUStr28
),
1604 new OUStringBuffer(arrOUS
[4]), kTestStr25
}
1605 /*{"Appends the string(with special characters) to the string buffer arrOUS[4]",
1606 new OUString(aUStr43),
1607 new OUStringBuffer(arrOUS[4]), kTestStr44 }*/
1609 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1611 new OUStringBuffer(kSInt32Max
), kTestStr25
}
1617 sal_Bool res
= sal_True
;
1620 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1622 arrTestCase
[i
].input1
->appendAscii( arrTestCase
[i
].input2
);
1624 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1625 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1631 arrTestCase
[i
].comments
,
1632 createName( pMeth
, "appendAscii_001", i
)
1639 //------------------------------------------------------------------------
1640 // testing the method appendAscii( const sal_Char * str, sal_Int32 len)
1641 //------------------------------------------------------------------------
1643 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_appendAscii_002(
1644 hTestResult hRtlTestResult
)
1646 sal_Char methName
[MAXBUFLENGTH
];
1647 sal_Char
* pMeth
= methName
;
1649 OUString arrOUS
[5]={OUString( aUStr7
),
1651 OUString( aUStr25
),
1653 kEncodingRTLTextUSASCII
,
1654 kConvertFlagsOStringToOUString
),
1655 OUString( aUStr28
)};
1657 typedef struct TestCase
1661 OUStringBuffer
* input1
;
1662 const sal_Char
* input2
;
1665 ~TestCase() { delete input1
; delete expVal
; }
1668 TestCase arrTestCase
[]={
1670 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1671 new OUString(aUStr1
),
1672 new OUStringBuffer(arrOUS
[0]), kTestStr36
, 12 },
1673 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1674 new OUString(aUStr2
),
1675 new OUStringBuffer(arrOUS
[0]), kTestStr36
, 28 },
1676 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1677 new OUString(aUStr37
),
1678 new OUStringBuffer(arrOUS
[0]), kTestStr23
, 16 },
1679 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1680 new OUString(aUStr7
),
1681 new OUStringBuffer(arrOUS
[0]), kTestStr2
, 0 },
1682 /* LLA: input3 must null < 0
1683 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1684 new OUString(aUStr41),
1685 new OUStringBuffer(arrOUS[0]), kTestStr2, -1 },
1687 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1688 new OUString(aUStr7
),
1689 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 4 },
1690 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1691 new OUString(aUStr2
),
1692 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 32 },
1693 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1694 new OUString(aUStr1
),
1695 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 16 },
1696 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1698 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 0 },
1699 /* LLA: input3 must null < 0
1700 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1702 new OUStringBuffer(arrOUS[1]), kTestStr2, -1 },
1704 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1705 new OUString(aUStr7
),
1706 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 4 },
1707 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1708 new OUString(aUStr2
),
1709 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 32 },
1710 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1711 new OUString(aUStr1
),
1712 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 16 },
1713 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1715 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 0 },
1716 /* LLA: input3 must null < 0
1717 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1719 new OUStringBuffer(arrOUS[2]), kTestStr2, -1 },
1721 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1722 new OUString(aUStr7
),
1723 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 4 },
1724 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1725 new OUString(aUStr2
),
1726 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 32 },
1727 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1728 new OUString(aUStr1
),
1729 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 16 },
1730 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1732 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 0 },
1733 /* LLA: input3 must null < 0
1734 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1736 new OUStringBuffer(arrOUS[3]), kTestStr2, -1 },
1738 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1739 new OUString(aUStr29
),
1740 new OUStringBuffer(arrOUS
[4]), kTestStr38
, 7 },
1741 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1742 new OUString(aUStr39
),
1743 new OUStringBuffer(arrOUS
[4]), kTestStr17
, 22 },
1744 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1745 new OUString(aUStr40
),
1746 new OUStringBuffer(arrOUS
[4]), kTestStr31
, 16 },
1747 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1748 new OUString(aUStr28
),
1749 new OUStringBuffer(arrOUS
[4]), kTestStr2
, 0 },
1750 /* LLA: input3 must null < 0
1751 {"Appends the string(length less than 0) to the string buffer arrOUS[4]",
1752 new OUString(aUStr42),
1753 new OUStringBuffer(arrOUS[4]), kTestStr2, -1 }
1756 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1758 new OUStringBuffer(kSInt32Max
), kTestStr25
}
1763 sal_Bool res
= sal_True
;
1766 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1768 arrTestCase
[i
].input1
->appendAscii(
1769 arrTestCase
[i
].input2
, arrTestCase
[i
].input3
);
1771 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1772 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1778 arrTestCase
[i
].comments
,
1779 createName( pMeth
, "appendAscii_002", i
)
1787 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_appendAsciis(
1788 hTestResult hRtlTestResult
)
1790 c_rtl_tres_state_start( hRtlTestResult
, "appendAsciis");
1791 sal_Bool bTSState
= test_rtl_OUStringBuffer_appendAscii_001( hRtlTestResult
);
1792 bTSState
&= test_rtl_OUStringBuffer_appendAscii_002( hRtlTestResult
);
1794 c_rtl_tres_state_end( hRtlTestResult
, "appendAsciis");
1795 // return( bTSState );
1797 // -----------------------------------------------------------------------------
1798 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer( hTestResult hRtlTestResult
)
1801 c_rtl_tres_state_start(hRtlTestResult
, "rtl_OUStringBuffer" );
1803 test_rtl_OUStringBuffer_ctors( hRtlTestResult
);
1804 test_rtl_OUStringBuffer_makeStringAndClear( hRtlTestResult
);
1805 test_rtl_OUStringBuffer_getLength( hRtlTestResult
);
1806 test_rtl_OUStringBuffer_getCapacity( hRtlTestResult
);
1807 test_rtl_OUStringBuffer_ensureCapacity( hRtlTestResult
);
1808 test_rtl_OUStringBuffer_setLength( hRtlTestResult
);
1809 test_rtl_OUStringBuffer_charAt( hRtlTestResult
);
1810 test_rtl_OUStringBuffer_csuc( hRtlTestResult
);
1811 test_rtl_OUStringBuffer_getStr( hRtlTestResult
);
1812 test_rtl_OUStringBuffer_setCharAt( hRtlTestResult
);
1813 test_rtl_OUStringBuffer_appends( hRtlTestResult
);
1814 test_rtl_OUStringBuffer_appendAsciis( hRtlTestResult
);
1816 c_rtl_tres_state_end(hRtlTestResult
, "rtl_OUStringBuffer");
1819 // -----------------------------------------------------------------------------
1820 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc
)
1824 (_pFunc
)(&test_rtl_OUStringBuffer
, "");