1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sal.hxx"
32 #include <sal/types.h>
35 // #ifndef _RTL_TRES_H_
36 // #include <rtl/tres.h>
38 #include <testshl/tresstatewrapper.hxx>
40 #ifndef _RTL_STRING_HXX_
41 #include <rtl/string.hxx>
44 #ifndef _RTL_USTRING_H_
45 #include <rtl/ustring.h>
48 #ifndef _RTL_USTRING_HXX_
49 #include <rtl/ustring.hxx>
52 #ifndef _RTL_USTRBUF_H_
53 #include <rtl/ustrbuf.h>
56 #ifndef _RTL_USTRBUF_HXX
57 #include <rtl/ustrbuf.hxx>
59 //------------------------------------------------------------------------
60 //------------------------------------------------------------------------
61 #ifndef _OSL_THREAD_H_
62 #include <osl/thread.h>
65 #ifndef _RTL_STRING_CONST_H_
66 #include <rtl_String_Const.h>
69 #ifndef _RTL_STRING_UTILS_HXX_
70 #include <rtl_String_Utils.hxx>
76 //------------------------------------------------------------------------
78 //------------------------------------------------------------------------
79 const int MAXBUFLENGTH
= 255;
80 //------------------------------------------------------------------------
82 //------------------------------------------------------------------------
87 (void)kDecimalNumsStr
;
88 (void)kHexDecimalNumsStr
;
91 (void)input1StrDefault
;
92 (void)input1StrNormal
;
93 (void)input1StrLastDefault
;
94 (void)input1StrLastNormal
;
98 //------------------------------------------------------------------------
99 // testing constructors
100 //------------------------------------------------------------------------
101 static sal_Bool
test_rtl_OUStringBuffer_ctor_001( hTestResult hRtlTestResult
)
104 ::rtl::OUStringBuffer aUStrBuf
;
107 aUStrBuf
.getLength() == 0 &&
108 ! *(aUStrBuf
.getStr()) && aUStrBuf
.getCapacity() == 16;
110 ::rtl::OUStringBuffer
aUStrBuf2(0);
113 aUStrBuf2
.getLength() == 0 &&
114 ! *(aUStrBuf2
.getStr()) && aUStrBuf2
.getCapacity() == /* LLA: !!! */ 0;
122 "New OUStringBuffer containing no characters",
128 //------------------------------------------------------------------------
130 static sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_002(
131 hTestResult hRtlTestResult
)
133 ::rtl::OUStringBuffer
aUStrBuftmp( aUStr1
);
134 ::rtl::OUStringBuffer
aUStrBuf( aUStrBuftmp
);
135 sal_Bool res
= cmpustr(aUStrBuftmp
.getStr(),aUStrBuf
.getStr());
141 aUStrBuf
.getLength()==aUStrBuftmp
.getLength() &&
142 aUStrBuf
.getCapacity() == aUStrBuftmp
.getCapacity() && res
,
143 "New OUStringBuffer from another OUStringBuffer",
148 //------------------------------------------------------------------------
151 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_003(
152 hTestResult hRtlTestResult
)
154 ::rtl::OUStringBuffer
aUStrBuf1(kTestStr2Len
);
156 ::rtl::OUStringBuffer
aUStrBuf2(kSInt32Max
); //will core dump
158 ::rtl::OUStringBuffer
aUStrBuf2(0);
160 ::rtl::OUStringBuffer
aUStrBuf3(kNonSInt32Max
);
164 aUStrBuf1
.getLength() == 0 &&
165 ! *(aUStrBuf1
.getStr()) && aUStrBuf1
.getCapacity() == kTestStr2Len
;
169 aUStrBuf2
.getLength() == 0 &&
170 ! *(aUStrBuf2
.getStr()) && aUStrBuf2
.getCapacity() == kSInt32Max
;
172 aUStrBuf2
.getLength() == 0 &&
173 ! *(aUStrBuf2
.getStr()) && aUStrBuf2
.getCapacity() == /* LLA: ??? 16 */ 0;
176 aUStrBuf3
.getLength() == 0 &&
177 ! *(aUStrBuf3
.getStr()) && aUStrBuf3
.getCapacity() == kNonSInt32Max
;
185 "New OUStringBuffer containing no characters and contain assigned capacity",
186 "ctor_003( will core dump,because the kSInt32Max )"
192 //------------------------------------------------------------------------
194 static sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_004(
195 hTestResult hRtlTestResult
)
197 ::rtl::OUString
aUStrtmp( aUStr1
);
198 ::rtl::OUStringBuffer
aUStrBuf( aUStrtmp
);
199 sal_Int32 leg
= aUStrBuf
.getLength();
205 aUStrBuf
.getStr() == aUStrtmp
&&
206 leg
== aUStrtmp
.pData
->length
&&
207 aUStrBuf
.getCapacity() == leg
+16 ,
208 "New OUStringBuffer from OUstring",
214 static sal_Bool SAL_CALL
test_rtl_OUStringBuffer_ctor_005(
215 hTestResult hRtlTestResult
)
217 ::rtl::OUStringBuffer
aUStrBuftmp( aUStr1
);
218 ::rtl::OUString aUStrtmp
= aUStrBuftmp
.makeStringAndClear();
219 ::rtl::OUStringBuffer
aUStrBuf( aUStrBuftmp
);
220 sal_Bool res
= cmpustr(aUStrBuftmp
.getStr(),aUStrBuf
.getStr());
221 sal_Int32 leg
= aUStrBuf
.getLength();
227 aUStrBuf
.getLength()==aUStrBuftmp
.getLength() &&
228 aUStrBuf
.getCapacity() == aUStrBuftmp
.getCapacity() &&
230 "New OUStringBuffer from another OUStringBuffer after makeClearFromString",
236 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_ctors(
237 hTestResult hRtlTestResult
)
239 c_rtl_tres_state_start( hRtlTestResult
, "ctors");
240 sal_Bool DCState
= test_ini_uString();
242 sal_Bool bTSState
= test_rtl_OUStringBuffer_ctor_001( hRtlTestResult
);
243 bTSState
&= test_rtl_OUStringBuffer_ctor_002( hRtlTestResult
);
244 bTSState
&= test_rtl_OUStringBuffer_ctor_003( hRtlTestResult
);
245 bTSState
&= test_rtl_OUStringBuffer_ctor_004( hRtlTestResult
);
246 bTSState
&= test_rtl_OUStringBuffer_ctor_005( hRtlTestResult
);
248 c_rtl_tres_state_end( hRtlTestResult
, "ctors");
249 // return( bTSState );
252 //------------------------------------------------------------------------
253 // testing the method makeStringAndClear()
254 //------------------------------------------------------------------------
255 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_makeStringAndClear(
256 hTestResult hRtlTestResult
)
258 c_rtl_tres_state_start( hRtlTestResult
, "makeStringAndClear");
259 sal_Char methName
[MAXBUFLENGTH
];
260 sal_Char
* pMeth
= methName
;
262 typedef struct TestCase
266 OUStringBuffer
* input1
;
268 ~TestCase() { delete input1
;}
278 kEncodingRTLTextUSASCII
,
279 kConvertFlagsOStringToOUString
)
282 TestCase arrTestCase
[]={
284 {"two empty strings(def. constructor)", new OUString(),
285 new OUStringBuffer()},
286 {"two empty strings(with a argu)", new OUString(),
287 new OUStringBuffer(26)},
288 {"normal string", new OUString(arrOUS
[0]),
289 new OUStringBuffer(arrOUS
[0])},
290 {"string with space ", new OUString(arrOUS
[1]),
291 new OUStringBuffer(arrOUS
[1])},
292 {"empty string", new OUString(arrOUS
[2]),
293 new OUStringBuffer(arrOUS
[2])},
294 {"string with a character", new OUString(arrOUS
[3]),
295 new OUStringBuffer(arrOUS
[3])},
296 {"string with special characters", new OUString(arrOUS
[4]),
297 new OUStringBuffer(arrOUS
[4])},
298 {"string only with (\0)", new OUString(arrOUS
[5]),
299 new OUStringBuffer(arrOUS
[5])}
302 sal_Bool res
= sal_True
;
305 for(i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
308 ( arrTestCase
[i
].input1
->makeStringAndClear() ==
309 *( arrTestCase
[i
].expVal
));
310 lastRes
= lastRes
&& ( arrTestCase
[i
].input1
->getCapacity() == 0 );
311 lastRes
= lastRes
&& ( *(arrTestCase
[i
].input1
->getStr()) == '\0' );
317 arrTestCase
[i
].comments
,
318 createName( pMeth
, "makeStringAndClear", i
)
323 c_rtl_tres_state_end( hRtlTestResult
, "makeStringAndClear");
326 //------------------------------------------------------------------------
327 // testing the method getLength
328 //------------------------------------------------------------------------
330 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_getLength(
331 hTestResult hRtlTestResult
)
333 c_rtl_tres_state_start( hRtlTestResult
, "getLength");
334 sal_Char methName
[MAXBUFLENGTH
];
335 sal_Char
* pMeth
= methName
;
337 OUString arrOUS
[6]={OUString( aUStr1
),
339 kEncodingRTLTextUSASCII
,
340 kConvertFlagsOStringToOUString
),
343 kEncodingRTLTextUSASCII
,
344 kConvertFlagsOStringToOUString
),
346 kEncodingRTLTextUSASCII
,
347 kConvertFlagsOStringToOUString
),
350 typedef struct TestCase
354 OUStringBuffer
* input
;
355 ~TestCase() { delete input
;}
358 TestCase arrTestCase
[]={
360 {"length of ascii string", kTestStr1Len
,
361 new OUStringBuffer(arrOUS
[0]) },
362 {"length of ascci string of size 1", 1,
363 new OUStringBuffer(arrOUS
[1])},
364 {"length of empty string", 0,
365 new OUStringBuffer(arrOUS
[2])},
366 {"length of empty string (empty ascii string arg)",0,
367 new OUStringBuffer(arrOUS
[3])},
368 {"length of empty string (string arg = '\\0')", 0,
369 new OUStringBuffer(arrOUS
[4])},
370 {"length(>16) of ascii string", kTestStr2Len
,
371 new OUStringBuffer(arrOUS
[5]) },
372 {"length of empty string (default constructor)", 0,
373 new OUStringBuffer()},
374 {"length of empty string (with capacity)", 0,
375 new OUStringBuffer(26)}
379 sal_Bool res
= sal_True
;
382 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
384 sal_Int32 length
= arrTestCase
[i
].input
->getLength();
385 sal_Bool lastRes
= (length
== arrTestCase
[i
].expVal
);
390 arrTestCase
[i
].comments
,
391 createName( pMeth
, "getLength", i
)
396 c_rtl_tres_state_end( hRtlTestResult
, "getLength");
399 //------------------------------------------------------------------------
400 // testing the method getCapacity()
401 //------------------------------------------------------------------------
403 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_getCapacity(
404 hTestResult hRtlTestResult
)
406 c_rtl_tres_state_start( hRtlTestResult
, "getCapacity");
407 sal_Char methName
[MAXBUFLENGTH
];
408 sal_Char
* pMeth
= methName
;
410 OUString arrOUS
[6]={OUString( aUStr1
),
412 kEncodingRTLTextUSASCII
,
413 kConvertFlagsOStringToOUString
),
416 kEncodingRTLTextUSASCII
,
417 kConvertFlagsOStringToOUString
),
419 kEncodingRTLTextUSASCII
,
420 kConvertFlagsOStringToOUString
),
423 typedef struct TestCase
427 OUStringBuffer
* input
;
428 ~TestCase() { delete input
;}
431 TestCase arrTestCase
[]={
433 {"capacity of ascii string", kTestStr1Len
+16,
434 new OUStringBuffer(arrOUS
[0]) },
435 {"capacity of ascci string of size 1", 1+16,
436 new OUStringBuffer(arrOUS
[1]) },
437 {"capacity of empty string", 0+16,
438 new OUStringBuffer(arrOUS
[2]) },
439 {"capacity of empty string (empty ascii string arg)",0+16,
440 new OUStringBuffer(arrOUS
[3]) },
441 {"capacity of empty string (string arg = '\\0')", 0+16,
442 new OUStringBuffer(arrOUS
[4]) },
443 {"capacity(>16) of ascii string", kTestStr2Len
+16,
444 new OUStringBuffer(arrOUS
[5]) },
445 {"capacity of empty string (default constructor)", 16,
446 new OUStringBuffer() },
448 {"capacity of empty string (with capacity 2147483647)(code will core dump)", kSInt32Max
,
449 new OUStringBuffer(kSInt32Max
) },// will core dump
451 {"capacity of empty string (with capacity -2147483648)", kNonSInt32Max
,
452 new OUStringBuffer(kNonSInt32Max
) },
453 {"capacity of empty string (with capacity 16)", 16,
454 new OUStringBuffer(16) },
455 {"capacity of empty string (with capacity 6)", 6,
456 new OUStringBuffer(6) },
457 {"capacity of empty string (with capacity 0)", 0,
458 new OUStringBuffer(0) },
459 {"capacity of empty string (with capacity -2)", -2,
460 new OUStringBuffer(-2) }
464 sal_Bool res
= sal_True
;
467 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
469 sal_Int32 length
= arrTestCase
[i
].input
->getCapacity();
470 sal_Bool lastRes
= (length
== arrTestCase
[i
].expVal
);
475 arrTestCase
[i
].comments
,
476 createName( pMeth
, "getCapacity", i
)
481 c_rtl_tres_state_end( hRtlTestResult
, "getCapacity");
484 //------------------------------------------------------------------------
485 // testing the method ensureCapacity(sal_Int32 minimumCapacity)
486 //------------------------------------------------------------------------
488 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_ensureCapacity(
489 hTestResult hRtlTestResult
)
491 c_rtl_tres_state_start( hRtlTestResult
, "ensureCapacity");
492 sal_Char methName
[MAXBUFLENGTH
];
493 sal_Char
* pMeth
= methName
;
495 typedef struct TestCase
499 OUStringBuffer
* input1
;
501 ~TestCase() { delete input1
;}
504 TestCase arrTestCase
[]={
506 {"capacity equal to 16, minimum is 5 ", 16,
507 new OUStringBuffer(), 5 },
508 {"capacity equal to 16, minimum is -5", 16,
509 new OUStringBuffer(), -5},
510 {"capacity equal to 16, minimum is 0", 16,
511 new OUStringBuffer(), 0},
512 {"capacity equal to 16, minimum is 20", 20, //the testcase is based on comments
513 new OUStringBuffer(), 20},
514 {"capacity equal to 16, minimum is 50", 50,
515 new OUStringBuffer(), 50},
516 {"capacity equal to 6, minimum is 20", 20,
517 new OUStringBuffer(6), 20 },
518 {"capacity equal to 6, minimum is 2", 6,
519 new OUStringBuffer(6), 2},
520 {"capacity equal to 6, minimum is -6", 6,
521 new OUStringBuffer(6), -6},
522 {"capacity equal to 6, minimum is -6", 10, //the testcase is based on comments
523 new OUStringBuffer(6), 10},
524 {"capacity equal to 0, minimum is 6", 6,
525 new OUStringBuffer(0), 6},
526 {"capacity equal to 0, minimum is 1", 2, //the testcase is based on comments
527 new OUStringBuffer(0), 1},
529 {"capacity equal to 0, minimum is -1", 0,
530 new OUStringBuffer(0), -1},
533 {"capacity equal to 2147483647, minimum is 65535", kSInt32Max
,//will core dump
534 new OUStringBuffer(kSInt32Max
), 65535},
535 {"capacity equal to 2147483647, minimum is 2147483647", kSInt32Max
,//will core dump
536 new OUStringBuffer(kSInt32Max
), kSInt32Max
},
537 {"capacity equal to 2147483647, minimum is -1", kSInt32Max
,//will core dump
538 new OUStringBuffer(kSInt32Max
), -1},
539 {"capacity equal to 2147483647, minimum is 0", kSInt32Max
,//will core dump
540 new OUStringBuffer(kSInt32Max
), 0},
541 {"capacity equal to 2147483647, minimum is -2147483648", kSInt32Max
,//will core dump
542 new OUStringBuffer(kSInt32Max
), kNonSInt32Max
},
544 {"capacity equal to -2147483648, minimum is 65535", 65535,
545 new OUStringBuffer(kNonSInt32Max
), 65535},
547 {"capacity equal to -2147483648, minimum is 2147483647", 2147483647,//will core dump
548 new OUStringBuffer(kNonSInt32Max
), 2147483647},
550 {"capacity equal to -2147483648, minimum is -1", 2,
551 new OUStringBuffer(kNonSInt32Max
), -1},
552 {"capacity equal to -2147483648, minimum is 0", 2,
553 new OUStringBuffer(kNonSInt32Max
), 0},
554 {"capacity equal to -2147483648, minimum is -2147483648", kNonSInt32Max
,
555 new OUStringBuffer(kNonSInt32Max
), kNonSInt32Max
}
559 sal_Bool res
= sal_True
;
562 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
564 arrTestCase
[i
].input1
->ensureCapacity(arrTestCase
[i
].input2
);
565 sal_Int32 length
= arrTestCase
[i
].input1
->getCapacity();
566 sal_Bool lastRes
= (length
== arrTestCase
[i
].expVal
);
572 arrTestCase
[i
].comments
,
573 createName( pMeth
, "ensureCapacity", i
)
578 c_rtl_tres_state_end( hRtlTestResult
, "ensureCapacity");
581 //------------------------------------------------------------------------
582 // testing the method setLength(sal_Int32 newLength)
583 //------------------------------------------------------------------------
585 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_setLength(
586 hTestResult hRtlTestResult
)
588 c_rtl_tres_state_start( hRtlTestResult
, "setLength");
589 sal_Char methName
[MAXBUFLENGTH
];
590 sal_Char
* pMeth
= methName
;
592 OUString arrOUS
[6]={OUString( aUStr1
),
596 kEncodingRTLTextUSASCII
,
597 kConvertFlagsOStringToOUString
),
599 kEncodingRTLTextUSASCII
,
600 kConvertFlagsOStringToOUString
),
603 typedef struct TestCase
609 OUStringBuffer
* input1
;
611 ~TestCase() { delete input1
; delete expVal2
;}
614 TestCase arrTestCase
[]={
616 {"newLength more than the capacity of OUStringBuffer(aUStr1)",
617 50, new OUString(aUStr1
), 50,
618 new OUStringBuffer(arrOUS
[0]), 50 },
619 {"newLength more than the length of OUStringBuffer(aUStr1)",
620 kTestStr13Len
, new OUString(aUStr1
), 32,
621 new OUStringBuffer(arrOUS
[0]), kTestStr13Len
},
622 {"newLength equal to the length of OUStringBuffer(aUStr1)",
623 kTestStr1Len
, new OUString(aUStr1
), 32,
624 new OUStringBuffer(arrOUS
[0]), kTestStr1Len
},
625 {"newLength less than the length of OUStringBuffer(aUStr1)",
626 kTestStr7Len
, new OUString(aUStr7
), 32,
627 new OUStringBuffer(arrOUS
[0]), kTestStr7Len
},
628 {"newLength equal to 0",
629 0, new OUString(), 32,
630 new OUStringBuffer(arrOUS
[0]), 0},
631 {"newLength more than the capacity of OUStringBuffer(1)",
632 25, new OUString(arrOUS
[1]), 25,
633 new OUStringBuffer(arrOUS
[1]), 25},
634 {"newLength more than the length of OUStringBuffer(1)",
635 5, new OUString(arrOUS
[1]), 17,
636 new OUStringBuffer(arrOUS
[1]), 5},
637 {"newLength equal to the length of OUStringBuffer(1)",
638 kTestStr27Len
, new OUString(arrOUS
[1]), 17,
639 new OUStringBuffer(arrOUS
[1]), kTestStr27Len
},
640 {"newLength less than the length of OUStringBuffer(1)",
641 0, new OUString(), 17,
642 new OUStringBuffer(arrOUS
[1]), 0},
643 {"newLength more than the capacity of OUStringBuffer()",
644 20, new OUString(), 20,
645 new OUStringBuffer(arrOUS
[2]), 20},
646 {"newLength more than the length of OUStringBuffer()",
647 3, new OUString(), 16,
648 new OUStringBuffer(arrOUS
[2]), 3},
649 {"newLength less than the length of OUStringBuffer()",
650 0, new OUString(), 16,
651 new OUStringBuffer(arrOUS
[2]), 0},
652 {"newLength more than the capacity of OUStringBuffer("")",
653 20, new OUString(), 20,
654 new OUStringBuffer(arrOUS
[3]), 20},
655 {"newLength more than the length of OUStringBuffer("")",
656 5, new OUString(), 16,
657 new OUStringBuffer(arrOUS
[3]), 5},
658 {"newLength less than the length of OUStringBuffer("")",
659 0, new OUString(), 16,
660 new OUStringBuffer(arrOUS
[3]), 0},
661 {"newLength more than the length of OUStringBuffer(\0)",
662 20, new OUString(), 20,
663 new OUStringBuffer(arrOUS
[4]), 20},
664 {"newLength more than the length of OUStringBuffer(\0)",
665 5, new OUString(), 16,
666 new OUStringBuffer(arrOUS
[4]), 5},
667 {"newLength less than the length of OUStringBuffer(\0)",
668 0, new OUString(), 16,
669 new OUStringBuffer(arrOUS
[4]), 0},
670 {"newLength more than the capacity of OUStringBuffer(aUStr2)",
671 50, new OUString(aUStr2
), 66,
672 new OUStringBuffer(arrOUS
[5]), 50,},
673 {"newLength more than the length of OUStringBuffer(aUStr2)",
674 40, new OUString(aUStr2
), 48,
675 new OUStringBuffer(arrOUS
[5]), 40,},
676 {"newLength equal to the length of OUStringBuffer(aUStr2)",
677 kTestStr2Len
, new OUString(aUStr2
), 48,
678 new OUStringBuffer(arrOUS
[5]), kTestStr2Len
,},
679 {"newLength less than the length of OUStringBuffer(aUStr2)",
680 kTestStr7Len
, new OUString(aUStr7
), 48,
681 new OUStringBuffer(arrOUS
[5]), kTestStr7Len
},
682 {"newLength equal to 0",
683 0, new OUString(), 48,
684 new OUStringBuffer(arrOUS
[5]), 0}
689 sal_Bool res
= sal_True
;
692 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
694 arrTestCase
[i
].input1
->setLength(arrTestCase
[i
].input2
);
696 ( arrTestCase
[i
].input1
->getStr() == *(arrTestCase
[i
].expVal2
) &&
697 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal1
&&
698 arrTestCase
[i
].input1
->getCapacity() == arrTestCase
[i
].expVal3
);
704 arrTestCase
[i
].comments
,
705 createName( pMeth
, "setLength", i
)
710 c_rtl_tres_state_end( hRtlTestResult
, "setLength");
713 //------------------------------------------------------------------------
714 // testing the method charAt( sal_Int32 index )
715 //------------------------------------------------------------------------
717 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_charAt(
718 hTestResult hRtlTestResult
)
720 c_rtl_tres_state_start( hRtlTestResult
, "charAt");
721 sal_Char methName
[MAXBUFLENGTH
];
722 sal_Char
* pMeth
= methName
;
724 OUString arrOUS
[4]={OUString( aUStr1
), // "Sun Microsystems";
725 OUString( aUStr27
), // "s";
726 OUString( aUStr28
), // "\50\3\5\7\11\13\15\17sun";
729 typedef struct TestCase
733 OUStringBuffer
* input1
;
735 ~TestCase() { delete input1
;}
738 TestCase arrTestCase
[]={
740 {"return the first character of OUStringBuffer(aUStr1)",
741 83, new OUStringBuffer(arrOUS
[0]), 0 },
742 {"return the middle character of OUStringBuffer(aUStr1)",
743 32, new OUStringBuffer(arrOUS
[0]), 3 },
744 {"return the last character of OUStringBuffer(aUStr1)",
745 115, new OUStringBuffer(arrOUS
[0]), 15 },
746 {"return the only character of OUStringBuffer(aUStr27)",
747 115, new OUStringBuffer(arrOUS
[1]), 0},
748 {"return the first of OUStringBuffer(aUStr28) with special character",
749 40, new OUStringBuffer(arrOUS
[2]), 0},
751 {"return the mid of OUStringBuffer(aUStr28) with special character",
752 11, new OUStringBuffer(arrOUS[2]), 5},
755 {"invalid character of OUStringBuffer()",
756 0, new OUStringBuffer(arrOUS[3]), 0},
759 {"invalid character of OUStringBuffer()",
760 0, new OUStringBuffer(arrOUS[3]), -2}
766 sal_Bool res
= sal_True
;
769 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
772 ( arrTestCase
[i
].input1
->charAt(arrTestCase
[i
].input2
) ==
773 arrTestCase
[i
].expVal
);
774 // LLA: last case removed, due to the fact of complexity of the test code :-(
781 arrTestCase
[i
].comments
,
782 createName( pMeth
, "charAt", i
)
788 // LLA: c_rtl_tres_state
790 // LLA: hRtlTestResult,
792 // LLA: arrTestCase[i].comments,
793 // LLA: createName( pMeth, "charAt", i )
799 c_rtl_tres_state_end( hRtlTestResult
, "charAt");
802 //------------------------------------------------------------------------
803 // testing the operator const sal_Unicode * (csuc for short)
804 //------------------------------------------------------------------------
805 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_csuc(
806 hTestResult hRtlTestResult
)
808 c_rtl_tres_state_start( hRtlTestResult
, "csuc");
809 sal_Char methName
[MAXBUFLENGTH
];
810 sal_Char
* pMeth
= methName
;
812 const sal_Unicode tmpUC
=0x0;
813 rtl_uString
* tmpUstring
= NULL
;
814 const sal_Char
*tmpStr
=kTestStr1
;
815 sal_Int32 tmpLen
=(sal_Int32
) kTestStr1Len
;
816 //sal_Int32 cmpLen = 0;
817 OUString
tempString(aUStr1
);
819 rtl_string2UString( &tmpUstring
, tmpStr
, tmpLen
,
820 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS
);
821 OSL_ASSERT(tmpUstring
!= NULL
);
824 typedef struct TestCase
827 const sal_Unicode
* expVal
;
829 OUStringBuffer
* input1
;
830 ~TestCase() { delete input1
; }
833 TestCase arrTestCase
[] =
835 {"test normal ustring",(*tmpUstring
).buffer
,kTestStr1Len
,
836 new OUStringBuffer(tempString
)},
837 {"test empty ustring",&tmpUC
, 1, new OUStringBuffer()}
840 sal_Bool res
= sal_True
;
842 for(i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
844 const sal_Unicode
* pstr
= *arrTestCase
[i
].input1
;
846 res
&= c_rtl_tres_state
849 cmpustr( pstr
, arrTestCase
[i
].expVal
, arrTestCase
[i
].cmpLen
),
850 arrTestCase
[i
].comments
,
851 createName( pMeth
, "const sal_Unicode*", i
)
854 c_rtl_tres_state_end( hRtlTestResult
, "csuc");
857 //------------------------------------------------------------------------
858 // testing the method const sal_Unicode * getStr()
859 //------------------------------------------------------------------------
860 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_getStr(
861 hTestResult hRtlTestResult
)
863 c_rtl_tres_state_start( hRtlTestResult
, "getStr");
864 sal_Char methName
[MAXBUFLENGTH
];
865 sal_Char
* pMeth
= methName
;
867 const sal_Unicode tmpUC
=0x0;
868 rtl_uString
* tmpUstring
= NULL
;
869 const sal_Char
*tmpStr
=kTestStr1
;
870 sal_Int32 tmpLen
=(sal_Int32
) kTestStr1Len
;
871 //sal_Int32 cmpLen = 0;
872 OUString
tempString(aUStr1
);
874 rtl_string2UString( &tmpUstring
, tmpStr
, tmpLen
,
875 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS
);
876 OSL_ASSERT(tmpUstring
!= NULL
);
879 typedef struct TestCase
882 const sal_Unicode
* expVal
;
884 OUStringBuffer
* input1
;
885 ~TestCase() { delete input1
;}
888 TestCase arrTestCase
[] =
890 {"test normal ustring",(*tmpUstring
).buffer
,kTestStr1Len
,
891 new OUStringBuffer(tempString
)},
892 {"test empty ustring",&tmpUC
, 1, new OUStringBuffer()}
895 sal_Bool res
= sal_True
;
897 for(i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
899 const sal_Unicode
* pstr
= arrTestCase
[i
].input1
->getStr();
901 res
&= c_rtl_tres_state
904 cmpustr( pstr
, arrTestCase
[i
].expVal
, arrTestCase
[i
].cmpLen
),
905 arrTestCase
[i
].comments
,
906 createName( pMeth
, "getStr", i
)
909 c_rtl_tres_state_end( hRtlTestResult
, "getStr");
912 //------------------------------------------------------------------------
913 // testing the method setCharAt(sal_Int32 index, sal_Unicode ch)
914 //------------------------------------------------------------------------
916 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_setCharAt(
917 hTestResult hRtlTestResult
)
919 c_rtl_tres_state_start( hRtlTestResult
, "setCharAt");
920 sal_Char methName
[MAXBUFLENGTH
];
921 sal_Char
* pMeth
= methName
;
923 OUString arrOUS
[4]={OUString( aUStr1
),
928 typedef struct TestCase
932 OUStringBuffer
* input1
;
935 ~TestCase() { delete input1
; delete expVal
; }
938 TestCase arrTestCase
[]={
940 {"set the first character of OUStringBuffer(aUStr1) with s",
941 new OUString(aUStr31
),
942 new OUStringBuffer(arrOUS
[0]), 0, 115 },
943 {"set the middle character of OUStringBuffer(aUStr1) with m",
944 new OUString(aUStr3
),
945 new OUStringBuffer(arrOUS
[0]), 4, 109 },
946 {"set the last character of OUStringBuffer(aUStr1) with ' '",
947 new OUString(aUStr32
),
948 new OUStringBuffer(arrOUS
[0]), 15, 32 },
949 {"set the only character of OUStringBuffer(aUStr27) with ' '",
950 new OUString(aUStr33
),
951 new OUStringBuffer(arrOUS
[1]), 0, 32},
952 {"set the only of OUStringBuffer(aUStr28) with special character",
953 new OUString(aUStr34
),
954 new OUStringBuffer(arrOUS
[2]), 1, 5},
956 {"set the only of OUStringBuffer(aUStr28) with special character",
957 new OUString(aUStr35),
958 new OUStringBuffer(arrOUS[2]), 1, -5}
961 ,{"invalid character of OUStringBuffer()",
963 new OUStringBuffer(arrOUS
[3]), 0, 5},
964 {"invalid character of OUStringBuffer()",
966 new OUStringBuffer(arrOUS
[3]), -2, 5},
967 {"invalid character of OUStringBuffer()",
969 new OUStringBuffer(arrOUS
[3]), 3, 5}
975 sal_Bool res
= sal_True
;
978 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
981 ( (arrTestCase
[i
].input1
->setCharAt(arrTestCase
[i
].input2
,
982 arrTestCase
[i
].input3
)).getStr() == *(arrTestCase
[i
].expVal
) );
989 arrTestCase
[i
].comments
,
990 createName( pMeth
, "setCharAt", i
)
1000 arrTestCase
[i
].comments
,
1001 createName( pMeth
, "setCharAt", i
)
1007 c_rtl_tres_state_end( hRtlTestResult
, "setCharAt");
1010 //------------------------------------------------------------------------
1011 // testing the method append(const OUString &str)
1012 //------------------------------------------------------------------------
1014 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_001(
1015 hTestResult hRtlTestResult
)
1017 sal_Char methName
[MAXBUFLENGTH
];
1018 sal_Char
* pMeth
= methName
;
1020 OUString arrOUS
[5]={OUString( aUStr7
),
1022 OUString( aUStr25
),
1024 kEncodingRTLTextUSASCII
,
1025 kConvertFlagsOStringToOUString
),
1026 OUString( aUStr28
)};
1028 typedef struct TestCase
1032 OUStringBuffer
* input1
;
1035 ~TestCase() { delete input1
; delete input2
; delete expVal
; }
1038 TestCase arrTestCase
[]={
1040 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1041 new OUString(aUStr1
),
1042 new OUStringBuffer(arrOUS
[0]), new OUString(aUStr8
) },
1043 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1044 new OUString(aUStr2
),
1045 new OUStringBuffer(arrOUS
[0]), new OUString(aUStr36
) },
1046 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1047 new OUString(aUStr37
),
1048 new OUStringBuffer(arrOUS
[0]), new OUString(aUStr23
) },
1049 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1050 new OUString(aUStr7
),
1051 new OUStringBuffer(arrOUS
[0]), new OUString()},
1052 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1053 new OUString(aUStr7
),
1054 new OUStringBuffer(arrOUS
[1]), new OUString(aUStr7
)},
1055 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1056 new OUString(aUStr2
),
1057 new OUStringBuffer(arrOUS
[1]), new OUString(aUStr2
)},
1058 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1059 new OUString(aUStr1
),
1060 new OUStringBuffer(arrOUS
[1]), new OUString(aUStr1
) },
1061 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1063 new OUStringBuffer(arrOUS
[1]), new OUString()},
1064 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1065 new OUString(aUStr7
),
1066 new OUStringBuffer(arrOUS
[2]), new OUString(aUStr7
)},
1067 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1068 new OUString(aUStr2
),
1069 new OUStringBuffer(arrOUS
[2]), new OUString(aUStr2
)},
1070 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1071 new OUString(aUStr1
),
1072 new OUStringBuffer(arrOUS
[2]), new OUString(aUStr1
) },
1073 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1075 new OUStringBuffer(arrOUS
[2]), new OUString()},
1076 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1077 new OUString(aUStr7
),
1078 new OUStringBuffer(arrOUS
[3]), new OUString(aUStr7
)},
1079 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1080 new OUString(aUStr2
),
1081 new OUStringBuffer(arrOUS
[3]), new OUString(aUStr2
)},
1082 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1083 new OUString(aUStr1
),
1084 new OUStringBuffer(arrOUS
[3]), new OUString(aUStr1
) },
1085 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1087 new OUStringBuffer(arrOUS
[3]), new OUString()},
1088 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1089 new OUString(aUStr29
),
1090 new OUStringBuffer(arrOUS
[4]), new OUString(aUStr38
)},
1091 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1092 new OUString(aUStr39
),
1093 new OUStringBuffer(arrOUS
[4]), new OUString(aUStr17
)},
1094 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1095 new OUString(aUStr40
),
1096 new OUStringBuffer(arrOUS
[4]), new OUString(aUStr31
) },
1097 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1098 new OUString(aUStr28
),
1099 new OUStringBuffer(arrOUS
[4]), new OUString()}
1101 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1103 new OUStringBuffer(kSInt32Max
), new OUString()}
1108 sal_Bool res
= sal_True
;
1111 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1113 arrTestCase
[i
].input1
->append( *(arrTestCase
[i
].input2
) );
1115 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1116 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1122 arrTestCase
[i
].comments
,
1123 createName( pMeth
, "append(const OUString &str)_001", i
)
1132 //------------------------------------------------------------------------
1133 // testing the method append( const sal_Unicode * str )
1134 //------------------------------------------------------------------------
1136 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_002(
1137 hTestResult hRtlTestResult
)
1139 sal_Char methName
[MAXBUFLENGTH
];
1140 sal_Char
* pMeth
= methName
;
1142 OUString arrOUS
[5]={OUString( aUStr7
),
1144 OUString( aUStr25
),
1146 kEncodingRTLTextUSASCII
,
1147 kConvertFlagsOStringToOUString
),
1148 OUString( aUStr28
)};
1150 typedef struct TestCase
1154 OUStringBuffer
* input1
;
1155 sal_Unicode
* input2
;
1157 ~TestCase() { delete input1
; delete expVal
; }
1160 TestCase arrTestCase
[]={
1162 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1163 new OUString(aUStr1
),
1164 new OUStringBuffer(arrOUS
[0]), aUStr8
},
1165 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1166 new OUString(aUStr2
),
1167 new OUStringBuffer(arrOUS
[0]), aUStr36
},
1168 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1169 new OUString(aUStr37
),
1170 new OUStringBuffer(arrOUS
[0]), aUStr23
},
1171 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1172 new OUString(aUStr7
),
1173 new OUStringBuffer(arrOUS
[0]), aUStr25
},
1174 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1175 new OUString(aUStr7
),
1176 new OUStringBuffer(arrOUS
[1]), aUStr7
},
1177 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1178 new OUString(aUStr2
),
1179 new OUStringBuffer(arrOUS
[1]), aUStr2
},
1180 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1181 new OUString(aUStr1
),
1182 new OUStringBuffer(arrOUS
[1]), aUStr1
},
1183 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1185 new OUStringBuffer(arrOUS
[1]), aUStr25
},
1186 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1187 new OUString(aUStr7
),
1188 new OUStringBuffer(arrOUS
[2]), aUStr7
},
1189 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1190 new OUString(aUStr2
),
1191 new OUStringBuffer(arrOUS
[2]), aUStr2
},
1192 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1193 new OUString(aUStr1
),
1194 new OUStringBuffer(arrOUS
[2]), aUStr1
},
1195 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1197 new OUStringBuffer(arrOUS
[2]), aUStr25
},
1198 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1199 new OUString(aUStr7
),
1200 new OUStringBuffer(arrOUS
[3]), aUStr7
},
1201 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1202 new OUString(aUStr2
),
1203 new OUStringBuffer(arrOUS
[3]), aUStr2
},
1204 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1205 new OUString(aUStr1
),
1206 new OUStringBuffer(arrOUS
[3]), aUStr1
},
1207 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1209 new OUStringBuffer(arrOUS
[3]), aUStr25
},
1210 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1211 new OUString(aUStr29
),
1212 new OUStringBuffer(arrOUS
[4]), aUStr38
},
1213 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1214 new OUString(aUStr39
),
1215 new OUStringBuffer(arrOUS
[4]), aUStr17
},
1216 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1217 new OUString(aUStr40
),
1218 new OUStringBuffer(arrOUS
[4]), aUStr31
},
1219 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1220 new OUString(aUStr28
),
1221 new OUStringBuffer(arrOUS
[4]), aUStr25
}
1223 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1225 new OUStringBuffer(kSInt32Max
), aUStr25
}
1230 sal_Bool res
= sal_True
;
1233 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1235 arrTestCase
[i
].input1
->append( arrTestCase
[i
].input2
);
1237 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1238 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1244 arrTestCase
[i
].comments
,
1245 createName( pMeth
, "append( const sal_Unicode * str )_002", i
)
1254 //------------------------------------------------------------------------
1255 // testing the method append( const sal_Unicode * str, sal_Int32 len)
1256 //------------------------------------------------------------------------
1258 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_003(
1259 hTestResult hRtlTestResult
)
1261 sal_Char methName
[MAXBUFLENGTH
];
1262 sal_Char
* pMeth
= methName
;
1264 OUString arrOUS
[5]={OUString( aUStr7
),
1266 OUString( aUStr25
),
1268 kEncodingRTLTextUSASCII
,
1269 kConvertFlagsOStringToOUString
),
1270 OUString( aUStr28
)};
1272 typedef struct TestCase
1276 OUStringBuffer
* input1
;
1277 sal_Unicode
* input2
;
1280 ~TestCase() { delete input1
; delete expVal
; }
1283 TestCase arrTestCase
[]={
1285 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1286 new OUString(aUStr1
),
1287 new OUStringBuffer(arrOUS
[0]), aUStr36
, 12 },
1288 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1289 new OUString(aUStr2
),
1290 new OUStringBuffer(arrOUS
[0]), aUStr36
, 28 },
1291 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1292 new OUString(aUStr37
),
1293 new OUStringBuffer(arrOUS
[0]), aUStr23
, 16 },
1294 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1295 new OUString(aUStr7
),
1296 new OUStringBuffer(arrOUS
[0]), aUStr2
, 0 },
1297 /* LLA: input3 must null < 0
1298 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1299 new OUString(aUStr41),
1300 new OUStringBuffer(arrOUS[0]), aUStr2, -1 },
1302 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1303 new OUString(aUStr7
),
1304 new OUStringBuffer(arrOUS
[1]), aUStr2
, 4 },
1305 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1306 new OUString(aUStr2
),
1307 new OUStringBuffer(arrOUS
[1]), aUStr2
, 32 },
1308 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1309 new OUString(aUStr1
),
1310 new OUStringBuffer(arrOUS
[1]), aUStr2
, 16 },
1311 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1313 new OUStringBuffer(arrOUS
[1]), aUStr2
, 0 },
1314 /* LLA: input3 must null < 0
1315 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1317 new OUStringBuffer(arrOUS[1]), aUStr2, -1 },
1319 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1320 new OUString(aUStr7
),
1321 new OUStringBuffer(arrOUS
[2]), aUStr2
, 4 },
1322 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1323 new OUString(aUStr2
),
1324 new OUStringBuffer(arrOUS
[2]), aUStr2
, 32 },
1325 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1326 new OUString(aUStr1
),
1327 new OUStringBuffer(arrOUS
[2]), aUStr2
, 16 },
1328 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1330 new OUStringBuffer(arrOUS
[2]), aUStr2
, 0 },
1331 /* LLA: input3 must null < 0
1332 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1334 new OUStringBuffer(arrOUS[2]), aUStr2, -1 },
1336 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1337 new OUString(aUStr7
),
1338 new OUStringBuffer(arrOUS
[3]), aUStr2
, 4 },
1339 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1340 new OUString(aUStr2
),
1341 new OUStringBuffer(arrOUS
[3]), aUStr2
, 32 },
1342 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1343 new OUString(aUStr1
),
1344 new OUStringBuffer(arrOUS
[3]), aUStr2
, 16 },
1345 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1347 new OUStringBuffer(arrOUS
[3]), aUStr2
, 0 },
1348 /* LLA: input3 must null < 0
1349 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1351 new OUStringBuffer(arrOUS[3]), aUStr2, -1 },
1353 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1354 new OUString(aUStr29
),
1355 new OUStringBuffer(arrOUS
[4]), aUStr38
, 7 },
1356 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1357 new OUString(aUStr39
),
1358 new OUStringBuffer(arrOUS
[4]), aUStr17
, 22 },
1359 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1360 new OUString(aUStr40
),
1361 new OUStringBuffer(arrOUS
[4]), aUStr31
, 16 },
1362 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1363 new OUString(aUStr28
),
1364 new OUStringBuffer(arrOUS
[4]), aUStr2
, 0 },
1365 /* LLA: input3 must null < 0
1366 {"Appends the string(length less than 0) to the string buffer arrOUS[4]",
1367 new OUString(aUStr42),
1368 new OUStringBuffer(arrOUS[4]), aUStr2, -1 }
1371 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1373 new OUStringBuffer(kSInt32Max
), aUStr25
}
1378 sal_Bool res
= sal_True
;
1381 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1383 arrTestCase
[i
].input1
->append(
1384 arrTestCase
[i
].input2
, arrTestCase
[i
].input3
);
1386 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1387 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1393 arrTestCase
[i
].comments
,
1394 createName( pMeth
, "append( const sal_Unicode * str, sal_Int32 len)_003", i
)
1403 //------------------------------------------------------------------------
1404 // testing the method append(sal_Bool b)
1405 //------------------------------------------------------------------------
1407 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_append_004(
1408 hTestResult hRtlTestResult
)
1410 sal_Char methName
[MAXBUFLENGTH
];
1411 sal_Char
* pMeth
= methName
;
1413 OUString arrOUS
[5]={OUString( aUStr7
),
1415 OUString( aUStr25
),
1417 kEncodingRTLTextUSASCII
,
1418 kConvertFlagsOStringToOUString
),
1419 OUString( aUStr28
)};
1421 typedef struct TestCase
1425 OUStringBuffer
* input1
;
1428 ~TestCase() { delete input1
; delete expVal
; }
1431 TestCase arrTestCase
[]={
1433 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[0]",
1434 new OUString(aUStr45
),
1435 new OUStringBuffer(arrOUS
[0]), sal_True
},
1436 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[0]",
1437 new OUString(aUStr46
),
1438 new OUStringBuffer(arrOUS
[0]), sal_False
},
1439 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[1]",
1440 new OUString(aUStr47
),
1441 new OUStringBuffer(arrOUS
[1]), sal_True
},
1442 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[1]",
1443 new OUString(aUStr48
),
1444 new OUStringBuffer(arrOUS
[1]), sal_False
},
1445 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[2]",
1446 new OUString(aUStr47
),
1447 new OUStringBuffer(arrOUS
[2]), sal_True
},
1448 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[2]",
1449 new OUString(aUStr48
),
1450 new OUStringBuffer(arrOUS
[2]), sal_False
},
1451 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[3]",
1452 new OUString(aUStr47
),
1453 new OUStringBuffer(arrOUS
[3]), sal_True
},
1454 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[3]",
1455 new OUString(aUStr48
),
1456 new OUStringBuffer(arrOUS
[3]), sal_False
},
1457 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[4]",
1458 new OUString(aUStr49
),
1459 new OUStringBuffer(arrOUS
[4]), sal_True
},
1460 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[4]",
1461 new OUString(aUStr50
),
1462 new OUStringBuffer(arrOUS
[4]), sal_False
}
1464 ,{"Appends the sal_Bool(sal_True) to the string buffer(with INT_MAX) ",
1465 new OUString(aUStr47
),
1466 new OUStringBuffer(kSInt32Max
), sal_True
},
1467 {"Appends the sal_Bool(sal_False) to the string buffer(with INT_MAX) ",
1468 new OUString(aUStr48
),
1469 new OUStringBuffer(kSInt32Max
), sal_False
}
1474 sal_Bool res
= sal_True
;
1477 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1479 arrTestCase
[i
].input1
->append(
1480 arrTestCase
[i
].input2
);
1482 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1483 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1489 arrTestCase
[i
].comments
,
1490 createName( pMeth
, "append( sal_Bool b)_004", i
)
1500 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_appends(
1501 hTestResult hRtlTestResult
)
1503 c_rtl_tres_state_start( hRtlTestResult
, "appends");
1504 sal_Bool bTSState
= test_rtl_OUStringBuffer_append_001( hRtlTestResult
);
1505 bTSState
&= test_rtl_OUStringBuffer_append_002( hRtlTestResult
);
1506 bTSState
&= test_rtl_OUStringBuffer_append_003( hRtlTestResult
);
1507 bTSState
&= test_rtl_OUStringBuffer_append_004( hRtlTestResult
);
1509 c_rtl_tres_state_end( hRtlTestResult
, "appends");
1510 // return( bTSState );
1512 //------------------------------------------------------------------------
1513 // testing the method appendAscii( const sal_Char * str )
1514 //------------------------------------------------------------------------
1516 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_appendAscii_001(
1517 hTestResult hRtlTestResult
)
1519 sal_Char methName
[MAXBUFLENGTH
];
1520 sal_Char
* pMeth
= methName
;
1522 OUString arrOUS
[5]={OUString( aUStr7
),
1524 OUString( aUStr25
),
1526 kEncodingRTLTextUSASCII
,
1527 kConvertFlagsOStringToOUString
),
1528 OUString( aUStr28
)};
1530 typedef struct TestCase
1534 OUStringBuffer
* input1
;
1535 const sal_Char
* input2
;
1537 ~TestCase() { delete input1
; delete expVal
; }
1540 TestCase arrTestCase
[]={
1542 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1543 new OUString(aUStr1
),
1544 new OUStringBuffer(arrOUS
[0]), kTestStr8
},
1545 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1546 new OUString(aUStr2
),
1547 new OUStringBuffer(arrOUS
[0]), kTestStr36
},
1548 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1549 new OUString(aUStr37
),
1550 new OUStringBuffer(arrOUS
[0]), kTestStr23
},
1551 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1552 new OUString(aUStr7
),
1553 new OUStringBuffer(arrOUS
[0]), kTestStr25
},
1554 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1555 new OUString(aUStr7
),
1556 new OUStringBuffer(arrOUS
[1]), kTestStr7
},
1557 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1558 new OUString(aUStr2
),
1559 new OUStringBuffer(arrOUS
[1]), kTestStr2
},
1560 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1561 new OUString(aUStr1
),
1562 new OUStringBuffer(arrOUS
[1]), kTestStr1
},
1563 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1565 new OUStringBuffer(arrOUS
[1]), kTestStr25
},
1566 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1567 new OUString(aUStr7
),
1568 new OUStringBuffer(arrOUS
[2]), kTestStr7
},
1569 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1570 new OUString(aUStr2
),
1571 new OUStringBuffer(arrOUS
[2]), kTestStr2
},
1572 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1573 new OUString(aUStr1
),
1574 new OUStringBuffer(arrOUS
[2]), kTestStr1
},
1575 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1577 new OUStringBuffer(arrOUS
[2]), kTestStr25
},
1578 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1579 new OUString(aUStr7
),
1580 new OUStringBuffer(arrOUS
[3]), kTestStr7
},
1581 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1582 new OUString(aUStr2
),
1583 new OUStringBuffer(arrOUS
[3]), kTestStr2
},
1584 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1585 new OUString(aUStr1
),
1586 new OUStringBuffer(arrOUS
[3]), kTestStr1
},
1587 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1589 new OUStringBuffer(arrOUS
[3]), kTestStr25
},
1590 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1591 new OUString(aUStr29
),
1592 new OUStringBuffer(arrOUS
[4]), kTestStr38
},
1593 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1594 new OUString(aUStr39
),
1595 new OUStringBuffer(arrOUS
[4]), kTestStr17
},
1596 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1597 new OUString(aUStr40
),
1598 new OUStringBuffer(arrOUS
[4]), kTestStr31
},
1599 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1600 new OUString(aUStr28
),
1601 new OUStringBuffer(arrOUS
[4]), kTestStr25
}
1602 /*{"Appends the string(with special characters) to the string buffer arrOUS[4]",
1603 new OUString(aUStr43),
1604 new OUStringBuffer(arrOUS[4]), kTestStr44 }*/
1606 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1608 new OUStringBuffer(kSInt32Max
), kTestStr25
}
1614 sal_Bool res
= sal_True
;
1617 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1619 arrTestCase
[i
].input1
->appendAscii( arrTestCase
[i
].input2
);
1621 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1622 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1628 arrTestCase
[i
].comments
,
1629 createName( pMeth
, "appendAscii_001", i
)
1636 //------------------------------------------------------------------------
1637 // testing the method appendAscii( const sal_Char * str, sal_Int32 len)
1638 //------------------------------------------------------------------------
1640 sal_Bool SAL_CALL
test_rtl_OUStringBuffer_appendAscii_002(
1641 hTestResult hRtlTestResult
)
1643 sal_Char methName
[MAXBUFLENGTH
];
1644 sal_Char
* pMeth
= methName
;
1646 OUString arrOUS
[5]={OUString( aUStr7
),
1648 OUString( aUStr25
),
1650 kEncodingRTLTextUSASCII
,
1651 kConvertFlagsOStringToOUString
),
1652 OUString( aUStr28
)};
1654 typedef struct TestCase
1658 OUStringBuffer
* input1
;
1659 const sal_Char
* input2
;
1662 ~TestCase() { delete input1
; delete expVal
; }
1665 TestCase arrTestCase
[]={
1667 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1668 new OUString(aUStr1
),
1669 new OUStringBuffer(arrOUS
[0]), kTestStr36
, 12 },
1670 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1671 new OUString(aUStr2
),
1672 new OUStringBuffer(arrOUS
[0]), kTestStr36
, 28 },
1673 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1674 new OUString(aUStr37
),
1675 new OUStringBuffer(arrOUS
[0]), kTestStr23
, 16 },
1676 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1677 new OUString(aUStr7
),
1678 new OUStringBuffer(arrOUS
[0]), kTestStr2
, 0 },
1679 /* LLA: input3 must null < 0
1680 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1681 new OUString(aUStr41),
1682 new OUStringBuffer(arrOUS[0]), kTestStr2, -1 },
1684 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1685 new OUString(aUStr7
),
1686 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 4 },
1687 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1688 new OUString(aUStr2
),
1689 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 32 },
1690 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1691 new OUString(aUStr1
),
1692 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 16 },
1693 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1695 new OUStringBuffer(arrOUS
[1]), kTestStr2
, 0 },
1696 /* LLA: input3 must null < 0
1697 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1699 new OUStringBuffer(arrOUS[1]), kTestStr2, -1 },
1701 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1702 new OUString(aUStr7
),
1703 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 4 },
1704 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1705 new OUString(aUStr2
),
1706 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 32 },
1707 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1708 new OUString(aUStr1
),
1709 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 16 },
1710 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1712 new OUStringBuffer(arrOUS
[2]), kTestStr2
, 0 },
1713 /* LLA: input3 must null < 0
1714 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1716 new OUStringBuffer(arrOUS[2]), kTestStr2, -1 },
1718 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1719 new OUString(aUStr7
),
1720 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 4 },
1721 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1722 new OUString(aUStr2
),
1723 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 32 },
1724 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1725 new OUString(aUStr1
),
1726 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 16 },
1727 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1729 new OUStringBuffer(arrOUS
[3]), kTestStr2
, 0 },
1730 /* LLA: input3 must null < 0
1731 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1733 new OUStringBuffer(arrOUS[3]), kTestStr2, -1 },
1735 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1736 new OUString(aUStr29
),
1737 new OUStringBuffer(arrOUS
[4]), kTestStr38
, 7 },
1738 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1739 new OUString(aUStr39
),
1740 new OUStringBuffer(arrOUS
[4]), kTestStr17
, 22 },
1741 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1742 new OUString(aUStr40
),
1743 new OUStringBuffer(arrOUS
[4]), kTestStr31
, 16 },
1744 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1745 new OUString(aUStr28
),
1746 new OUStringBuffer(arrOUS
[4]), kTestStr2
, 0 },
1747 /* LLA: input3 must null < 0
1748 {"Appends the string(length less than 0) to the string buffer arrOUS[4]",
1749 new OUString(aUStr42),
1750 new OUStringBuffer(arrOUS[4]), kTestStr2, -1 }
1753 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1755 new OUStringBuffer(kSInt32Max
), kTestStr25
}
1760 sal_Bool res
= sal_True
;
1763 for (i
= 0; i
< (sizeof (arrTestCase
))/(sizeof (TestCase
)); i
++)
1765 arrTestCase
[i
].input1
->appendAscii(
1766 arrTestCase
[i
].input2
, arrTestCase
[i
].input3
);
1768 ( arrTestCase
[i
].input1
->getStr()== *(arrTestCase
[i
].expVal
) &&
1769 arrTestCase
[i
].input1
->getLength() == arrTestCase
[i
].expVal
->getLength() );
1775 arrTestCase
[i
].comments
,
1776 createName( pMeth
, "appendAscii_002", i
)
1784 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer_appendAsciis(
1785 hTestResult hRtlTestResult
)
1787 c_rtl_tres_state_start( hRtlTestResult
, "appendAsciis");
1788 sal_Bool bTSState
= test_rtl_OUStringBuffer_appendAscii_001( hRtlTestResult
);
1789 bTSState
&= test_rtl_OUStringBuffer_appendAscii_002( hRtlTestResult
);
1791 c_rtl_tres_state_end( hRtlTestResult
, "appendAsciis");
1792 // return( bTSState );
1794 // -----------------------------------------------------------------------------
1795 extern "C" void /* sal_Bool */ SAL_CALL
test_rtl_OUStringBuffer( hTestResult hRtlTestResult
)
1798 c_rtl_tres_state_start(hRtlTestResult
, "rtl_OUStringBuffer" );
1800 test_rtl_OUStringBuffer_ctors( hRtlTestResult
);
1801 test_rtl_OUStringBuffer_makeStringAndClear( hRtlTestResult
);
1802 test_rtl_OUStringBuffer_getLength( hRtlTestResult
);
1803 test_rtl_OUStringBuffer_getCapacity( hRtlTestResult
);
1804 test_rtl_OUStringBuffer_ensureCapacity( hRtlTestResult
);
1805 test_rtl_OUStringBuffer_setLength( hRtlTestResult
);
1806 test_rtl_OUStringBuffer_charAt( hRtlTestResult
);
1807 test_rtl_OUStringBuffer_csuc( hRtlTestResult
);
1808 test_rtl_OUStringBuffer_getStr( hRtlTestResult
);
1809 test_rtl_OUStringBuffer_setCharAt( hRtlTestResult
);
1810 test_rtl_OUStringBuffer_appends( hRtlTestResult
);
1811 test_rtl_OUStringBuffer_appendAsciis( hRtlTestResult
);
1813 c_rtl_tres_state_end(hRtlTestResult
, "rtl_OUStringBuffer");
1816 // -----------------------------------------------------------------------------
1817 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc
)
1821 (_pFunc
)(&test_rtl_OUStringBuffer
, "");