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