1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sal.hxx"
26 
27 #ifndef _SAL_TYPES_H_
28     #include <sal/types.h>
29 #endif
30 
31 // #ifndef _RTL_TRES_H_
32 //     #include <rtl/tres.h>
33 // #endif
34 #include <testshl/tresstatewrapper.hxx>
35 
36 #ifndef _RTL_STRING_HXX_
37     #include <rtl/string.hxx>
38 #endif
39 
40 #ifndef _RTL_USTRING_H_
41 	#include <rtl/ustring.h>
42 #endif
43 
44 #ifndef _RTL_USTRING_HXX_
45 	#include <rtl/ustring.hxx>
46 #endif
47 
48 #ifndef _RTL_USTRBUF_H_
49         #include <rtl/ustrbuf.h>
50 #endif
51 
52 #ifndef _RTL_USTRBUF_HXX
53         #include <rtl/ustrbuf.hxx>
54 #endif
55 //------------------------------------------------------------------------
56 //------------------------------------------------------------------------
57 #ifndef _OSL_THREAD_H_
58 	#include <osl/thread.h>
59 #endif
60 
61 #ifndef _RTL_STRING_CONST_H_
62     #include <rtl_String_Const.h>
63 #endif
64 
65 #ifndef _RTL_STRING_UTILS_HXX_
66     #include <rtl_String_Utils.hxx>
67 #endif
68 
69 #include "stdio.h"
70 using namespace rtl;
71 
72 //------------------------------------------------------------------------
73 // test classes
74 //------------------------------------------------------------------------
75 const int MAXBUFLENGTH = 255;
76 //------------------------------------------------------------------------
77 // helper functions
78 //------------------------------------------------------------------------
unused()79 static void unused()
80 {
81     (void)kBinaryNumsStr;
82     (void)kOctolNumsStr;
83     (void)kDecimalNumsStr;
84     (void)kHexDecimalNumsStr;
85     (void)kBase36NumsStr;
86     (void)inputChar;
87     (void)input1StrDefault;
88     (void)input1StrNormal;
89     (void)input1StrLastDefault;
90     (void)input1StrLastNormal;
91     unused();
92 }
93 
94 //------------------------------------------------------------------------
95 // testing constructors
96 //------------------------------------------------------------------------
test_rtl_OUStringBuffer_ctor_001(hTestResult hRtlTestResult)97 static sal_Bool test_rtl_OUStringBuffer_ctor_001( hTestResult hRtlTestResult )
98 {
99 
100     ::rtl::OUStringBuffer aUStrBuf;
101 
102     bool b1 =
103         aUStrBuf.getLength() == 0 &&
104         ! *(aUStrBuf.getStr()) && aUStrBuf.getCapacity() == 16;
105 
106     ::rtl::OUStringBuffer aUStrBuf2(0);
107 
108     bool b2 =
109         aUStrBuf2.getLength() == 0 &&
110         ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: !!! */ 0;
111 
112     return
113     (
114         c_rtl_tres_state
115         (
116             hRtlTestResult,
117             b1 && b2,
118             "New OUStringBuffer containing no characters",
119             "ctor_001"
120         )
121     );
122 }
123 
124 //------------------------------------------------------------------------
125 
test_rtl_OUStringBuffer_ctor_002(hTestResult hRtlTestResult)126 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_002(
127                                                hTestResult hRtlTestResult )
128 {
129     ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 );
130     ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp );
131     sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr());
132     return
133     (
134         c_rtl_tres_state
135         (
136             hRtlTestResult,
137             aUStrBuf.getLength()==aUStrBuftmp.getLength() &&
138             aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() && res ,
139             "New OUStringBuffer from another OUStringBuffer",
140             "ctor_002"
141         )
142     );
143 }
144 //------------------------------------------------------------------------
145 
146 /* static */
test_rtl_OUStringBuffer_ctor_003(hTestResult hRtlTestResult)147 sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_003(
148                                                hTestResult hRtlTestResult )
149 {
150     ::rtl::OUStringBuffer aUStrBuf1(kTestStr2Len);
151 #ifdef WITH_CORE
152     ::rtl::OUStringBuffer aUStrBuf2(kSInt32Max);     //will core dump
153 #else
154     ::rtl::OUStringBuffer aUStrBuf2(0);
155 #endif
156     ::rtl::OUStringBuffer aUStrBuf3(kNonSInt32Max);
157 
158 
159     bool b1 =
160         aUStrBuf1.getLength() == 0 &&
161         ! *(aUStrBuf1.getStr()) && aUStrBuf1.getCapacity() == kTestStr2Len ;
162 
163     bool b2 =
164 #ifdef WITH_CORE
165         aUStrBuf2.getLength() == 0 &&
166         ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == kSInt32Max ;
167 #else
168         aUStrBuf2.getLength() == 0 &&
169             ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: ??? 16 */ 0;
170 #endif
171     bool b3 =
172         aUStrBuf3.getLength() == 0 &&
173         ! *(aUStrBuf3.getStr()) && aUStrBuf3.getCapacity() == kNonSInt32Max;
174 
175     return
176         (
177             c_rtl_tres_state
178             (
179                 hRtlTestResult,
180                 b1 && b2 && b3,
181                 "New OUStringBuffer containing no characters and contain assigned capacity",
182                 "ctor_003( will core dump,because the kSInt32Max )"
183                 )
184             );
185 
186 }
187 
188 //------------------------------------------------------------------------
189 
test_rtl_OUStringBuffer_ctor_004(hTestResult hRtlTestResult)190 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_004(
191                                                hTestResult hRtlTestResult)
192 {
193     ::rtl::OUString aUStrtmp( aUStr1 );
194     ::rtl::OUStringBuffer aUStrBuf( aUStrtmp );
195     sal_Int32 leg = aUStrBuf.getLength();
196     return
197     (
198         c_rtl_tres_state
199         (
200             hRtlTestResult,
201             aUStrBuf.getStr() == aUStrtmp &&
202             leg == aUStrtmp.pData->length &&
203             aUStrBuf.getCapacity() == leg+16 ,
204             "New OUStringBuffer from OUstring",
205             "ctor_004"
206         )
207     );
208 }
209 
test_rtl_OUStringBuffer_ctor_005(hTestResult hRtlTestResult)210 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_005(
211                                                hTestResult hRtlTestResult)
212 {
213     ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 );
214     ::rtl::OUString aUStrtmp = aUStrBuftmp.makeStringAndClear();
215     ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp );
216     sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr());
217     sal_Int32 leg = aUStrBuf.getLength();
218     return
219     (
220         c_rtl_tres_state
221         (
222             hRtlTestResult,
223             aUStrBuf.getLength()==aUStrBuftmp.getLength() &&
224             aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() &&
225             res && leg == 0,
226             "New OUStringBuffer from another OUStringBuffer after makeClearFromString",
227             "ctor_005"
228         )
229     );
230 }
231 
test_rtl_OUStringBuffer_ctors(hTestResult hRtlTestResult)232 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ctors(
233 	                                          hTestResult hRtlTestResult )
234 {
235     c_rtl_tres_state_start( hRtlTestResult, "ctors");
236     sal_Bool DCState = test_ini_uString();
237     (void)DCState;
238     sal_Bool bTSState = test_rtl_OUStringBuffer_ctor_001( hRtlTestResult );
239     bTSState &= test_rtl_OUStringBuffer_ctor_002( hRtlTestResult);
240     bTSState &= test_rtl_OUStringBuffer_ctor_003( hRtlTestResult);
241     bTSState &= test_rtl_OUStringBuffer_ctor_004( hRtlTestResult);
242     bTSState &= test_rtl_OUStringBuffer_ctor_005( hRtlTestResult);
243 
244     c_rtl_tres_state_end( hRtlTestResult, "ctors");
245 //    return( bTSState );
246 }
247 
248 //------------------------------------------------------------------------
249 // testing the method makeStringAndClear()
250 //------------------------------------------------------------------------
test_rtl_OUStringBuffer_makeStringAndClear(hTestResult hRtlTestResult)251 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_makeStringAndClear(
252                                               hTestResult hRtlTestResult )
253 {
254     c_rtl_tres_state_start( hRtlTestResult, "makeStringAndClear");
255     sal_Char methName[MAXBUFLENGTH];
256     sal_Char* pMeth = methName;
257 
258     typedef struct TestCase
259     {
260 	sal_Char*		comments;
261 	OUString*               expVal;
262     	OUStringBuffer*         input1;
263 
264 	~TestCase()		{ delete input1;}
265     } TestCase;
266 
267     OUString arrOUS[6]={
268         OUString( aUStr1 ),
269         OUString( aUStr14 ),
270         OUString( aUStr25 ),
271         OUString( aUStr27 ),
272         OUString( aUStr29 ),
273         OUString( "\0",0,
274 	          kEncodingRTLTextUSASCII,
275 	          kConvertFlagsOStringToOUString)
276     };
277 
278     TestCase arrTestCase[]={
279 
280 	{"two empty strings(def. constructor)", new OUString(),
281                 new OUStringBuffer()},
282 	{"two empty strings(with a argu)", new OUString(),
283 		new OUStringBuffer(26)},
284 	{"normal string", new OUString(arrOUS[0]),
285                 new OUStringBuffer(arrOUS[0])},
286 	{"string with space ", new OUString(arrOUS[1]),
287 	    	new OUStringBuffer(arrOUS[1])},
288 	{"empty string", new OUString(arrOUS[2]),
289 	    	new OUStringBuffer(arrOUS[2])},
290 	{"string with a character", new OUString(arrOUS[3]),
291 	    	new OUStringBuffer(arrOUS[3])},
292 	{"string with special characters", new OUString(arrOUS[4]),
293                 new OUStringBuffer(arrOUS[4])},
294 	{"string only with (\0)", new OUString(arrOUS[5]),
295                 new OUStringBuffer(arrOUS[5])}
296     };
297 
298     sal_Bool res = sal_True;
299     sal_uInt32 i;
300 
301     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
302     {
303         sal_Bool lastRes =
304                 ( arrTestCase[i].input1->makeStringAndClear() ==
305                                       		*( arrTestCase[i].expVal ));
306         lastRes = lastRes && ( arrTestCase[i].input1->getCapacity() == 0 );
307         lastRes = lastRes && ( *(arrTestCase[i].input1->getStr()) == '\0' );
308 
309         c_rtl_tres_state
310         (
311             hRtlTestResult,
312             lastRes,
313             arrTestCase[i].comments,
314             createName( pMeth, "makeStringAndClear", i )
315         );
316 
317         res &= lastRes;
318     }
319     c_rtl_tres_state_end( hRtlTestResult, "makeStringAndClear");
320 //    return (res);
321 }
322 //------------------------------------------------------------------------
323 // testing the method getLength
324 //------------------------------------------------------------------------
325 
test_rtl_OUStringBuffer_getLength(hTestResult hRtlTestResult)326 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getLength(
327                                               hTestResult hRtlTestResult)
328 {
329     c_rtl_tres_state_start( hRtlTestResult, "getLength");
330     sal_Char methName[MAXBUFLENGTH];
331     sal_Char* pMeth = methName;
332 
333     OUString arrOUS[6]={OUString( aUStr1 ),
334                         OUString( "1",1,
335 	                kEncodingRTLTextUSASCII,
336 	                kConvertFlagsOStringToOUString),
337                         OUString(),
338                         OUString( "",0,
339 	                kEncodingRTLTextUSASCII,
340 	                kConvertFlagsOStringToOUString),
341                         OUString( "\0",0,
342 	                kEncodingRTLTextUSASCII,
343 	                kConvertFlagsOStringToOUString),
344                         OUString( aUStr2 )};
345 
346     typedef struct TestCase
347     {
348 	sal_Char*		comments;
349 	sal_Int32 		expVal;
350     	OUStringBuffer*         input;
351     	~TestCase()             { delete input;}
352     } TestCase;
353 
354     TestCase arrTestCase[]={
355 
356 	{"length of ascii string", kTestStr1Len,
357 			new OUStringBuffer(arrOUS[0]) },
358     	{"length of ascci string of size 1", 1,
359     			new OUStringBuffer(arrOUS[1])},
360     	{"length of empty string", 0,
361                         new OUStringBuffer(arrOUS[2])},
362 	{"length of empty string (empty ascii string arg)",0,
363 			new OUStringBuffer(arrOUS[3])},
364 	{"length of empty string (string arg = '\\0')", 0,
365 			new OUStringBuffer(arrOUS[4])},
366         {"length(>16) of ascii string", kTestStr2Len,
367 			new OUStringBuffer(arrOUS[5]) },
368         {"length of empty string (default constructor)", 0,
369                         new OUStringBuffer()},
370         {"length of empty string (with capacity)", 0,
371                         new OUStringBuffer(26)}
372 	};
373 
374 
375     sal_Bool res = sal_True;
376     sal_uInt32 i;
377 
378     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
379     {
380 	sal_Int32 length = arrTestCase[i].input->getLength();
381         sal_Bool lastRes = (length == arrTestCase[i].expVal);
382         c_rtl_tres_state
383         (
384             hRtlTestResult,
385             lastRes,
386             arrTestCase[i].comments,
387             createName( pMeth, "getLength", i )
388 
389         );
390 	res &= lastRes;
391     }
392     c_rtl_tres_state_end( hRtlTestResult, "getLength");
393 //    return ( res );
394 }
395 //------------------------------------------------------------------------
396 // testing the method getCapacity()
397 //------------------------------------------------------------------------
398 
test_rtl_OUStringBuffer_getCapacity(hTestResult hRtlTestResult)399 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getCapacity(
400                                               hTestResult hRtlTestResult)
401 {
402     c_rtl_tres_state_start( hRtlTestResult, "getCapacity");
403     sal_Char methName[MAXBUFLENGTH];
404     sal_Char* pMeth = methName;
405 
406     OUString arrOUS[6]={OUString( aUStr1 ),
407                         OUString( "1",1,
408 	                kEncodingRTLTextUSASCII,
409 	                kConvertFlagsOStringToOUString),
410                         OUString(),
411                         OUString( "",0,
412 	                kEncodingRTLTextUSASCII,
413 	                kConvertFlagsOStringToOUString),
414                         OUString( "\0",0,
415 	                kEncodingRTLTextUSASCII,
416 	                kConvertFlagsOStringToOUString),
417                         OUString( aUStr2 )};
418 
419     typedef struct TestCase
420     {
421 	sal_Char*		comments;
422 	sal_Int32 		expVal;
423     	OUStringBuffer*         input;
424     	~TestCase()             { delete input;}
425     } TestCase;
426 
427     TestCase arrTestCase[]={
428 
429 	{"capacity of ascii string", kTestStr1Len+16,
430 			new OUStringBuffer(arrOUS[0]) },
431     	{"capacity of ascci string of size 1", 1+16,
432     			new OUStringBuffer(arrOUS[1]) },
433     	{"capacity of empty string", 0+16,
434                         new OUStringBuffer(arrOUS[2]) },
435 	{"capacity of empty string (empty ascii string arg)",0+16,
436 			new OUStringBuffer(arrOUS[3]) },
437 	{"capacity of empty string (string arg = '\\0')", 0+16,
438 			new OUStringBuffer(arrOUS[4]) },
439         {"capacity(>16) of ascii string", kTestStr2Len+16,
440 			new OUStringBuffer(arrOUS[5]) },
441         {"capacity of empty string (default constructor)", 16,
442                         new OUStringBuffer() },
443 #ifdef WITH_CORE
444         {"capacity of empty string (with capacity 2147483647)(code will core dump)", kSInt32Max,
445                         new OUStringBuffer(kSInt32Max) },// will core dump
446 #endif
447         {"capacity of empty string (with capacity -2147483648)", kNonSInt32Max,
448                         new OUStringBuffer(kNonSInt32Max) },
449         {"capacity of empty string (with capacity 16)", 16,
450                         new OUStringBuffer(16) },
451         {"capacity of empty string (with capacity 6)", 6,
452                         new OUStringBuffer(6) },
453         {"capacity of empty string (with capacity 0)", 0,
454                         new OUStringBuffer(0) },
455         {"capacity of empty string (with capacity -2)", -2,
456                         new OUStringBuffer(-2) }
457 	};
458 
459 
460     sal_Bool res = sal_True;
461     sal_uInt32 i;
462 
463     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
464     {
465 	sal_Int32 length = arrTestCase[i].input->getCapacity();
466         sal_Bool lastRes = (length == arrTestCase[i].expVal);
467         c_rtl_tres_state
468         (
469             hRtlTestResult,
470             lastRes,
471             arrTestCase[i].comments,
472             createName( pMeth, "getCapacity", i )
473 
474         );
475 	res &= lastRes;
476     }
477     c_rtl_tres_state_end( hRtlTestResult, "getCapacity");
478 //    return ( res );
479 }
480 //------------------------------------------------------------------------
481 // testing the method ensureCapacity(sal_Int32 minimumCapacity)
482 //------------------------------------------------------------------------
483 
test_rtl_OUStringBuffer_ensureCapacity(hTestResult hRtlTestResult)484 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ensureCapacity(
485                                               hTestResult hRtlTestResult)
486 {
487     c_rtl_tres_state_start( hRtlTestResult, "ensureCapacity");
488     sal_Char methName[MAXBUFLENGTH];
489     sal_Char* pMeth = methName;
490 
491     typedef struct TestCase
492     {
493 	sal_Char*		comments;
494 	sal_Int32 		expVal;
495     	OUStringBuffer*         input1;
496         sal_Int32               input2;
497     	~TestCase()             { delete input1;}
498     } TestCase;
499 
500     TestCase arrTestCase[]={
501 
502 	{"capacity equal to 16, minimum is 5 ", 16,
503 			new OUStringBuffer(), 5 },
504     	{"capacity equal to 16, minimum is -5", 16,
505     			new OUStringBuffer(), -5},
506     	{"capacity equal to 16, minimum is 0", 16,
507                         new OUStringBuffer(), 0},
508 	{"capacity equal to 16, minimum is 20", 20, //the testcase is based on comments
509 			new OUStringBuffer(), 20},
510 	{"capacity equal to 16, minimum is 50", 50,
511 			new OUStringBuffer(), 50},
512         {"capacity equal to 6, minimum is 20", 20,
513 			new OUStringBuffer(6), 20 },
514         {"capacity equal to 6, minimum is 2", 6,
515                         new OUStringBuffer(6), 2},
516         {"capacity equal to 6, minimum is -6", 6,
517                         new OUStringBuffer(6), -6},
518         {"capacity equal to 6, minimum is -6", 10, //the testcase is based on comments
519                         new OUStringBuffer(6), 10},
520         {"capacity equal to 0, minimum is 6", 6,
521                         new OUStringBuffer(0), 6},
522         {"capacity equal to 0, minimum is 1", 2, //the testcase is based on comments
523                         new OUStringBuffer(0), 1},
524     /*
525       {"capacity equal to 0, minimum is -1", 0,
526                         new OUStringBuffer(0), -1},
527     */
528 #ifdef WITH_CORE
529         {"capacity equal to 2147483647, minimum is 65535", kSInt32Max,//will core dump
530                         new OUStringBuffer(kSInt32Max), 65535},
531         {"capacity equal to 2147483647, minimum is 2147483647", kSInt32Max,//will core dump
532                         new OUStringBuffer(kSInt32Max), kSInt32Max},
533         {"capacity equal to 2147483647, minimum is -1", kSInt32Max,//will core dump
534                         new OUStringBuffer(kSInt32Max), -1},
535         {"capacity equal to 2147483647, minimum is 0", kSInt32Max,//will core dump
536                         new OUStringBuffer(kSInt32Max), 0},
537         {"capacity equal to 2147483647, minimum is -2147483648", kSInt32Max,//will core dump
538                         new OUStringBuffer(kSInt32Max), kNonSInt32Max},
539 #endif
540         {"capacity equal to -2147483648, minimum is 65535", 65535,
541                         new OUStringBuffer(kNonSInt32Max), 65535},
542 #ifdef WITH_CORE
543         {"capacity equal to -2147483648, minimum is 2147483647", 2147483647,//will core dump
544                         new OUStringBuffer(kNonSInt32Max), 2147483647},
545 #endif
546         {"capacity equal to -2147483648, minimum is -1", 2,
547                         new OUStringBuffer(kNonSInt32Max), -1},
548         {"capacity equal to -2147483648, minimum is 0", 2,
549                         new OUStringBuffer(kNonSInt32Max), 0},
550         {"capacity equal to -2147483648, minimum is -2147483648", kNonSInt32Max,
551                         new OUStringBuffer(kNonSInt32Max), kNonSInt32Max}
552  	};
553 
554 
555     sal_Bool res = sal_True;
556     sal_uInt32 i;
557 
558     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
559     {
560 	arrTestCase[i].input1->ensureCapacity(arrTestCase[i].input2);
561         sal_Int32 length = arrTestCase[i].input1->getCapacity();
562         sal_Bool lastRes = (length == arrTestCase[i].expVal);
563 
564         c_rtl_tres_state
565         (
566             hRtlTestResult,
567             lastRes,
568             arrTestCase[i].comments,
569             createName( pMeth, "ensureCapacity", i )
570 
571         );
572 	res &= lastRes;
573     }
574     c_rtl_tres_state_end( hRtlTestResult, "ensureCapacity");
575 //    return ( res );
576 }
577 //------------------------------------------------------------------------
578 // testing the method setLength(sal_Int32 newLength)
579 //------------------------------------------------------------------------
580 
test_rtl_OUStringBuffer_setLength(hTestResult hRtlTestResult)581 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_setLength(
582                                               hTestResult hRtlTestResult)
583 {
584     c_rtl_tres_state_start( hRtlTestResult, "setLength");
585     sal_Char methName[MAXBUFLENGTH];
586     sal_Char* pMeth = methName;
587 
588     OUString arrOUS[6]={OUString( aUStr1 ),
589                         OUString( aUStr27),
590                         OUString(),
591                         OUString( "",0,
592 	                kEncodingRTLTextUSASCII,
593 	                kConvertFlagsOStringToOUString),
594                         OUString( "\0",0,
595 	                kEncodingRTLTextUSASCII,
596 	                kConvertFlagsOStringToOUString),
597                         OUString( aUStr2 )};
598 
599     typedef struct TestCase
600     {
601 	sal_Char*		comments;
602 	sal_Int32 		expVal1;
603     	OUString*               expVal2;
604 	sal_Int32 		expVal3;
605         OUStringBuffer*         input1;
606         sal_Int32               input2;
607     	~TestCase()             { delete input1; delete expVal2;}
608     } TestCase;
609 
610     TestCase arrTestCase[]={
611 
612 	{"newLength more than the capacity of OUStringBuffer(aUStr1)",
613                 50, new OUString(aUStr1), 50,
614                 new OUStringBuffer(arrOUS[0]), 50 },
615 	{"newLength more than the length of OUStringBuffer(aUStr1)",
616                 kTestStr13Len, new OUString(aUStr1), 32,
617                 new OUStringBuffer(arrOUS[0]), kTestStr13Len },
618         {"newLength equal to the length of OUStringBuffer(aUStr1)",
619                 kTestStr1Len, new OUString(aUStr1), 32,
620                 new OUStringBuffer(arrOUS[0]), kTestStr1Len },
621     	{"newLength less than the length of OUStringBuffer(aUStr1)",
622                 kTestStr7Len, new OUString(aUStr7), 32,
623                 new OUStringBuffer(arrOUS[0]), kTestStr7Len},
624     	{"newLength equal to 0",
625                 0, new OUString(), 32,
626                 new OUStringBuffer(arrOUS[0]), 0},
627 	{"newLength more than the capacity of OUStringBuffer(1)",
628                 25, new OUString(arrOUS[1]), 25,
629                 new OUStringBuffer(arrOUS[1]), 25},
630 	{"newLength more than the length of OUStringBuffer(1)",
631                 5, new OUString(arrOUS[1]), 17,
632                 new OUStringBuffer(arrOUS[1]), 5},
633 	{"newLength equal to the length of OUStringBuffer(1)",
634                 kTestStr27Len, new OUString(arrOUS[1]), 17,
635                 new OUStringBuffer(arrOUS[1]), kTestStr27Len},
636 	{"newLength less than the length of OUStringBuffer(1)",
637                 0, new OUString(), 17,
638                 new OUStringBuffer(arrOUS[1]), 0},
639 	{"newLength more than the capacity of OUStringBuffer()",
640                 20, new OUString(), 20,
641                 new OUStringBuffer(arrOUS[2]), 20},
642 	{"newLength more than the length of OUStringBuffer()",
643                 3, new OUString(), 16,
644                 new OUStringBuffer(arrOUS[2]), 3},
645 	{"newLength less than the length of OUStringBuffer()",
646                 0, new OUString(), 16,
647                 new OUStringBuffer(arrOUS[2]), 0},
648 	{"newLength more than the capacity of OUStringBuffer("")",
649                 20, new OUString(), 20,
650                 new OUStringBuffer(arrOUS[3]), 20},
651 	{"newLength more than the length of OUStringBuffer("")",
652                 5, new OUString(), 16,
653                 new OUStringBuffer(arrOUS[3]), 5},
654 	{"newLength less than the length of OUStringBuffer("")",
655                 0, new OUString(), 16,
656                 new OUStringBuffer(arrOUS[3]), 0},
657 	{"newLength more than the length of OUStringBuffer(\0)",
658                 20, new OUString(), 20,
659                 new OUStringBuffer(arrOUS[4]), 20},
660 	{"newLength more than the length of OUStringBuffer(\0)",
661                 5, new OUString(), 16,
662                 new OUStringBuffer(arrOUS[4]), 5},
663 	{"newLength less than the length of OUStringBuffer(\0)",
664                 0, new OUString(), 16,
665                 new OUStringBuffer(arrOUS[4]), 0},
666 	{"newLength more than the capacity of OUStringBuffer(aUStr2)",
667                 50, new OUString(aUStr2), 66,
668                 new OUStringBuffer(arrOUS[5]), 50,},
669 	{"newLength more than the length of OUStringBuffer(aUStr2)",
670                 40, new OUString(aUStr2), 48,
671                 new OUStringBuffer(arrOUS[5]), 40,},
672 	{"newLength equal to the length of OUStringBuffer(aUStr2)",
673                 kTestStr2Len, new OUString(aUStr2), 48,
674                 new OUStringBuffer(arrOUS[5]), kTestStr2Len,},
675     	{"newLength less than the length of OUStringBuffer(aUStr2)",
676                 kTestStr7Len, new OUString(aUStr7), 48,
677                 new OUStringBuffer(arrOUS[5]), kTestStr7Len},
678     	{"newLength equal to 0",
679                 0, new OUString(), 48,
680                 new OUStringBuffer(arrOUS[5]), 0}
681 
682 	};
683 
684 
685     sal_Bool res = sal_True;
686     sal_uInt32 i;
687 
688     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
689     {
690 	arrTestCase[i].input1->setLength(arrTestCase[i].input2);
691         sal_Bool lastRes =
692             ( arrTestCase[i].input1->getStr() == *(arrTestCase[i].expVal2) &&
693               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal1 &&
694               arrTestCase[i].input1->getCapacity() == arrTestCase[i].expVal3 );
695 
696         c_rtl_tres_state
697         (
698             hRtlTestResult,
699             lastRes,
700             arrTestCase[i].comments,
701             createName( pMeth, "setLength", i )
702 
703         );
704 	res &= lastRes;
705     }
706     c_rtl_tres_state_end( hRtlTestResult, "setLength");
707 //    return ( res );
708 }
709 //------------------------------------------------------------------------
710 // testing the method charAt( sal_Int32 index )
711 //------------------------------------------------------------------------
712 
test_rtl_OUStringBuffer_charAt(hTestResult hRtlTestResult)713 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_charAt(
714                                               hTestResult hRtlTestResult)
715 {
716     c_rtl_tres_state_start( hRtlTestResult, "charAt");
717     sal_Char methName[MAXBUFLENGTH];
718     sal_Char* pMeth = methName;
719 
720     OUString arrOUS[4]={OUString( aUStr1 ), // "Sun Microsystems";
721                         OUString( aUStr27), // "s";
722                         OUString( aUStr28), // "\50\3\5\7\11\13\15\17sun";
723                         OUString( )};
724 
725     typedef struct TestCase
726     {
727         sal_Char*		comments;
728         sal_Unicode 		expVal;
729         OUStringBuffer*         input1;
730         sal_Int32               input2;
731     	~TestCase()             { delete input1;}
732     } TestCase;
733 
734     TestCase arrTestCase[]={
735 
736 	{"return the first character of OUStringBuffer(aUStr1)",
737                 83, new OUStringBuffer(arrOUS[0]), 0 },
738 	{"return the middle character of OUStringBuffer(aUStr1)",
739                 32, new OUStringBuffer(arrOUS[0]), 3 },
740         {"return the last character of OUStringBuffer(aUStr1)",
741                 115, new OUStringBuffer(arrOUS[0]), 15 },
742 	{"return the only character of OUStringBuffer(aUStr27)",
743                 115, new OUStringBuffer(arrOUS[1]), 0},
744 	{"return the first of OUStringBuffer(aUStr28) with special character",
745                 40, new OUStringBuffer(arrOUS[2]), 0},
746 	/*
747 {"return the mid of OUStringBuffer(aUStr28) with special character",
748                 11, new OUStringBuffer(arrOUS[2]), 5},
749 */
750 /*
751         {"invalid character of OUStringBuffer()",
752                 0, new OUStringBuffer(arrOUS[3]), 0},
753 */
754 /*
755         {"invalid character of OUStringBuffer()",
756                 0, new OUStringBuffer(arrOUS[3]), -2}
757 */
758 
759 	};
760 
761 
762     sal_Bool res = sal_True;
763     sal_uInt32 i;
764 
765     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
766     {
767         sal_Bool lastRes =
768             ( arrTestCase[i].input1->charAt(arrTestCase[i].input2) ==
769               arrTestCase[i].expVal );
770         // LLA: last case removed, due to the fact of complexity of the test code :-(
771         // LLA: if(i<=7)
772         // LLA: {
773         c_rtl_tres_state
774             (
775                 hRtlTestResult,
776                 lastRes,
777                 arrTestCase[i].comments,
778                 createName( pMeth, "charAt", i )
779 
780                 );
781         // LLA: }
782         // LLA: else
783         // LLA: {
784         // LLA:     c_rtl_tres_state
785         // LLA:     (
786         // LLA:         hRtlTestResult,
787         // LLA:         sal_True,
788         // LLA:         arrTestCase[i].comments,
789         // LLA:         createName( pMeth, "charAt", i )
790         // LLA:
791         // LLA:     );
792         // LLA: }
793 	res &= lastRes;
794     }
795     c_rtl_tres_state_end( hRtlTestResult, "charAt");
796 //    return ( res );
797 }
798 //------------------------------------------------------------------------
799 // testing the operator const sal_Unicode * (csuc for short)
800 //------------------------------------------------------------------------
test_rtl_OUStringBuffer_csuc(hTestResult hRtlTestResult)801 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_csuc(
802                                               hTestResult hRtlTestResult)
803 {
804     c_rtl_tres_state_start( hRtlTestResult, "csuc");
805 	sal_Char methName[MAXBUFLENGTH];
806 	sal_Char* pMeth = methName;
807 
808 	const sal_Unicode tmpUC=0x0;
809 	rtl_uString* tmpUstring = NULL;
810 	const sal_Char *tmpStr=kTestStr1;
811 	sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
812 	//sal_Int32 cmpLen = 0;
813         OUString tempString(aUStr1);
814 
815 	rtl_string2UString( &tmpUstring, tmpStr,  tmpLen,
816 		osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
817     OSL_ASSERT(tmpUstring != NULL);
818 
819 
820 	typedef struct TestCase
821         {
822             sal_Char*		           comments;
823             const sal_Unicode*             expVal;
824             sal_Int32                      cmpLen;
825             OUStringBuffer*                input1;
826             ~TestCase()                    {  delete input1; }
827  	} TestCase;
828 
829     TestCase arrTestCase[] =
830     {
831       	{"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
832       				new OUStringBuffer(tempString)},
833         {"test empty ustring",&tmpUC, 1, new OUStringBuffer()}
834     };
835 
836     sal_Bool res = sal_True;
837     sal_uInt32 i;
838     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
839     {
840        const sal_Unicode* pstr = *arrTestCase[i].input1;
841 
842        res &= c_rtl_tres_state
843        (
844             hRtlTestResult,
845             cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ),
846             arrTestCase[i].comments,
847             createName( pMeth, "const sal_Unicode*", i )
848        );
849     }
850     c_rtl_tres_state_end( hRtlTestResult, "csuc");
851 //    return ( res );
852 }
853 //------------------------------------------------------------------------
854 // testing the method const sal_Unicode * getStr()
855 //------------------------------------------------------------------------
test_rtl_OUStringBuffer_getStr(hTestResult hRtlTestResult)856 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getStr(
857                                               hTestResult hRtlTestResult)
858 {
859     c_rtl_tres_state_start( hRtlTestResult, "getStr");
860 	sal_Char methName[MAXBUFLENGTH];
861 	sal_Char* pMeth = methName;
862 
863 	const sal_Unicode tmpUC=0x0;
864 	rtl_uString* tmpUstring = NULL;
865 	const sal_Char *tmpStr=kTestStr1;
866 	sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
867 	//sal_Int32 cmpLen = 0;
868         OUString tempString(aUStr1);
869 
870 	rtl_string2UString( &tmpUstring, tmpStr,  tmpLen,
871 		osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
872     OSL_ASSERT(tmpUstring != NULL);
873 
874 
875     typedef struct TestCase
876     {
877         sal_Char*			comments;
878         const sal_Unicode*		expVal;
879         sal_Int32			cmpLen;
880         OUStringBuffer*                 input1;
881         ~TestCase()                     {  delete input1;}
882     } TestCase;
883 
884     TestCase arrTestCase[] =
885     {
886       	{"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
887       				new OUStringBuffer(tempString)},
888         {"test empty ustring",&tmpUC, 1, new OUStringBuffer()}
889     };
890 
891     sal_Bool res = sal_True;
892     sal_uInt32 i;
893     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
894     {
895        const sal_Unicode* pstr = arrTestCase[i].input1->getStr();
896 
897        res &= c_rtl_tres_state
898        (
899             hRtlTestResult,
900             cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ),
901             arrTestCase[i].comments,
902             createName( pMeth, "getStr", i )
903        );
904     }
905     c_rtl_tres_state_end( hRtlTestResult, "getStr");
906 //    return ( res );
907 }
908 //------------------------------------------------------------------------
909 // testing the method setCharAt(sal_Int32 index, sal_Unicode ch)
910 //------------------------------------------------------------------------
911 
test_rtl_OUStringBuffer_setCharAt(hTestResult hRtlTestResult)912 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_setCharAt(
913                                               hTestResult hRtlTestResult)
914 {
915     c_rtl_tres_state_start( hRtlTestResult, "setCharAt");
916     sal_Char methName[MAXBUFLENGTH];
917     sal_Char* pMeth = methName;
918 
919     OUString arrOUS[4]={OUString( aUStr1 ),
920                         OUString( aUStr27),
921                         OUString( aUStr28),
922                         OUString( )};
923 
924     typedef struct TestCase
925     {
926 	sal_Char*		comments;
927 	OUString*               expVal;
928         OUStringBuffer*         input1;
929         sal_Int32               input2;
930         sal_Unicode             input3;
931     	~TestCase()             { delete input1; delete expVal; }
932     } TestCase;
933 
934     TestCase arrTestCase[]={
935 
936 	{"set the first character of OUStringBuffer(aUStr1) with s",
937                 new OUString(aUStr31),
938                 new OUStringBuffer(arrOUS[0]), 0, 115 },
939 	{"set the middle character of OUStringBuffer(aUStr1) with m",
940                 new OUString(aUStr3),
941                 new OUStringBuffer(arrOUS[0]), 4, 109 },
942         {"set the last character of OUStringBuffer(aUStr1) with ' '",
943                 new OUString(aUStr32),
944                 new OUStringBuffer(arrOUS[0]), 15, 32 },
945 	{"set the only character of OUStringBuffer(aUStr27) with ' '",
946                 new OUString(aUStr33),
947                 new OUStringBuffer(arrOUS[1]), 0, 32},
948 	{"set the only of OUStringBuffer(aUStr28) with special character",
949                 new OUString(aUStr34),
950                 new OUStringBuffer(arrOUS[2]), 1, 5},
951 /*
952         {"set the only of OUStringBuffer(aUStr28) with special character",
953                 new OUString(aUStr35),
954                 new OUStringBuffer(arrOUS[2]), 1, -5}
955 */
956 #ifdef WITH_CORE
957 	,{"invalid character of OUStringBuffer()",
958                 0,
959                 new OUStringBuffer(arrOUS[3]), 0, 5},
960         {"invalid character of OUStringBuffer()",
961                 0,
962                 new OUStringBuffer(arrOUS[3]), -2, 5},
963         {"invalid character of OUStringBuffer()",
964                 0,
965                 new OUStringBuffer(arrOUS[3]), 3, 5}
966 #endif
967 
968 	};
969 
970 
971     sal_Bool res = sal_True;
972     sal_uInt32 i;
973 
974     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
975     {
976         sal_Bool lastRes =
977             ( (arrTestCase[i].input1->setCharAt(arrTestCase[i].input2,
978                 arrTestCase[i].input3)).getStr() == *(arrTestCase[i].expVal) );
979         if(i<=4)
980         {
981             c_rtl_tres_state
982             (
983                 hRtlTestResult,
984                 lastRes,
985                 arrTestCase[i].comments,
986                 createName( pMeth, "setCharAt", i )
987 
988             );
989         }
990         else
991         {
992             c_rtl_tres_state
993             (
994                 hRtlTestResult,
995                 sal_True,
996                 arrTestCase[i].comments,
997                 createName( pMeth, "setCharAt", i )
998 
999             );
1000         }
1001 	res &= lastRes;
1002     }
1003     c_rtl_tres_state_end( hRtlTestResult, "setCharAt");
1004 //    return ( res );
1005 }
1006 //------------------------------------------------------------------------
1007 // testing the method append(const OUString &str)
1008 //------------------------------------------------------------------------
1009 
test_rtl_OUStringBuffer_append_001(hTestResult hRtlTestResult)1010 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_001(
1011                                               hTestResult hRtlTestResult)
1012 {
1013     sal_Char methName[MAXBUFLENGTH];
1014     sal_Char* pMeth = methName;
1015 
1016     OUString arrOUS[5]={OUString( aUStr7 ),
1017                         OUString(),
1018                         OUString( aUStr25 ),
1019                         OUString( "\0",0,
1020 	                kEncodingRTLTextUSASCII,
1021 	                kConvertFlagsOStringToOUString),
1022                         OUString( aUStr28 )};
1023 
1024     typedef struct TestCase
1025     {
1026 	sal_Char*		comments;
1027 	OUString*               expVal;
1028         OUStringBuffer*         input1;
1029         OUString*               input2;
1030 
1031     	~TestCase()             { delete input1; delete input2; delete expVal; }
1032     } TestCase;
1033 
1034     TestCase arrTestCase[]={
1035 
1036 	{"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1037                 new OUString(aUStr1),
1038                 new OUStringBuffer(arrOUS[0]), new OUString(aUStr8) },
1039 	{"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1040                 new OUString(aUStr2),
1041                 new OUStringBuffer(arrOUS[0]), new OUString(aUStr36) },
1042         {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1043                 new OUString(aUStr37),
1044                 new OUStringBuffer(arrOUS[0]), new OUString(aUStr23) },
1045 	{"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1046                 new OUString(aUStr7),
1047                 new OUStringBuffer(arrOUS[0]), new OUString()},
1048 	{"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1049                 new OUString(aUStr7),
1050                 new OUStringBuffer(arrOUS[1]), new OUString(aUStr7)},
1051         {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1052                 new OUString(aUStr2),
1053                 new OUStringBuffer(arrOUS[1]), new OUString(aUStr2)},
1054 	{"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1055                 new OUString(aUStr1),
1056                 new OUStringBuffer(arrOUS[1]), new OUString(aUStr1) },
1057         {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1058                 new OUString(),
1059                 new OUStringBuffer(arrOUS[1]), new OUString()},
1060         {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1061                 new OUString(aUStr7),
1062                 new OUStringBuffer(arrOUS[2]), new OUString(aUStr7)},
1063         {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1064                 new OUString(aUStr2),
1065                 new OUStringBuffer(arrOUS[2]), new OUString(aUStr2)},
1066 	{"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1067                 new OUString(aUStr1),
1068                 new OUStringBuffer(arrOUS[2]), new OUString(aUStr1) },
1069         {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1070                 new OUString(),
1071                 new OUStringBuffer(arrOUS[2]), new OUString()},
1072         {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1073                 new OUString(aUStr7),
1074                 new OUStringBuffer(arrOUS[3]), new OUString(aUStr7)},
1075         {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1076                 new OUString(aUStr2),
1077                 new OUStringBuffer(arrOUS[3]), new OUString(aUStr2)},
1078 	{"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1079                 new OUString(aUStr1),
1080                 new OUStringBuffer(arrOUS[3]), new OUString(aUStr1) },
1081         {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1082                 new OUString(),
1083                 new OUStringBuffer(arrOUS[3]), new OUString()},
1084         {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1085                 new OUString(aUStr29),
1086                 new OUStringBuffer(arrOUS[4]), new OUString(aUStr38)},
1087         {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1088                 new OUString(aUStr39),
1089                 new OUStringBuffer(arrOUS[4]), new OUString(aUStr17)},
1090 	{"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1091                 new OUString(aUStr40),
1092                 new OUStringBuffer(arrOUS[4]), new OUString(aUStr31) },
1093         {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1094                 new OUString(aUStr28),
1095                 new OUStringBuffer(arrOUS[4]), new OUString()}
1096 #ifdef WITH_CORE
1097         ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1098                 new OUString(),
1099                 new OUStringBuffer(kSInt32Max), new OUString()}
1100 #endif
1101 	};
1102 
1103 
1104     sal_Bool res = sal_True;
1105     sal_uInt32 i;
1106 
1107     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1108     {
1109         arrTestCase[i].input1->append( *(arrTestCase[i].input2) );
1110         sal_Bool lastRes =
1111             ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1112               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength()  );
1113 
1114         c_rtl_tres_state
1115         (
1116             hRtlTestResult,
1117             lastRes,
1118             arrTestCase[i].comments,
1119             createName( pMeth, "append(const OUString &str)_001", i )
1120 
1121         );
1122 
1123         res &= lastRes;
1124     }
1125 
1126     return ( res );
1127 }
1128 //------------------------------------------------------------------------
1129 // testing the method append( const sal_Unicode * str )
1130 //------------------------------------------------------------------------
1131 
test_rtl_OUStringBuffer_append_002(hTestResult hRtlTestResult)1132 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_002(
1133                                               hTestResult hRtlTestResult)
1134 {
1135     sal_Char methName[MAXBUFLENGTH];
1136     sal_Char* pMeth = methName;
1137 
1138     OUString arrOUS[5]={OUString( aUStr7 ),
1139                         OUString(),
1140                         OUString( aUStr25 ),
1141                         OUString( "\0",0,
1142 	                kEncodingRTLTextUSASCII,
1143 	                kConvertFlagsOStringToOUString),
1144                         OUString( aUStr28 )};
1145 
1146     typedef struct TestCase
1147     {
1148 	sal_Char*		comments;
1149 	OUString*               expVal;
1150         OUStringBuffer*         input1;
1151         sal_Unicode*            input2;
1152 
1153     	~TestCase()             { delete input1; delete expVal; }
1154     } TestCase;
1155 
1156     TestCase arrTestCase[]={
1157 
1158 	{"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1159                 new OUString(aUStr1),
1160                 new OUStringBuffer(arrOUS[0]), aUStr8 },
1161 	{"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1162                 new OUString(aUStr2),
1163                 new OUStringBuffer(arrOUS[0]), aUStr36 },
1164         {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1165                 new OUString(aUStr37),
1166                 new OUStringBuffer(arrOUS[0]), aUStr23 },
1167 	{"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1168                 new OUString(aUStr7),
1169                 new OUStringBuffer(arrOUS[0]), aUStr25 },
1170 	{"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1171                 new OUString(aUStr7),
1172                 new OUStringBuffer(arrOUS[1]), aUStr7 },
1173         {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1174                 new OUString(aUStr2),
1175                 new OUStringBuffer(arrOUS[1]), aUStr2 },
1176 	{"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1177                 new OUString(aUStr1),
1178                 new OUStringBuffer(arrOUS[1]), aUStr1 },
1179         {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1180                 new OUString(),
1181                 new OUStringBuffer(arrOUS[1]), aUStr25 },
1182         {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1183                 new OUString(aUStr7),
1184                 new OUStringBuffer(arrOUS[2]), aUStr7 },
1185         {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1186                 new OUString(aUStr2),
1187                 new OUStringBuffer(arrOUS[2]), aUStr2 },
1188 	{"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1189                 new OUString(aUStr1),
1190                 new OUStringBuffer(arrOUS[2]), aUStr1 },
1191         {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1192                 new OUString(),
1193                 new OUStringBuffer(arrOUS[2]), aUStr25 },
1194         {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1195                 new OUString(aUStr7),
1196                 new OUStringBuffer(arrOUS[3]), aUStr7 },
1197         {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1198                 new OUString(aUStr2),
1199                 new OUStringBuffer(arrOUS[3]), aUStr2 },
1200 	{"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1201                 new OUString(aUStr1),
1202                 new OUStringBuffer(arrOUS[3]), aUStr1 },
1203         {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1204                 new OUString(),
1205                 new OUStringBuffer(arrOUS[3]), aUStr25 },
1206         {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1207                 new OUString(aUStr29),
1208                 new OUStringBuffer(arrOUS[4]), aUStr38 },
1209         {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1210                 new OUString(aUStr39),
1211                 new OUStringBuffer(arrOUS[4]), aUStr17 },
1212 	{"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1213                 new OUString(aUStr40),
1214                 new OUStringBuffer(arrOUS[4]), aUStr31 },
1215         {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1216                 new OUString(aUStr28),
1217                 new OUStringBuffer(arrOUS[4]), aUStr25 }
1218 #ifdef WITH_CORE
1219         ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1220                 new OUString(),
1221                 new OUStringBuffer(kSInt32Max), aUStr25 }
1222 #endif
1223 	};
1224 
1225 
1226     sal_Bool res = sal_True;
1227     sal_uInt32 i;
1228 
1229     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1230     {
1231         arrTestCase[i].input1->append( arrTestCase[i].input2 );
1232         sal_Bool lastRes =
1233             ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1234               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength()  );
1235 
1236         c_rtl_tres_state
1237         (
1238             hRtlTestResult,
1239             lastRes,
1240             arrTestCase[i].comments,
1241             createName( pMeth, "append( const sal_Unicode * str )_002", i )
1242 
1243         );
1244 
1245         res &= lastRes;
1246     }
1247 
1248     return ( res );
1249 }
1250 //------------------------------------------------------------------------
1251 // testing the method append( const sal_Unicode * str, sal_Int32 len)
1252 //------------------------------------------------------------------------
1253 
test_rtl_OUStringBuffer_append_003(hTestResult hRtlTestResult)1254 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_003(
1255                                               hTestResult hRtlTestResult)
1256 {
1257     sal_Char methName[MAXBUFLENGTH];
1258     sal_Char* pMeth = methName;
1259 
1260     OUString arrOUS[5]={OUString( aUStr7 ),
1261                         OUString(),
1262                         OUString( aUStr25 ),
1263                         OUString( "\0",0,
1264 	                kEncodingRTLTextUSASCII,
1265 	                kConvertFlagsOStringToOUString),
1266                         OUString( aUStr28 )};
1267 
1268     typedef struct TestCase
1269     {
1270 	sal_Char*		comments;
1271 	OUString*               expVal;
1272         OUStringBuffer*         input1;
1273         sal_Unicode*            input2;
1274         sal_Int32               input3;
1275 
1276     	~TestCase()             { delete input1; delete expVal; }
1277     } TestCase;
1278 
1279     TestCase arrTestCase[]={
1280 
1281 	{"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1282                 new OUString(aUStr1),
1283                 new OUStringBuffer(arrOUS[0]), aUStr36, 12 },
1284 	{"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1285                 new OUString(aUStr2),
1286                 new OUStringBuffer(arrOUS[0]), aUStr36, 28 },
1287         {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1288                 new OUString(aUStr37),
1289                 new OUStringBuffer(arrOUS[0]), aUStr23, 16 },
1290 	{"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1291                 new OUString(aUStr7),
1292                 new OUStringBuffer(arrOUS[0]), aUStr2, 0 },
1293     /* LLA: input3 must null < 0
1294         {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1295                 new OUString(aUStr41),
1296                 new OUStringBuffer(arrOUS[0]), aUStr2, -1 },
1297     */
1298 	{"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1299                 new OUString(aUStr7),
1300                 new OUStringBuffer(arrOUS[1]), aUStr2, 4 },
1301         {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1302                 new OUString(aUStr2),
1303                 new OUStringBuffer(arrOUS[1]), aUStr2, 32 },
1304 	{"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1305                 new OUString(aUStr1),
1306                 new OUStringBuffer(arrOUS[1]), aUStr2, 16 },
1307         {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1308                 new OUString(),
1309                 new OUStringBuffer(arrOUS[1]), aUStr2, 0 },
1310     /* LLA: input3 must null < 0
1311         {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1312                 new OUString(),
1313                 new OUStringBuffer(arrOUS[1]), aUStr2, -1 },
1314     */
1315         {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1316                 new OUString(aUStr7),
1317                 new OUStringBuffer(arrOUS[2]), aUStr2, 4 },
1318         {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1319                 new OUString(aUStr2),
1320                 new OUStringBuffer(arrOUS[2]), aUStr2, 32 },
1321 	{"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1322                 new OUString(aUStr1),
1323                 new OUStringBuffer(arrOUS[2]), aUStr2, 16 },
1324         {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1325                 new OUString(),
1326                 new OUStringBuffer(arrOUS[2]), aUStr2, 0 },
1327     /* LLA: input3 must null < 0
1328         {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1329                 new OUString(),
1330                 new OUStringBuffer(arrOUS[2]), aUStr2, -1 },
1331     */
1332         {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1333                 new OUString(aUStr7),
1334                 new OUStringBuffer(arrOUS[3]), aUStr2, 4 },
1335         {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1336                 new OUString(aUStr2),
1337                 new OUStringBuffer(arrOUS[3]), aUStr2, 32 },
1338 	{"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1339                 new OUString(aUStr1),
1340                 new OUStringBuffer(arrOUS[3]), aUStr2, 16 },
1341         {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1342                 new OUString(),
1343                 new OUStringBuffer(arrOUS[3]), aUStr2, 0 },
1344     /* LLA: input3 must null < 0
1345         {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1346                 new OUString(),
1347                 new OUStringBuffer(arrOUS[3]), aUStr2, -1 },
1348     */
1349         {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1350                 new OUString(aUStr29),
1351                 new OUStringBuffer(arrOUS[4]), aUStr38, 7 },
1352         {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1353                 new OUString(aUStr39),
1354                 new OUStringBuffer(arrOUS[4]), aUStr17, 22 },
1355 	{"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1356                 new OUString(aUStr40),
1357                 new OUStringBuffer(arrOUS[4]), aUStr31, 16 },
1358         {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1359                 new OUString(aUStr28),
1360                 new OUStringBuffer(arrOUS[4]), aUStr2, 0 },
1361     /* LLA: input3 must null < 0
1362       {"Appends the string(length less than 0) to the string buffer arrOUS[4]",
1363                 new OUString(aUStr42),
1364                 new OUStringBuffer(arrOUS[4]), aUStr2, -1 }
1365     */
1366 #ifdef WITH_CORE
1367         ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1368                 new OUString(),
1369                 new OUStringBuffer(kSInt32Max), aUStr25 }
1370 #endif
1371 	};
1372 
1373 
1374     sal_Bool res = sal_True;
1375     sal_uInt32 i;
1376 
1377     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1378     {
1379         arrTestCase[i].input1->append(
1380                     arrTestCase[i].input2, arrTestCase[i].input3);
1381         sal_Bool lastRes =
1382             ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1383               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength()  );
1384 
1385         c_rtl_tres_state
1386         (
1387             hRtlTestResult,
1388             lastRes,
1389             arrTestCase[i].comments,
1390             createName( pMeth, "append( const sal_Unicode * str, sal_Int32 len)_003", i )
1391 
1392         );
1393 
1394         res &= lastRes;
1395     }
1396 
1397     return ( res );
1398 }
1399 //------------------------------------------------------------------------
1400 // testing the method append(sal_Bool b)
1401 //------------------------------------------------------------------------
1402 
test_rtl_OUStringBuffer_append_004(hTestResult hRtlTestResult)1403 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_004(
1404                                               hTestResult hRtlTestResult)
1405 {
1406     sal_Char methName[MAXBUFLENGTH];
1407     sal_Char* pMeth = methName;
1408 
1409     OUString arrOUS[5]={OUString( aUStr7 ),
1410                         OUString(),
1411                         OUString( aUStr25 ),
1412                         OUString( "\0",0,
1413 	                kEncodingRTLTextUSASCII,
1414 	                kConvertFlagsOStringToOUString),
1415                         OUString( aUStr28 )};
1416 
1417     typedef struct TestCase
1418     {
1419 	sal_Char*		comments;
1420 	OUString*               expVal;
1421         OUStringBuffer*         input1;
1422         sal_Bool                input2;
1423 
1424     	~TestCase()             { delete input1; delete expVal; }
1425     } TestCase;
1426 
1427     TestCase arrTestCase[]={
1428 
1429 	{"Appends the sal_Bool(sal_True) to the string buffer arrOUS[0]",
1430                 new OUString(aUStr45),
1431                 new OUStringBuffer(arrOUS[0]), sal_True },
1432 	{"Appends the sal_Bool(sal_False) to the string buffer arrOUS[0]",
1433                 new OUString(aUStr46),
1434                 new OUStringBuffer(arrOUS[0]), sal_False },
1435 	{"Appends the sal_Bool(sal_True) to the string buffer arrOUS[1]",
1436                 new OUString(aUStr47),
1437                 new OUStringBuffer(arrOUS[1]), sal_True },
1438         {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[1]",
1439                 new OUString(aUStr48),
1440                 new OUStringBuffer(arrOUS[1]), sal_False },
1441         {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[2]",
1442                 new OUString(aUStr47),
1443                 new OUStringBuffer(arrOUS[2]), sal_True },
1444         {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[2]",
1445                 new OUString(aUStr48),
1446                 new OUStringBuffer(arrOUS[2]), sal_False },
1447         {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[3]",
1448                 new OUString(aUStr47),
1449                 new OUStringBuffer(arrOUS[3]), sal_True },
1450         {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[3]",
1451                 new OUString(aUStr48),
1452                 new OUStringBuffer(arrOUS[3]), sal_False },
1453         {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[4]",
1454                 new OUString(aUStr49),
1455                 new OUStringBuffer(arrOUS[4]), sal_True },
1456         {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[4]",
1457                 new OUString(aUStr50),
1458                 new OUStringBuffer(arrOUS[4]), sal_False }
1459 #ifdef WITH_CORE
1460         ,{"Appends the sal_Bool(sal_True) to the string buffer(with INT_MAX) ",
1461                 new OUString(aUStr47),
1462                 new OUStringBuffer(kSInt32Max), sal_True },
1463         {"Appends the sal_Bool(sal_False) to the string buffer(with INT_MAX) ",
1464                 new OUString(aUStr48),
1465                 new OUStringBuffer(kSInt32Max), sal_False }
1466 #endif
1467 	};
1468 
1469 
1470     sal_Bool res = sal_True;
1471     sal_uInt32 i;
1472 
1473     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1474     {
1475         arrTestCase[i].input1->append(
1476                     arrTestCase[i].input2 );
1477         sal_Bool lastRes =
1478             ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1479               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength()  );
1480 
1481         c_rtl_tres_state
1482         (
1483             hRtlTestResult,
1484             lastRes,
1485             arrTestCase[i].comments,
1486             createName( pMeth, "append( sal_Bool b)_004", i )
1487 
1488         );
1489 
1490         res &= lastRes;
1491     }
1492 
1493     return ( res );
1494 }
1495 
test_rtl_OUStringBuffer_appends(hTestResult hRtlTestResult)1496 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appends(
1497 	                                          hTestResult hRtlTestResult )
1498 {
1499     c_rtl_tres_state_start( hRtlTestResult, "appends");
1500     sal_Bool bTSState = test_rtl_OUStringBuffer_append_001( hRtlTestResult );
1501     bTSState &= test_rtl_OUStringBuffer_append_002( hRtlTestResult);
1502     bTSState &= test_rtl_OUStringBuffer_append_003( hRtlTestResult);
1503     bTSState &= test_rtl_OUStringBuffer_append_004( hRtlTestResult);
1504 
1505     c_rtl_tres_state_end( hRtlTestResult, "appends");
1506 //    return( bTSState );
1507 }
1508 //------------------------------------------------------------------------
1509 // testing the method appendAscii( const sal_Char * str )
1510 //------------------------------------------------------------------------
1511 
test_rtl_OUStringBuffer_appendAscii_001(hTestResult hRtlTestResult)1512 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_001(
1513                                               hTestResult hRtlTestResult)
1514 {
1515     sal_Char methName[MAXBUFLENGTH];
1516     sal_Char* pMeth = methName;
1517 
1518     OUString arrOUS[5]={OUString( aUStr7 ),
1519                         OUString(),
1520                         OUString( aUStr25 ),
1521                         OUString( "\0",0,
1522 	                kEncodingRTLTextUSASCII,
1523 	                kConvertFlagsOStringToOUString),
1524                         OUString( aUStr28 )};
1525 
1526     typedef struct TestCase
1527     {
1528 	sal_Char*		comments;
1529 	OUString*               expVal;
1530         OUStringBuffer*         input1;
1531         const sal_Char*         input2;
1532 
1533     	~TestCase()             { delete input1; delete expVal; }
1534     } TestCase;
1535 
1536     TestCase arrTestCase[]={
1537 
1538         {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1539                 new OUString(aUStr1),
1540                 new OUStringBuffer(arrOUS[0]), kTestStr8 },
1541 	{"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1542                 new OUString(aUStr2),
1543                 new OUStringBuffer(arrOUS[0]), kTestStr36 },
1544         {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1545                 new OUString(aUStr37),
1546                 new OUStringBuffer(arrOUS[0]), kTestStr23 },
1547 	{"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1548                 new OUString(aUStr7),
1549                 new OUStringBuffer(arrOUS[0]), kTestStr25 },
1550 	{"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1551                 new OUString(aUStr7),
1552                 new OUStringBuffer(arrOUS[1]), kTestStr7 },
1553         {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1554                 new OUString(aUStr2),
1555                 new OUStringBuffer(arrOUS[1]), kTestStr2 },
1556 	{"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1557                 new OUString(aUStr1),
1558                 new OUStringBuffer(arrOUS[1]), kTestStr1 },
1559         {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1560                 new OUString(),
1561                 new OUStringBuffer(arrOUS[1]), kTestStr25 },
1562         {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1563                 new OUString(aUStr7),
1564                 new OUStringBuffer(arrOUS[2]), kTestStr7 },
1565         {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1566                 new OUString(aUStr2),
1567                 new OUStringBuffer(arrOUS[2]), kTestStr2 },
1568 	{"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1569                 new OUString(aUStr1),
1570                 new OUStringBuffer(arrOUS[2]), kTestStr1 },
1571         {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1572                 new OUString(),
1573                 new OUStringBuffer(arrOUS[2]), kTestStr25 },
1574         {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1575                 new OUString(aUStr7),
1576                 new OUStringBuffer(arrOUS[3]), kTestStr7 },
1577         {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1578                 new OUString(aUStr2),
1579                 new OUStringBuffer(arrOUS[3]), kTestStr2 },
1580 	{"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1581                 new OUString(aUStr1),
1582                 new OUStringBuffer(arrOUS[3]), kTestStr1 },
1583         {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1584                 new OUString(),
1585                 new OUStringBuffer(arrOUS[3]), kTestStr25 },
1586         {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1587                 new OUString(aUStr29),
1588                 new OUStringBuffer(arrOUS[4]), kTestStr38 },
1589         {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1590                 new OUString(aUStr39),
1591                 new OUStringBuffer(arrOUS[4]), kTestStr17 },
1592 	{"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1593                 new OUString(aUStr40),
1594                 new OUStringBuffer(arrOUS[4]), kTestStr31 },
1595         {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1596                 new OUString(aUStr28),
1597                 new OUStringBuffer(arrOUS[4]), kTestStr25 }
1598         /*{"Appends the string(with special characters) to the string buffer arrOUS[4]",
1599                 new OUString(aUStr43),
1600                 new OUStringBuffer(arrOUS[4]), kTestStr44 }*/
1601 #ifdef WITH_CORE
1602         ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1603                 new OUString(),
1604                 new OUStringBuffer(kSInt32Max), kTestStr25 }
1605 #endif
1606 
1607 	};
1608 
1609 
1610     sal_Bool res = sal_True;
1611     sal_uInt32 i;
1612 
1613     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1614     {
1615         arrTestCase[i].input1->appendAscii( arrTestCase[i].input2 );
1616         sal_Bool lastRes =
1617             ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1618               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength()  );
1619 
1620             c_rtl_tres_state
1621             (
1622                 hRtlTestResult,
1623                 lastRes,
1624                 arrTestCase[i].comments,
1625                 createName( pMeth, "appendAscii_001", i )
1626             );
1627 
1628         res &= lastRes;
1629     }
1630     return ( res );
1631 }
1632 //------------------------------------------------------------------------
1633 // testing the method appendAscii( const sal_Char * str, sal_Int32 len)
1634 //------------------------------------------------------------------------
1635 
test_rtl_OUStringBuffer_appendAscii_002(hTestResult hRtlTestResult)1636 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_002(
1637                                               hTestResult hRtlTestResult)
1638 {
1639     sal_Char methName[MAXBUFLENGTH];
1640     sal_Char* pMeth = methName;
1641 
1642     OUString arrOUS[5]={OUString( aUStr7 ),
1643                         OUString(),
1644                         OUString( aUStr25 ),
1645                         OUString( "\0",0,
1646 	                kEncodingRTLTextUSASCII,
1647 	                kConvertFlagsOStringToOUString),
1648                         OUString( aUStr28 )};
1649 
1650     typedef struct TestCase
1651     {
1652 	sal_Char*		comments;
1653 	OUString*               expVal;
1654         OUStringBuffer*         input1;
1655         const sal_Char*         input2;
1656         sal_Int32               input3;
1657 
1658     	~TestCase()             { delete input1; delete expVal; }
1659     } TestCase;
1660 
1661     TestCase arrTestCase[]={
1662 
1663 	{"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1664                 new OUString(aUStr1),
1665                 new OUStringBuffer(arrOUS[0]), kTestStr36, 12 },
1666 	{"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1667                 new OUString(aUStr2),
1668                 new OUStringBuffer(arrOUS[0]), kTestStr36, 28 },
1669         {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1670                 new OUString(aUStr37),
1671                 new OUStringBuffer(arrOUS[0]), kTestStr23, 16 },
1672 	{"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1673                 new OUString(aUStr7),
1674                 new OUStringBuffer(arrOUS[0]), kTestStr2, 0 },
1675     /* LLA: input3 must null < 0
1676         {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1677                 new OUString(aUStr41),
1678                 new OUStringBuffer(arrOUS[0]), kTestStr2, -1 },
1679     */
1680 	{"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1681                 new OUString(aUStr7),
1682                 new OUStringBuffer(arrOUS[1]), kTestStr2, 4 },
1683         {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1684                 new OUString(aUStr2),
1685                 new OUStringBuffer(arrOUS[1]), kTestStr2, 32 },
1686 	{"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1687                 new OUString(aUStr1),
1688                 new OUStringBuffer(arrOUS[1]), kTestStr2, 16 },
1689         {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1690                 new OUString(),
1691                 new OUStringBuffer(arrOUS[1]), kTestStr2, 0 },
1692     /* LLA: input3 must null < 0
1693         {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1694                 new OUString(),
1695                 new OUStringBuffer(arrOUS[1]), kTestStr2, -1 },
1696     */
1697         {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1698                 new OUString(aUStr7),
1699                 new OUStringBuffer(arrOUS[2]), kTestStr2, 4 },
1700         {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1701                 new OUString(aUStr2),
1702                 new OUStringBuffer(arrOUS[2]), kTestStr2, 32 },
1703 	{"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1704                 new OUString(aUStr1),
1705                 new OUStringBuffer(arrOUS[2]), kTestStr2, 16 },
1706         {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1707                 new OUString(),
1708                 new OUStringBuffer(arrOUS[2]), kTestStr2, 0 },
1709     /* LLA: input3 must null < 0
1710        {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1711                 new OUString(),
1712                 new OUStringBuffer(arrOUS[2]), kTestStr2, -1 },
1713     */
1714         {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1715                 new OUString(aUStr7),
1716                 new OUStringBuffer(arrOUS[3]), kTestStr2, 4 },
1717         {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1718                 new OUString(aUStr2),
1719                 new OUStringBuffer(arrOUS[3]), kTestStr2, 32 },
1720 	{"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1721                 new OUString(aUStr1),
1722                 new OUStringBuffer(arrOUS[3]), kTestStr2, 16 },
1723         {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1724                 new OUString(),
1725                 new OUStringBuffer(arrOUS[3]), kTestStr2, 0 },
1726     /* LLA: input3 must null < 0
1727         {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1728                 new OUString(),
1729                 new OUStringBuffer(arrOUS[3]), kTestStr2, -1 },
1730     */
1731         {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1732                 new OUString(aUStr29),
1733                 new OUStringBuffer(arrOUS[4]), kTestStr38, 7 },
1734         {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1735                 new OUString(aUStr39),
1736                 new OUStringBuffer(arrOUS[4]), kTestStr17, 22 },
1737 	{"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1738                 new OUString(aUStr40),
1739                 new OUStringBuffer(arrOUS[4]), kTestStr31, 16 },
1740         {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1741                 new OUString(aUStr28),
1742                 new OUStringBuffer(arrOUS[4]), kTestStr2, 0 },
1743     /* LLA: input3 must null < 0
1744         {"Appends the string(length less than 0) to the string buffer arrOUS[4]",
1745                 new OUString(aUStr42),
1746                 new OUStringBuffer(arrOUS[4]), kTestStr2, -1 }
1747     */
1748 #ifdef WITH_CORE
1749         ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ",
1750                 new OUString(),
1751                 new OUStringBuffer(kSInt32Max), kTestStr25 }
1752 #endif
1753 	};
1754 
1755 
1756     sal_Bool res = sal_True;
1757     sal_uInt32 i;
1758 
1759     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1760     {
1761         arrTestCase[i].input1->appendAscii(
1762                     arrTestCase[i].input2, arrTestCase[i].input3);
1763         sal_Bool lastRes =
1764             ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1765               arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength()  );
1766 
1767         c_rtl_tres_state
1768         (
1769             hRtlTestResult,
1770             lastRes,
1771             arrTestCase[i].comments,
1772             createName( pMeth, "appendAscii_002", i )
1773 
1774         );
1775 
1776         res &= lastRes;
1777     }
1778     return ( res );
1779 }
test_rtl_OUStringBuffer_appendAsciis(hTestResult hRtlTestResult)1780 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appendAsciis(
1781 	                                          hTestResult hRtlTestResult )
1782 {
1783     c_rtl_tres_state_start( hRtlTestResult, "appendAsciis");
1784     sal_Bool bTSState = test_rtl_OUStringBuffer_appendAscii_001( hRtlTestResult );
1785     bTSState &= test_rtl_OUStringBuffer_appendAscii_002( hRtlTestResult);
1786 
1787     c_rtl_tres_state_end( hRtlTestResult, "appendAsciis");
1788 //    return( bTSState );
1789 }
1790 // -----------------------------------------------------------------------------
test_rtl_OUStringBuffer(hTestResult hRtlTestResult)1791 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer( hTestResult hRtlTestResult )
1792 {
1793 
1794     c_rtl_tres_state_start(hRtlTestResult, "rtl_OUStringBuffer" );
1795 
1796     test_rtl_OUStringBuffer_ctors( hRtlTestResult );
1797     test_rtl_OUStringBuffer_makeStringAndClear( hRtlTestResult );
1798     test_rtl_OUStringBuffer_getLength( hRtlTestResult );
1799     test_rtl_OUStringBuffer_getCapacity( hRtlTestResult );
1800     test_rtl_OUStringBuffer_ensureCapacity( hRtlTestResult );
1801     test_rtl_OUStringBuffer_setLength( hRtlTestResult );
1802     test_rtl_OUStringBuffer_charAt( hRtlTestResult );
1803     test_rtl_OUStringBuffer_csuc( hRtlTestResult );
1804     test_rtl_OUStringBuffer_getStr( hRtlTestResult );
1805     test_rtl_OUStringBuffer_setCharAt( hRtlTestResult );
1806     test_rtl_OUStringBuffer_appends( hRtlTestResult );
1807     test_rtl_OUStringBuffer_appendAsciis( hRtlTestResult );
1808 
1809     c_rtl_tres_state_end(hRtlTestResult, "rtl_OUStringBuffer");
1810 }
1811 
1812 // -----------------------------------------------------------------------------
RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)1813 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
1814 {
1815     if (_pFunc)
1816     {
1817         (_pFunc)(&test_rtl_OUStringBuffer, "");
1818     }
1819 }
1820