xref: /AOO41X/main/sal/qa/rtl_strings/rtl_OString.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 #include <string.h>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _SAL_TYPES_H_
33*cdf0e10cSrcweir     #include <sal/types.h>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir // #ifndef _RTL_TRES_H_
37*cdf0e10cSrcweir //     #include <rtl/tres.h>
38*cdf0e10cSrcweir // #endif
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <testshl/tresstatewrapper.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #ifndef _RTL_STRING_HXX_
43*cdf0e10cSrcweir     #include <rtl/string.hxx>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #ifndef _RTL_STRING_CONST_H_
47*cdf0e10cSrcweir     #include <rtl_String_Const.h>
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #ifndef _RTL_STRING_UTILS_HXX_
51*cdf0e10cSrcweir     #include <rtl_String_Utils.hxx>
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir #include <rtl/ustring.h>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace rtl;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir //------------------------------------------------------------------------
58*cdf0e10cSrcweir // test classes
59*cdf0e10cSrcweir //------------------------------------------------------------------------
60*cdf0e10cSrcweir const int MAXBUFLENGTH = 255;
61*cdf0e10cSrcweir //------------------------------------------------------------------------
62*cdf0e10cSrcweir // helper functions
63*cdf0e10cSrcweir //------------------------------------------------------------------------
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir static void unused()
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir     test_ini_uString();
68*cdf0e10cSrcweir     (void)inputChar;
69*cdf0e10cSrcweir     (void)input1StrDefault;
70*cdf0e10cSrcweir     (void)input1StrNormal;
71*cdf0e10cSrcweir     (void)input1StrLastDefault;
72*cdf0e10cSrcweir     (void)input1StrLastNormal;
73*cdf0e10cSrcweir     unused();
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir //------------------------------------------------------------------------
77*cdf0e10cSrcweir // testing constructors
78*cdf0e10cSrcweir //------------------------------------------------------------------------
79*cdf0e10cSrcweir static sal_Bool test_rtl_OString_ctor_001( hTestResult hRtlTestResult )
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir     ::rtl::OString aStr;
82*cdf0e10cSrcweir     rtl_String* pData = aStr.pData;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     return
86*cdf0e10cSrcweir     (
87*cdf0e10cSrcweir         c_rtl_tres_state
88*cdf0e10cSrcweir         (
89*cdf0e10cSrcweir             hRtlTestResult,
90*cdf0e10cSrcweir             pData->length == 0 &&
91*cdf0e10cSrcweir             ! *pData->buffer,
92*cdf0e10cSrcweir             "New OString containing no characters",
93*cdf0e10cSrcweir             "ctor_001"
94*cdf0e10cSrcweir         )
95*cdf0e10cSrcweir     );
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir //------------------------------------------------------------------------
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_ctor_002(
101*cdf0e10cSrcweir                                          hTestResult hRtlTestResult )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir     ::rtl::OString aStr(kTestStr1);
104*cdf0e10cSrcweir     rtl_String* pData = aStr.pData;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     return
107*cdf0e10cSrcweir     (
108*cdf0e10cSrcweir         c_rtl_tres_state
109*cdf0e10cSrcweir         (
110*cdf0e10cSrcweir             hRtlTestResult,
111*cdf0e10cSrcweir             pData->refCount == 1 &&
112*cdf0e10cSrcweir             pData->length == kTestStr1Len &&
113*cdf0e10cSrcweir             cmpstr( (const sal_Char*)pData->buffer, kTestStr1, kTestStr1Len ),
114*cdf0e10cSrcweir             "New OString from a character buffer array",
115*cdf0e10cSrcweir             "ctor_002"
116*cdf0e10cSrcweir         )
117*cdf0e10cSrcweir     );
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir //------------------------------------------------------------------------
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_ctor_003(
122*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult  )
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir     ::rtl::OString aStr(kTestStr2, kTestStr1Len);
125*cdf0e10cSrcweir     rtl_String* pData = aStr.pData;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     return
128*cdf0e10cSrcweir     (
129*cdf0e10cSrcweir        c_rtl_tres_state
130*cdf0e10cSrcweir         (
131*cdf0e10cSrcweir             hRtlTestResult,
132*cdf0e10cSrcweir             pData->refCount == 1 &&
133*cdf0e10cSrcweir             pData->length == kTestStr1Len &&
134*cdf0e10cSrcweir             cmpstr( (const sal_Char*)pData->buffer, kTestStr2, kTestStr1Len ),
135*cdf0e10cSrcweir             "New OString from the first n chars of ascii string",
136*cdf0e10cSrcweir             "ctor_003"
137*cdf0e10cSrcweir         )
138*cdf0e10cSrcweir     );
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir //------------------------------------------------------------------------
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_ctor_004(
144*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult)
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     ::rtl::OString aStr1(kTestStr1);
147*cdf0e10cSrcweir     ::rtl::OString aStr2(aStr1);
148*cdf0e10cSrcweir     rtl_String* pData1 = aStr1.pData;
149*cdf0e10cSrcweir     rtl_String* pData2 = aStr2.pData;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     return
152*cdf0e10cSrcweir     (
153*cdf0e10cSrcweir         c_rtl_tres_state
154*cdf0e10cSrcweir         (
155*cdf0e10cSrcweir             hRtlTestResult,
156*cdf0e10cSrcweir             pData1->refCount == pData2->refCount &&
157*cdf0e10cSrcweir             pData1->length == kTestStr1Len &&
158*cdf0e10cSrcweir             pData1->buffer == pData2->buffer,
159*cdf0e10cSrcweir             "New OString from an OString",
160*cdf0e10cSrcweir             "ctor_004"
161*cdf0e10cSrcweir         )
162*cdf0e10cSrcweir     );
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir //------------------------------------------------------------------------
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir static sal_Bool test_rtl_OString_ctor_005( hTestResult hRtlTestResult )
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir     rtl_String *aStr1 = NULL;
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     rtl_string_newFromStr( &aStr1, kTestStr1 );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     if ( aStr1 != NULL )
173*cdf0e10cSrcweir     {
174*cdf0e10cSrcweir         ::rtl::OString aStr2(aStr1);
175*cdf0e10cSrcweir         rtl_String* pData2 = aStr2.pData;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir         sal_Bool bOK =  c_rtl_tres_state
178*cdf0e10cSrcweir                         (
179*cdf0e10cSrcweir                             hRtlTestResult,
180*cdf0e10cSrcweir                             aStr1->refCount == pData2->refCount &&
181*cdf0e10cSrcweir                             pData2->length == kTestStr1Len &&
182*cdf0e10cSrcweir                             aStr1->buffer == pData2->buffer,
183*cdf0e10cSrcweir                             "new OString from a RTL String",
184*cdf0e10cSrcweir                             "ctor_005"
185*cdf0e10cSrcweir                         );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         rtl_string_release( aStr1 );
188*cdf0e10cSrcweir         aStr1 = NULL;
189*cdf0e10cSrcweir         return ( bOK );
190*cdf0e10cSrcweir     }
191*cdf0e10cSrcweir     return
192*cdf0e10cSrcweir     (
193*cdf0e10cSrcweir         c_rtl_tres_state
194*cdf0e10cSrcweir         (
195*cdf0e10cSrcweir             hRtlTestResult,
196*cdf0e10cSrcweir             sal_False,
197*cdf0e10cSrcweir             "copying an ascii string to a RTL String!",
198*cdf0e10cSrcweir             "ctor_005"
199*cdf0e10cSrcweir         )
200*cdf0e10cSrcweir     );
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir //------------------------------------------------------------------------
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir static sal_Bool test_rtl_OString_ctor_006( hTestResult hRtlTestResult )
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     sal_Unicode aStr1[kTestStr1Len+1];
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     if ( AStringToUStringNCopy( aStr1, kTestStr1, kTestStr1Len ) )
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir         if ( AStringToUStringNCompare( aStr1, kTestStr1, kTestStr1Len ) == 0 )
213*cdf0e10cSrcweir         {
214*cdf0e10cSrcweir             // const sal_Char  *kTCMessage[2] = { "", "array." };
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir             ::rtl::OString aStr2
217*cdf0e10cSrcweir             (
218*cdf0e10cSrcweir                 aStr1,
219*cdf0e10cSrcweir                 kTestStr1Len,
220*cdf0e10cSrcweir                 kEncodingRTLTextUSASCII,
221*cdf0e10cSrcweir                 kConvertFlagsOUStringToOString
222*cdf0e10cSrcweir             );
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir             return
225*cdf0e10cSrcweir             (
226*cdf0e10cSrcweir                 c_rtl_tres_state
227*cdf0e10cSrcweir                 (
228*cdf0e10cSrcweir                     hRtlTestResult,
229*cdf0e10cSrcweir                     aStr2 == kTestStr1,
230*cdf0e10cSrcweir                     "new OString from a unicode character buffer",
231*cdf0e10cSrcweir                     "ctor_006"
232*cdf0e10cSrcweir                 )
233*cdf0e10cSrcweir             );
234*cdf0e10cSrcweir         } /// end if AStringToUStringNCompare
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir         return
237*cdf0e10cSrcweir         (
238*cdf0e10cSrcweir              c_rtl_tres_state
239*cdf0e10cSrcweir             (
240*cdf0e10cSrcweir                 hRtlTestResult,
241*cdf0e10cSrcweir                 sal_False,
242*cdf0e10cSrcweir                 "compare ascii string with unicode string!",
243*cdf0e10cSrcweir                 "ctor_006"
244*cdf0e10cSrcweir             )
245*cdf0e10cSrcweir         );
246*cdf0e10cSrcweir     } /// end if AStringToUStringNCopy
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     return
249*cdf0e10cSrcweir     (
250*cdf0e10cSrcweir         c_rtl_tres_state
251*cdf0e10cSrcweir         (
252*cdf0e10cSrcweir             hRtlTestResult,
253*cdf0e10cSrcweir             sal_False,
254*cdf0e10cSrcweir             "copy ascii string to unicode string!",
255*cdf0e10cSrcweir             "ctor_006"
256*cdf0e10cSrcweir         )
257*cdf0e10cSrcweir     );
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_ctors(
260*cdf0e10cSrcweir 					hTestResult hRtlTestResult )
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "ctor");
264*cdf0e10cSrcweir     sal_Bool bTSState = test_rtl_OString_ctor_001( hRtlTestResult );
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir     bTSState &= test_rtl_OString_ctor_002( hRtlTestResult);
267*cdf0e10cSrcweir     bTSState &= test_rtl_OString_ctor_003( hRtlTestResult);
268*cdf0e10cSrcweir     bTSState &= test_rtl_OString_ctor_004( hRtlTestResult);
269*cdf0e10cSrcweir     bTSState &= test_rtl_OString_ctor_005( hRtlTestResult);
270*cdf0e10cSrcweir     bTSState &= test_rtl_OString_ctor_006( hRtlTestResult);
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "ctor");
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir //    return( bTSState );
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir //------------------------------------------------------------------------
280*cdf0e10cSrcweir // testing the method getLength
281*cdf0e10cSrcweir //------------------------------------------------------------------------
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_getLength(
284*cdf0e10cSrcweir                                       hTestResult hRtlTestResult)
285*cdf0e10cSrcweir {
286*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
287*cdf0e10cSrcweir     sal_Char* pMeth = methName;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "getLength");
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir typedef struct TestCase
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     sal_Char*                    comments;
294*cdf0e10cSrcweir     sal_Int32                    expVal;
295*cdf0e10cSrcweir     OString*                     input;
296*cdf0e10cSrcweir     ~TestCase() { delete input;}
297*cdf0e10cSrcweir } TestCase;
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir TestCase arrTestCase[]={
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     {"length of ascii string", kTestStr1Len, new OString(kTestStr1)},
302*cdf0e10cSrcweir     {"length of ascci string of size 1", 1, new OString("1")},
303*cdf0e10cSrcweir     {"length of empty string (default constructor)", 0, new OString()},
304*cdf0e10cSrcweir     {"length of empty string (empty ascii string arg)",0,new OString("")},
305*cdf0e10cSrcweir     {"length of empty string (string arg = '\\0')",0,new OString("\0")}
306*cdf0e10cSrcweir     };
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir     sal_Bool res = sal_True;
310*cdf0e10cSrcweir     sal_uInt32 i;
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
313*cdf0e10cSrcweir     {
314*cdf0e10cSrcweir         sal_Int32 length = arrTestCase[i].input->getLength();
315*cdf0e10cSrcweir         sal_Bool lastRes = (length == arrTestCase[i].expVal);
316*cdf0e10cSrcweir         c_rtl_tres_state
317*cdf0e10cSrcweir         (
318*cdf0e10cSrcweir             hRtlTestResult,
319*cdf0e10cSrcweir             lastRes,
320*cdf0e10cSrcweir             arrTestCase[i].comments,
321*cdf0e10cSrcweir             createName( pMeth, "getLength", i )
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir         );
324*cdf0e10cSrcweir         res &= lastRes;
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "getLength");
327*cdf0e10cSrcweir //    return ( res );
328*cdf0e10cSrcweir }
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir //------------------------------------------------------------------------
333*cdf0e10cSrcweir // testing the method equals( const OString & aStr )
334*cdf0e10cSrcweir //------------------------------------------------------------------------
335*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_equals(
336*cdf0e10cSrcweir                                              hTestResult hRtlTestResult )
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
339*cdf0e10cSrcweir     sal_Char* pMeth = methName;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "equals");
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir     typedef struct TestCase
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir     sal_Char*                    comments;
346*cdf0e10cSrcweir     sal_Bool                     expVal;
347*cdf0e10cSrcweir     OString*                     input1;
348*cdf0e10cSrcweir     OString*                     input2;
349*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
350*cdf0e10cSrcweir } TestCase;
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir TestCase arrTestCase[]={
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir     {"same size", sal_True, new OString(kTestStr1),new OString(kTestStr1)},
355*cdf0e10cSrcweir     {"different size", sal_False, new OString(kTestStr1),
356*cdf0e10cSrcweir         new OString(kTestStr2)},
357*cdf0e10cSrcweir     {"same size, no case match", sal_False, new OString(kTestStr1),
358*cdf0e10cSrcweir         new OString(kTestStr3)},
359*cdf0e10cSrcweir     {"two empty strings(def. constructor)", sal_True, new OString(),
360*cdf0e10cSrcweir         new OString()},
361*cdf0e10cSrcweir     {"empty(def.constructor) and non empty", sal_False, new OString(),
362*cdf0e10cSrcweir         new OString(kTestStr2)},
363*cdf0e10cSrcweir     {"non empty and empty(def. constructor)", sal_False,
364*cdf0e10cSrcweir         new OString(kTestStr1),new OString()},
365*cdf0e10cSrcweir     {"two empty strings(string arg = '\\0')", sal_True,
366*cdf0e10cSrcweir         new OString(""),new OString("")},
367*cdf0e10cSrcweir     {"empty(string arg = '\\0') and non empty", sal_False,
368*cdf0e10cSrcweir         new OString(""),new OString(kTestStr2)},
369*cdf0e10cSrcweir     {"non empty and empty(string arg = '\\0')", sal_False,
370*cdf0e10cSrcweir         new OString(kTestStr1),new OString("")}
371*cdf0e10cSrcweir     };
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir     sal_Bool res = sal_True;
374*cdf0e10cSrcweir     sal_uInt32 i;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
377*cdf0e10cSrcweir     {
378*cdf0e10cSrcweir         sal_Bool lastRes =
379*cdf0e10cSrcweir                  ( arrTestCase[i].input1->equals(*(arrTestCase[i].input2)) ==
380*cdf0e10cSrcweir                     arrTestCase[i].expVal );
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir           c_rtl_tres_state
383*cdf0e10cSrcweir         (
384*cdf0e10cSrcweir               hRtlTestResult,
385*cdf0e10cSrcweir             lastRes,
386*cdf0e10cSrcweir             arrTestCase[i].comments,
387*cdf0e10cSrcweir             createName( pMeth, "equals", i )
388*cdf0e10cSrcweir         );
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir         res &= lastRes;
391*cdf0e10cSrcweir     }
392*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "equals");
393*cdf0e10cSrcweir //    return (res);
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir //------------------------------------------------------------------------
397*cdf0e10cSrcweir // testing the method equalsIgnoreAsciiCase( const OString & aStr )
398*cdf0e10cSrcweir //------------------------------------------------------------------------
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_equalsIgnoreAsciiCase(
401*cdf0e10cSrcweir                                              hTestResult hRtlTestResult )
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
404*cdf0e10cSrcweir     sal_Char* pMeth = methName;
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "equalsIgnoreAsciiCase");
407*cdf0e10cSrcweir     typedef struct TestCase
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir     sal_Char*                    comments;
410*cdf0e10cSrcweir     sal_Bool                     expVal;
411*cdf0e10cSrcweir     OString*                     input1;
412*cdf0e10cSrcweir     OString*                     input2;
413*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
414*cdf0e10cSrcweir } TestCase;
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir TestCase arrTestCase[]={
417*cdf0e10cSrcweir         {"same strings but different cases",sal_True,new OString(kTestStr4),
418*cdf0e10cSrcweir             new OString(kTestStr5)},
419*cdf0e10cSrcweir         {"same strings",sal_True,new OString(kTestStr4),
420*cdf0e10cSrcweir             new OString(kTestStr4)},
421*cdf0e10cSrcweir         {"with equal beginning",sal_False,new OString(kTestStr2),
422*cdf0e10cSrcweir             new OString(kTestStr4)},
423*cdf0e10cSrcweir         {"empty(def.constructor) and non empty",sal_False,new OString(),
424*cdf0e10cSrcweir             new OString(kTestStr5)},
425*cdf0e10cSrcweir         {"non empty and empty(def.constructor)",sal_False,
426*cdf0e10cSrcweir             new OString(kTestStr4), new OString()},
427*cdf0e10cSrcweir         {"two empty strings(def.constructor)",sal_True,new OString(),
428*cdf0e10cSrcweir             new OString()},
429*cdf0e10cSrcweir         {"different strings with equal length",sal_False,
430*cdf0e10cSrcweir             new OString(kTestStr10), new OString(kTestStr11)}
431*cdf0e10cSrcweir     };
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir     sal_Bool res = sal_True;
434*cdf0e10cSrcweir     sal_uInt32 i;
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
437*cdf0e10cSrcweir     {
438*cdf0e10cSrcweir         sal_Bool lastRes =
439*cdf0e10cSrcweir         (arrTestCase[i].input1->equalsIgnoreAsciiCase(*arrTestCase[i].input2)
440*cdf0e10cSrcweir             == arrTestCase[i].expVal);
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir          c_rtl_tres_state
443*cdf0e10cSrcweir         (
444*cdf0e10cSrcweir             hRtlTestResult,
445*cdf0e10cSrcweir             lastRes,
446*cdf0e10cSrcweir             arrTestCase[i].comments,
447*cdf0e10cSrcweir             createName( pMeth, "equalsIgnoreAsciiCase", i )
448*cdf0e10cSrcweir         );
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir         res &= lastRes;
451*cdf0e10cSrcweir     }
452*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "equalsIgnoreAsciiCase");
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir //    return (res);
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_compareTo_001(
458*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
459*cdf0e10cSrcweir {
460*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
461*cdf0e10cSrcweir     sal_Char* pMeth = methName;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     typedef struct TestCase
464*cdf0e10cSrcweir {
465*cdf0e10cSrcweir     sal_Char*                     comments;
466*cdf0e10cSrcweir     sal_Int32                     expVal;
467*cdf0e10cSrcweir     OString*                      input1;
468*cdf0e10cSrcweir     OString*                      input2;
469*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
470*cdf0e10cSrcweir } TestCase;
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir TestCase arrTestCase[]={
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir         {"simple compare, str1 to str5",-1,new OString(kTestStr1),
475*cdf0e10cSrcweir             new OString(kTestStr5)},
476*cdf0e10cSrcweir         {"simple compare, str2 to str5",-1,new OString(kTestStr2),
477*cdf0e10cSrcweir             new OString(kTestStr5)},
478*cdf0e10cSrcweir         {"simple compare, str1 to str9",-1,new OString(kTestStr1),
479*cdf0e10cSrcweir             new OString(kTestStr9)},
480*cdf0e10cSrcweir         {"simple compare, str1 to str2",-1,new OString(kTestStr1),
481*cdf0e10cSrcweir             new OString(kTestStr2)},
482*cdf0e10cSrcweir         {"simple compare, str4 to str5",-1,new OString(kTestStr4),
483*cdf0e10cSrcweir             new OString(kTestStr5)},
484*cdf0e10cSrcweir         {"simple compare, str1 to str3",-1,new OString(kTestStr1),
485*cdf0e10cSrcweir             new OString(kTestStr3)},
486*cdf0e10cSrcweir         {"simple compare, str5 to str1",+1,new OString(kTestStr5),
487*cdf0e10cSrcweir             new OString(kTestStr1)},
488*cdf0e10cSrcweir         {"simple compare, str2 to str1",+1,new OString(kTestStr2),
489*cdf0e10cSrcweir             new OString(kTestStr1)},
490*cdf0e10cSrcweir         {"simple compare, str9 to str5",+1,new OString(kTestStr9),
491*cdf0e10cSrcweir             new OString(kTestStr5)},
492*cdf0e10cSrcweir         {"simple compare, str5 to str4",+1,new OString(kTestStr5),
493*cdf0e10cSrcweir             new OString(kTestStr4)},
494*cdf0e10cSrcweir         {"simple compare, str1 to str1",0,new OString(kTestStr1),
495*cdf0e10cSrcweir             new OString(kTestStr1)},
496*cdf0e10cSrcweir         {"simple compare, nullString to nullString",0,new OString(),
497*cdf0e10cSrcweir             new OString()},
498*cdf0e10cSrcweir         {"simple compare, nullString to str2",-1,new OString(),
499*cdf0e10cSrcweir             new OString(kTestStr2)},
500*cdf0e10cSrcweir         {"simple compare, str1 to nullString",+1,new OString(kTestStr1),
501*cdf0e10cSrcweir             new OString()}
502*cdf0e10cSrcweir     };
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir     sal_Bool res = sal_True;
505*cdf0e10cSrcweir     sal_uInt32 i;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
508*cdf0e10cSrcweir     {
509*cdf0e10cSrcweir         sal_Int32 cmpRes =
510*cdf0e10cSrcweir             arrTestCase[i].input1->compareTo(*arrTestCase[i].input2);
511*cdf0e10cSrcweir         cmpRes = ( cmpRes == 0 ) ? 0 : ( cmpRes > 0 ) ? +1 : -1 ;
512*cdf0e10cSrcweir         sal_Bool lastRes = ( cmpRes == arrTestCase[i].expVal);
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir         c_rtl_tres_state
515*cdf0e10cSrcweir         (
516*cdf0e10cSrcweir             hRtlTestResult,
517*cdf0e10cSrcweir             lastRes,
518*cdf0e10cSrcweir             arrTestCase[i].comments,
519*cdf0e10cSrcweir             createName( pMeth, "compareTo(const OString&)", i )
520*cdf0e10cSrcweir         );
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir         res &= lastRes;
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir     return (res);
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir //------------------------------------------------------------------------
530*cdf0e10cSrcweir //  testing the method compareTo( const OString & rObj, sal_Int32 length )
531*cdf0e10cSrcweir //------------------------------------------------------------------------
532*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_compareTo_002(
533*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
534*cdf0e10cSrcweir {
535*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
536*cdf0e10cSrcweir     sal_Char* pMeth = methName;
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir     typedef struct TestCase
539*cdf0e10cSrcweir     {
540*cdf0e10cSrcweir     sal_Char*                    comments;
541*cdf0e10cSrcweir     sal_Int32                    expVal;
542*cdf0e10cSrcweir     sal_Int32                    maxLength;
543*cdf0e10cSrcweir     OString*                     input1;
544*cdf0e10cSrcweir     OString*                     input2;
545*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
546*cdf0e10cSrcweir     } TestCase;
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir     TestCase arrTestCase[] =
549*cdf0e10cSrcweir     {
550*cdf0e10cSrcweir         {"compare with maxlength, str1 to str9, 16",-1,16,
551*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr9)},
552*cdf0e10cSrcweir         {"compare with maxlength, str2 to str9, 32",-1,32,
553*cdf0e10cSrcweir             new OString(kTestStr2), new OString(kTestStr9)},
554*cdf0e10cSrcweir         {"compare with maxlength, str9 to str4, 16",+1,16,
555*cdf0e10cSrcweir             new OString(kTestStr9), new OString(kTestStr4)},
556*cdf0e10cSrcweir         {"compare with maxlength, str9 to str22, 32",+1,32,
557*cdf0e10cSrcweir             new OString(kTestStr9), new OString(kTestStr22)},
558*cdf0e10cSrcweir         {"compare with maxlength, str9 to str5, 16",0,16,
559*cdf0e10cSrcweir             new OString(kTestStr9), new OString(kTestStr5)},
560*cdf0e10cSrcweir         {"compare with maxlength, str9 to str9, 32",0,32,
561*cdf0e10cSrcweir             new OString(kTestStr9), new OString(kTestStr9)},
562*cdf0e10cSrcweir         {"compare with maxlength, str1 to str2, 32",-1,32,
563*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr2)},
564*cdf0e10cSrcweir         {"compare with maxlength, str1 to str2, 32",-1,32,
565*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr2)}
566*cdf0e10cSrcweir     };
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     sal_Bool res = sal_True;
569*cdf0e10cSrcweir     sal_uInt32 i;
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
572*cdf0e10cSrcweir     {
573*cdf0e10cSrcweir         sal_Int32 cmpRes =
574*cdf0e10cSrcweir                     arrTestCase[i].input1->compareTo(*arrTestCase[i].input2,
575*cdf0e10cSrcweir                             arrTestCase[i].maxLength);
576*cdf0e10cSrcweir         cmpRes = (cmpRes == 0) ? 0 : (cmpRes > 0) ? +1 : -1 ;
577*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir         c_rtl_tres_state
580*cdf0e10cSrcweir         (
581*cdf0e10cSrcweir             hRtlTestResult,
582*cdf0e10cSrcweir             lastRes,
583*cdf0e10cSrcweir             arrTestCase[i].comments,
584*cdf0e10cSrcweir             createName( pMeth, "compareTo(const OString&, sal_Int32)", i )
585*cdf0e10cSrcweir         );
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir         res &= lastRes;
588*cdf0e10cSrcweir     }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir     return (res);
591*cdf0e10cSrcweir }
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_compareTo(
594*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "compareTo");
597*cdf0e10cSrcweir     sal_Bool res = test_rtl_OString_compareTo_001(hRtlTestResult);
598*cdf0e10cSrcweir     res &= test_rtl_OString_compareTo_002(hRtlTestResult);
599*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "compareTo");
600*cdf0e10cSrcweir //    return (res);
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir //------------------------------------------------------------------------
604*cdf0e10cSrcweir // testing the operator == ( const OString& rStr1, const OString& rStr2 )
605*cdf0e10cSrcweir // testing the operator == ( const OString& rStr1, const sal_Char *rStr2 )
606*cdf0e10cSrcweir // testing the operator == ( const sal_Char *rStr1, const OString& rStr2 )
607*cdf0e10cSrcweir //------------------------------------------------------------------------
608*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_cmp(
609*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
610*cdf0e10cSrcweir {
611*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_cmp");
612*cdf0e10cSrcweir     const sal_Int16 NCASES = 7;
613*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
614*cdf0e10cSrcweir     sal_Char* pMeth = methName;
615*cdf0e10cSrcweir     const sal_Char *arrOStr[NCASES][2] =
616*cdf0e10cSrcweir     {
617*cdf0e10cSrcweir         {kTestStr1, kTestStr1},
618*cdf0e10cSrcweir         {kTestStr1, kTestStr3},
619*cdf0e10cSrcweir         {kTestStr1, kTestStr2},
620*cdf0e10cSrcweir         {0, 0},
621*cdf0e10cSrcweir         {0, kTestStr2},
622*cdf0e10cSrcweir         {kTestStr1, 0},
623*cdf0e10cSrcweir         {"", ""}
624*cdf0e10cSrcweir     };
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir     sal_Bool arrExpVal[NCASES] =
627*cdf0e10cSrcweir     {
628*cdf0e10cSrcweir         sal_True,
629*cdf0e10cSrcweir         sal_False,
630*cdf0e10cSrcweir         sal_False,
631*cdf0e10cSrcweir         sal_True,
632*cdf0e10cSrcweir         sal_False,
633*cdf0e10cSrcweir         sal_False,
634*cdf0e10cSrcweir         sal_True
635*cdf0e10cSrcweir     };
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir     sal_Char *arrComments[NCASES] =
638*cdf0e10cSrcweir     {
639*cdf0e10cSrcweir         "'Sun Microsystems'=='Sun Microsystems'",
640*cdf0e10cSrcweir         "!('Sun Microsystems'=='Sun microsystems')",
641*cdf0e10cSrcweir         "!('Sun Microsystems'=='Sun Microsystems Java Technology')",
642*cdf0e10cSrcweir         "two empty strings(def.constructor)",
643*cdf0e10cSrcweir         "!(empty string=='Sun Microsystems Java Technology')",
644*cdf0e10cSrcweir         "!('Sun Microsystems Java Technology'==empty string)",
645*cdf0e10cSrcweir         "''==''"
646*cdf0e10cSrcweir     };
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir     sal_Bool res = sal_True;
649*cdf0e10cSrcweir     sal_Int32 i;
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir     for(i = 0; i < NCASES; i++)
652*cdf0e10cSrcweir     {
653*cdf0e10cSrcweir         OString *str1, *str2;
654*cdf0e10cSrcweir         str1 = (arrOStr[i][0]) ? new OString(arrOStr[i][0]) : new OString() ;
655*cdf0e10cSrcweir         str2 = (arrOStr[i][1]) ? new OString(arrOStr[i][1]) : new OString() ;
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir         sal_Bool cmpRes = (*str1 == *str2);
658*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrExpVal[i]);
659*cdf0e10cSrcweir         res &= lastRes;
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir         c_rtl_tres_state
662*cdf0e10cSrcweir         (
663*cdf0e10cSrcweir             hRtlTestResult,
664*cdf0e10cSrcweir             lastRes,
665*cdf0e10cSrcweir             arrComments[i],
666*cdf0e10cSrcweir             createName( pMeth, "operator ==(OString&, OString&)", i )
667*cdf0e10cSrcweir         );
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir         cmpRes = (*str1 == arrOStr[i][1]);
670*cdf0e10cSrcweir         lastRes = (cmpRes == arrExpVal[i]);
671*cdf0e10cSrcweir         res &= lastRes;
672*cdf0e10cSrcweir         c_rtl_tres_state
673*cdf0e10cSrcweir         (
674*cdf0e10cSrcweir             hRtlTestResult,
675*cdf0e10cSrcweir             lastRes,
676*cdf0e10cSrcweir             arrComments[i],
677*cdf0e10cSrcweir             createName( pMeth, "operator ==(OString&, sal_Char *)", i )
678*cdf0e10cSrcweir         );
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir         cmpRes = (arrOStr[i][0] == *str2);
681*cdf0e10cSrcweir         lastRes = (cmpRes == arrExpVal[i]);
682*cdf0e10cSrcweir         res &= lastRes;
683*cdf0e10cSrcweir         c_rtl_tres_state
684*cdf0e10cSrcweir         (
685*cdf0e10cSrcweir             hRtlTestResult,
686*cdf0e10cSrcweir             lastRes,
687*cdf0e10cSrcweir             arrComments[i],
688*cdf0e10cSrcweir             createName( pMeth, "operator ==(sal_Char *, OString&)", i )
689*cdf0e10cSrcweir         );
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir         delete str2;
692*cdf0e10cSrcweir         delete str1;
693*cdf0e10cSrcweir     }
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_cmp");
696*cdf0e10cSrcweir //    return ( res );
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir //------------------------------------------------------------------------
700*cdf0e10cSrcweir // testing the operator != (const OString& rStr1, const OString& rStr2)
701*cdf0e10cSrcweir // testing the operator != (const OString& rStr1, const sal_Char *rStr2)
702*cdf0e10cSrcweir // testing the operator != (const sal_Char *rStr1, const OString& rStr2)
703*cdf0e10cSrcweir //------------------------------------------------------------------------
704*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_neq(
705*cdf0e10cSrcweir                                              hTestResult hRtlTestResult )
706*cdf0e10cSrcweir {
707*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_neq");
708*cdf0e10cSrcweir     const sal_Int16 NCASES = 6;
709*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
710*cdf0e10cSrcweir     sal_Char* pMeth = methName;
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir     const sal_Char *arrOStr[NCASES][2] =
713*cdf0e10cSrcweir     {
714*cdf0e10cSrcweir         {kTestStr1, kTestStr3},
715*cdf0e10cSrcweir         {kTestStr1, kTestStr2},
716*cdf0e10cSrcweir         {kTestStr1, kTestStr1},
717*cdf0e10cSrcweir         {0, kTestStr2},
718*cdf0e10cSrcweir         {kTestStr1, 0},
719*cdf0e10cSrcweir         {0, 0}
720*cdf0e10cSrcweir     };
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir     sal_Bool arrExpVal[NCASES] =
723*cdf0e10cSrcweir     {
724*cdf0e10cSrcweir         sal_True,
725*cdf0e10cSrcweir         sal_True,
726*cdf0e10cSrcweir         sal_False,
727*cdf0e10cSrcweir         sal_True,
728*cdf0e10cSrcweir         sal_True,
729*cdf0e10cSrcweir         sal_False
730*cdf0e10cSrcweir     };
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir     sal_Char *arrComments[NCASES] =
733*cdf0e10cSrcweir     {
734*cdf0e10cSrcweir         "'Sun Microsystems'!='Sun microsystems'",
735*cdf0e10cSrcweir         "'Sun Microsystems'!='Sun Microsystems Java Technology'",
736*cdf0e10cSrcweir         "!('Sun Microsystems'!='Sun Microsystems')",
737*cdf0e10cSrcweir         "empty string!='Sun Microsystems Java Technology'",
738*cdf0e10cSrcweir         "'Sun Microsystems Java Technology'!=empty string", "!(''!='')"
739*cdf0e10cSrcweir     };
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir     sal_Bool res = sal_True;
742*cdf0e10cSrcweir     sal_Int32 i;
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir     for(i = 0; i < NCASES; i++)
745*cdf0e10cSrcweir     {
746*cdf0e10cSrcweir         OString *str1, *str2;
747*cdf0e10cSrcweir         str1 = (arrOStr[i][0]) ? new OString(arrOStr[i][0]) : new OString() ;
748*cdf0e10cSrcweir         str2 = (arrOStr[i][1]) ? new OString(arrOStr[i][1]) : new OString() ;
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir         sal_Bool cmpRes = (*str1 != *str2);
751*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrExpVal[i]);
752*cdf0e10cSrcweir         res &= lastRes;
753*cdf0e10cSrcweir         c_rtl_tres_state
754*cdf0e10cSrcweir         (
755*cdf0e10cSrcweir             hRtlTestResult,
756*cdf0e10cSrcweir             lastRes,
757*cdf0e10cSrcweir             arrComments[i],
758*cdf0e10cSrcweir             createName( pMeth, "operator !=(OString&, OString&)", i )
759*cdf0e10cSrcweir         );
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir         cmpRes = (*str1 != arrOStr[i][1]);
762*cdf0e10cSrcweir         lastRes = (cmpRes == arrExpVal[i]);
763*cdf0e10cSrcweir         res &= lastRes;
764*cdf0e10cSrcweir         c_rtl_tres_state
765*cdf0e10cSrcweir         (
766*cdf0e10cSrcweir             hRtlTestResult,
767*cdf0e10cSrcweir             lastRes,
768*cdf0e10cSrcweir             arrComments[i],
769*cdf0e10cSrcweir             createName( pMeth, "operator !=(OString&, sal_Char *)", i )
770*cdf0e10cSrcweir         );
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir         cmpRes = (arrOStr[i][0] != *str2);
773*cdf0e10cSrcweir         lastRes = (cmpRes == arrExpVal[i]);
774*cdf0e10cSrcweir         res &= lastRes;
775*cdf0e10cSrcweir         c_rtl_tres_state
776*cdf0e10cSrcweir         (
777*cdf0e10cSrcweir             hRtlTestResult,
778*cdf0e10cSrcweir             lastRes,
779*cdf0e10cSrcweir             arrComments[i],
780*cdf0e10cSrcweir             createName( pMeth, "operator !=(sal_Char *, OString&)", i )
781*cdf0e10cSrcweir         );
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir         delete str2;
784*cdf0e10cSrcweir         delete str1;
785*cdf0e10cSrcweir     }
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_neq");
788*cdf0e10cSrcweir //   return ( res );
789*cdf0e10cSrcweir }
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir //------------------------------------------------------------------------
793*cdf0e10cSrcweir // testing the operator > (const OString& rStr1, const OString& rStr2)
794*cdf0e10cSrcweir //------------------------------------------------------------------------
795*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_g(
796*cdf0e10cSrcweir                                              hTestResult hRtlTestResult )
797*cdf0e10cSrcweir {
798*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
799*cdf0e10cSrcweir     sal_Char* pMeth = methName;
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_g");
802*cdf0e10cSrcweir     typedef struct TestCase
803*cdf0e10cSrcweir     {
804*cdf0e10cSrcweir     sal_Char*                    comments;
805*cdf0e10cSrcweir     sal_Bool                     expVal;
806*cdf0e10cSrcweir     OString*                     input1;
807*cdf0e10cSrcweir     OString*                     input2;
808*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
809*cdf0e10cSrcweir     } TestCase;
810*cdf0e10cSrcweir 
811*cdf0e10cSrcweir     TestCase arrTestCase[] =
812*cdf0e10cSrcweir     {
813*cdf0e10cSrcweir         { "'Sun microsystems'>'Sun Microsystems'",sal_True,
814*cdf0e10cSrcweir             new OString(kTestStr3), new OString(kTestStr1)},
815*cdf0e10cSrcweir         {"!('Sun Microsystems'>'Sun microsystems')",sal_False,
816*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr3)},
817*cdf0e10cSrcweir         {"'Sun Microsystems Java Technology'>'Sun Microsystems'",sal_True,
818*cdf0e10cSrcweir             new OString(kTestStr2), new OString(kTestStr1)},
819*cdf0e10cSrcweir         {"!('Sun Microsystems'>'Sun Microsystems Java Technology')",sal_False,
820*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr2)},
821*cdf0e10cSrcweir         {"!('Sun Microsystems'>'Sun Microsystems'",sal_False,
822*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr1)},
823*cdf0e10cSrcweir         {"'Sun Microsystems'>''",sal_True,new OString(kTestStr1),
824*cdf0e10cSrcweir             new OString()},
825*cdf0e10cSrcweir         {"!(''>'Sun Microsystems')",sal_False,new OString(),
826*cdf0e10cSrcweir             new OString(kTestStr1)},
827*cdf0e10cSrcweir         {"!(''>'')",sal_False,new OString(), new OString()}
828*cdf0e10cSrcweir };
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir     sal_Bool res = sal_True;
831*cdf0e10cSrcweir     sal_uInt32 i;
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
834*cdf0e10cSrcweir     {
835*cdf0e10cSrcweir         sal_Bool cmpRes = (*arrTestCase[i].input1 > *arrTestCase[i].input2);
836*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir         c_rtl_tres_state
839*cdf0e10cSrcweir         (
840*cdf0e10cSrcweir             hRtlTestResult,
841*cdf0e10cSrcweir             lastRes,
842*cdf0e10cSrcweir             arrTestCase[i].comments,
843*cdf0e10cSrcweir             createName( pMeth, "operator >", i )
844*cdf0e10cSrcweir         );
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir         res &= lastRes;
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir     }
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_g");
851*cdf0e10cSrcweir //    return ( res );
852*cdf0e10cSrcweir }
853*cdf0e10cSrcweir 
854*cdf0e10cSrcweir //------------------------------------------------------------------------
855*cdf0e10cSrcweir // testing the operator < (const OString& rStr1, const OString& rStr2)
856*cdf0e10cSrcweir //------------------------------------------------------------------------
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_l(
859*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
860*cdf0e10cSrcweir {
861*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
862*cdf0e10cSrcweir     sal_Char* pMeth = methName;
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_l");
865*cdf0e10cSrcweir     typedef struct TestCase
866*cdf0e10cSrcweir     {
867*cdf0e10cSrcweir     sal_Char*                    comments;
868*cdf0e10cSrcweir     sal_Bool                     expVal;
869*cdf0e10cSrcweir     OString*                     input1;
870*cdf0e10cSrcweir     OString*                     input2;
871*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
872*cdf0e10cSrcweir     } TestCase;
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir     TestCase arrTestCase[] =
875*cdf0e10cSrcweir     {
876*cdf0e10cSrcweir         {"!('Sun microsystems'<'Sun Microsystems')",sal_False,
877*cdf0e10cSrcweir             new OString(kTestStr3), new OString(kTestStr1)},
878*cdf0e10cSrcweir         {"'Sun Microsystems'<'Sun microsystems'",sal_True,
879*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr3)},
880*cdf0e10cSrcweir         {"'Sun Microsystems'<'Sun Microsystems Java Technology'",sal_True,
881*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr2)},
882*cdf0e10cSrcweir         {"!('Sun Microsystems Java Technology'<'Sun Microsystems')",sal_False,
883*cdf0e10cSrcweir             new OString(kTestStr2), new OString(kTestStr1)},
884*cdf0e10cSrcweir         {"!('Sun Microsystems'<'Sun Microsystems'", sal_False,
885*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr1)},
886*cdf0e10cSrcweir         {"'Sun Microsystems'<''",sal_False,new OString(kTestStr1),
887*cdf0e10cSrcweir             new OString()},
888*cdf0e10cSrcweir         {"''<'Sun Microsystems Java Technology'",sal_True,new OString(),
889*cdf0e10cSrcweir             new OString(kTestStr2)},
890*cdf0e10cSrcweir         {"!(''<'')",sal_False,new OString(), new OString()}
891*cdf0e10cSrcweir     };
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir     sal_Bool res = sal_True;
894*cdf0e10cSrcweir     sal_uInt32 i;
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
897*cdf0e10cSrcweir     {
898*cdf0e10cSrcweir         sal_Bool cmpRes = (*arrTestCase[i].input1 < *arrTestCase[i].input2);
899*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir         c_rtl_tres_state
902*cdf0e10cSrcweir         (
903*cdf0e10cSrcweir             hRtlTestResult,
904*cdf0e10cSrcweir             lastRes,
905*cdf0e10cSrcweir             arrTestCase[i].comments,
906*cdf0e10cSrcweir             createName( pMeth, "operator <", i )
907*cdf0e10cSrcweir         );
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir         res &= lastRes;
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir     }
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_l");
914*cdf0e10cSrcweir //   return ( res );
915*cdf0e10cSrcweir }
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir //------------------------------------------------------------------------
918*cdf0e10cSrcweir // testing the operator >= (const OString& rStr1, const OString& rStr2)
919*cdf0e10cSrcweir //------------------------------------------------------------------------
920*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_ge(
921*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
922*cdf0e10cSrcweir {
923*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
924*cdf0e10cSrcweir     sal_Char* pMeth = methName;
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_ge");
927*cdf0e10cSrcweir    typedef struct TestCase
928*cdf0e10cSrcweir     {
929*cdf0e10cSrcweir     sal_Char*                    comments;
930*cdf0e10cSrcweir     sal_Bool                     expVal;
931*cdf0e10cSrcweir     OString*                     input1;
932*cdf0e10cSrcweir     OString*                     input2;
933*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
934*cdf0e10cSrcweir     } TestCase;
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir     TestCase arrTestCase[] =
937*cdf0e10cSrcweir     {
938*cdf0e10cSrcweir         {"'Sun microsystems'>='Sun Microsystems'",sal_True,
939*cdf0e10cSrcweir             new OString(kTestStr3), new OString(kTestStr1)},
940*cdf0e10cSrcweir         {"!('Sun Microsystems'>='Sun microsystems')",sal_False,
941*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr3)},
942*cdf0e10cSrcweir         {"!('Sun Microsystems'>='Sun Microsystems Java Technology')",sal_False,
943*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr2)},
944*cdf0e10cSrcweir         {"'Sun Microsystems Java Technology'>='Sun Microsystems'",sal_True,
945*cdf0e10cSrcweir             new OString(kTestStr2), new OString(kTestStr1)},
946*cdf0e10cSrcweir         {"'Sun Microsystems'>='Sun Microsystems'", sal_True,
947*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr1)},
948*cdf0e10cSrcweir         {"'Sun Microsystems'>=''",sal_True,new OString(kTestStr1),
949*cdf0e10cSrcweir             new OString()},
950*cdf0e10cSrcweir         { "''>='Sun microsystems'",sal_False,new OString(),
951*cdf0e10cSrcweir             new OString(kTestStr3)},
952*cdf0e10cSrcweir         {"''>=''",sal_True,new OString(), new OString()}
953*cdf0e10cSrcweir     };
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir     sal_Bool res = sal_True;
956*cdf0e10cSrcweir     sal_uInt32 i;
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
959*cdf0e10cSrcweir     {
960*cdf0e10cSrcweir         sal_Bool cmpRes = (*arrTestCase[i].input1 >= *arrTestCase[i].input2);
961*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir         c_rtl_tres_state
964*cdf0e10cSrcweir         (
965*cdf0e10cSrcweir             hRtlTestResult,
966*cdf0e10cSrcweir             lastRes,
967*cdf0e10cSrcweir             arrTestCase[i].comments,
968*cdf0e10cSrcweir             createName( pMeth, "operator >=", i )
969*cdf0e10cSrcweir         );
970*cdf0e10cSrcweir 
971*cdf0e10cSrcweir         res &= lastRes;
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir     }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_ge");
976*cdf0e10cSrcweir //    return ( res );
977*cdf0e10cSrcweir }
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir //------------------------------------------------------------------------
980*cdf0e10cSrcweir // testing the operator <= (const OString& rStr1, const OString& rStr2)
981*cdf0e10cSrcweir //------------------------------------------------------------------------
982*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_le(
983*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
984*cdf0e10cSrcweir {
985*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
986*cdf0e10cSrcweir     sal_Char* pMeth = methName;
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_le");
989*cdf0e10cSrcweir     typedef struct TestCase
990*cdf0e10cSrcweir     {
991*cdf0e10cSrcweir     sal_Char*                    comments;
992*cdf0e10cSrcweir     sal_Bool                     expVal;
993*cdf0e10cSrcweir     OString*                     input1;
994*cdf0e10cSrcweir     OString*                     input2;
995*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
996*cdf0e10cSrcweir     } TestCase;
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir     TestCase arrTestCase[] =
999*cdf0e10cSrcweir     {
1000*cdf0e10cSrcweir         {"!('Sun microsystems'<='Sun Microsystems')",sal_False,
1001*cdf0e10cSrcweir             new OString(kTestStr3), new OString(kTestStr1)},
1002*cdf0e10cSrcweir         {"'Sun Microsystems'<='Sun microsystems'",sal_True,
1003*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr3)},
1004*cdf0e10cSrcweir         {"'Sun Microsystems'<='Sun Microsystems Java Technology'",sal_True,
1005*cdf0e10cSrcweir             new OString(kTestStr1),
1006*cdf0e10cSrcweir             new OString(kTestStr2)},
1007*cdf0e10cSrcweir         {"!('Sun Microsystems Java Technology'<='Sun Microsystems')",sal_False,
1008*cdf0e10cSrcweir             new OString(kTestStr2),
1009*cdf0e10cSrcweir             new OString(kTestStr1)},
1010*cdf0e10cSrcweir         {"!('Sun Microsystems'<='Sun Microsystems'", sal_True,
1011*cdf0e10cSrcweir             new OString(kTestStr1), new OString(kTestStr1)},
1012*cdf0e10cSrcweir         {"'Sun Microsystems'<=''",sal_False,new OString(kTestStr1),
1013*cdf0e10cSrcweir             new OString()},
1014*cdf0e10cSrcweir         {"''<='Sun Microsystems Java Technology'",sal_True,new OString(),
1015*cdf0e10cSrcweir             new OString(kTestStr2)},
1016*cdf0e10cSrcweir         {"!(''<='')",sal_True,new OString(), new OString()}
1017*cdf0e10cSrcweir     };
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir     sal_Bool res = sal_True;
1020*cdf0e10cSrcweir     sal_uInt32 i;
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1023*cdf0e10cSrcweir     {
1024*cdf0e10cSrcweir         sal_Bool cmpRes = (*arrTestCase[i].input1 <= *arrTestCase[i].input2);
1025*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir         c_rtl_tres_state
1028*cdf0e10cSrcweir         (
1029*cdf0e10cSrcweir             hRtlTestResult,
1030*cdf0e10cSrcweir             lastRes,
1031*cdf0e10cSrcweir             arrTestCase[i].comments,
1032*cdf0e10cSrcweir             createName( pMeth, "operator <=", i )
1033*cdf0e10cSrcweir         );
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir         res &= lastRes;
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir     }
1038*cdf0e10cSrcweir 
1039*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_le");
1040*cdf0e10cSrcweir //    return ( res );
1041*cdf0e10cSrcweir }
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir //------------------------------------------------------------------------
1045*cdf0e10cSrcweir // testing the operator =
1046*cdf0e10cSrcweir //------------------------------------------------------------------------
1047*cdf0e10cSrcweir static sal_Bool test_rtl_OString_op_eq_001( hTestResult hRtlTestResult )
1048*cdf0e10cSrcweir {
1049*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1050*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir     typedef struct TestCase
1053*cdf0e10cSrcweir     {
1054*cdf0e10cSrcweir     sal_Char*                    comments;
1055*cdf0e10cSrcweir     sal_Bool                     expVal;
1056*cdf0e10cSrcweir     OString*                     input1;
1057*cdf0e10cSrcweir     OString*                     input2;
1058*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2;}
1059*cdf0e10cSrcweir     } TestCase;
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir     TestCase arrTestCase[] =
1062*cdf0e10cSrcweir     {
1063*cdf0e10cSrcweir         {"'' = str1, str1 == str2",sal_True,new OString(kTestStr1),
1064*cdf0e10cSrcweir             new OString()},
1065*cdf0e10cSrcweir         {"str1 = str2, str1 == str2",sal_True,new OString(kTestStr1),
1066*cdf0e10cSrcweir             new OString(kTestStr6)},
1067*cdf0e10cSrcweir         {"str2 = '', str1 == str2",sal_True,new OString(),
1068*cdf0e10cSrcweir             new OString(kTestStr2)},
1069*cdf0e10cSrcweir         {"'' = '', str1 == str2",sal_True,new OString(),
1070*cdf0e10cSrcweir             new OString()}
1071*cdf0e10cSrcweir     };
1072*cdf0e10cSrcweir 
1073*cdf0e10cSrcweir     sal_Bool res = sal_True;
1074*cdf0e10cSrcweir     sal_uInt32 i;
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1077*cdf0e10cSrcweir     {
1078*cdf0e10cSrcweir        *(arrTestCase[i].input1) = *(arrTestCase[i].input2);
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir         sal_Bool cmpRes =
1081*cdf0e10cSrcweir             (*(arrTestCase[i].input1) == *(arrTestCase[i].input2));
1082*cdf0e10cSrcweir         sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir         c_rtl_tres_state
1085*cdf0e10cSrcweir         (
1086*cdf0e10cSrcweir             hRtlTestResult,
1087*cdf0e10cSrcweir             lastRes,
1088*cdf0e10cSrcweir             arrTestCase[i].comments,
1089*cdf0e10cSrcweir             createName( pMeth, "operator =", i )
1090*cdf0e10cSrcweir         );
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir         res &= lastRes;
1093*cdf0e10cSrcweir     }
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir     return ( res );
1096*cdf0e10cSrcweir }
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir static sal_Bool test_rtl_OString_op_eq_002(
1099*cdf0e10cSrcweir                     hTestResult hRtlTestResult )
1100*cdf0e10cSrcweir {
1101*cdf0e10cSrcweir     ::rtl::OString aStr;
1102*cdf0e10cSrcweir     aStr = OString(kTestStr1);
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir     return
1105*cdf0e10cSrcweir     (
1106*cdf0e10cSrcweir         c_rtl_tres_state
1107*cdf0e10cSrcweir         (
1108*cdf0e10cSrcweir             hRtlTestResult,
1109*cdf0e10cSrcweir             aStr == kTestStr1,
1110*cdf0e10cSrcweir             "str = OString(\"%s\"), str == \"%s\"",
1111*cdf0e10cSrcweir             "operator ="
1112*cdf0e10cSrcweir         )
1113*cdf0e10cSrcweir     );
1114*cdf0e10cSrcweir }
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir static sal_Bool test_rtl_OString_op_eq_003(
1117*cdf0e10cSrcweir                     hTestResult hRtlTestResult )
1118*cdf0e10cSrcweir {
1119*cdf0e10cSrcweir     sal_Bool bTCState = false;
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir     ::rtl::OString aStr1(kTestStr1);
1122*cdf0e10cSrcweir     ::rtl::OString aStr2;
1123*cdf0e10cSrcweir     ::rtl::OString aStr3;
1124*cdf0e10cSrcweir 
1125*cdf0e10cSrcweir     aStr3 = aStr2 = aStr1;
1126*cdf0e10cSrcweir 
1127*cdf0e10cSrcweir     bTCState =    ( aStr1 == aStr2 )
1128*cdf0e10cSrcweir                && ( aStr1 == aStr3 )
1129*cdf0e10cSrcweir                && ( aStr2 == aStr3 );
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir     c_rtl_tres_state
1132*cdf0e10cSrcweir     (
1133*cdf0e10cSrcweir         hRtlTestResult,
1134*cdf0e10cSrcweir         bTCState,
1135*cdf0e10cSrcweir         "str3=str2=str1,(str1 == str2)&&(str1 == str3)&&(str2 == str3)",
1136*cdf0e10cSrcweir         "operator ="
1137*cdf0e10cSrcweir     );
1138*cdf0e10cSrcweir 
1139*cdf0e10cSrcweir     return bTCState;
1140*cdf0e10cSrcweir }
1141*cdf0e10cSrcweir 
1142*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_eq(
1143*cdf0e10cSrcweir                                          hTestResult hRtlTestResult )
1144*cdf0e10cSrcweir {
1145*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_eq");
1146*cdf0e10cSrcweir     sal_Bool res = test_rtl_OString_op_eq_001( hRtlTestResult );
1147*cdf0e10cSrcweir     res &= test_rtl_OString_op_eq_002( hRtlTestResult );
1148*cdf0e10cSrcweir     res &= test_rtl_OString_op_eq_003( hRtlTestResult );
1149*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_eq");
1150*cdf0e10cSrcweir 
1151*cdf0e10cSrcweir //    return ( res );
1152*cdf0e10cSrcweir }
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir //------------------------------------------------------------------------
1155*cdf0e10cSrcweir // testing the operator +
1156*cdf0e10cSrcweir //------------------------------------------------------------------------
1157*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_plus(
1158*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1159*cdf0e10cSrcweir {
1160*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1161*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_plus");
1164*cdf0e10cSrcweir     typedef struct TestCase
1165*cdf0e10cSrcweir     {
1166*cdf0e10cSrcweir     sal_Char*                    comments;
1167*cdf0e10cSrcweir     OString*                     expVal;
1168*cdf0e10cSrcweir     OString*                     input1;
1169*cdf0e10cSrcweir     OString*                     input2;
1170*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2; delete expVal;}
1171*cdf0e10cSrcweir     } TestCase;
1172*cdf0e10cSrcweir 
1173*cdf0e10cSrcweir     TestCase arrTestCase[] =
1174*cdf0e10cSrcweir     {
1175*cdf0e10cSrcweir         {"str1 = str7 + str8",new OString(kTestStr1),
1176*cdf0e10cSrcweir             new OString(kTestStr7), new OString(kTestStr8)},
1177*cdf0e10cSrcweir         {"str1 = str1 + '' ",new OString(kTestStr1),
1178*cdf0e10cSrcweir             new OString(kTestStr1), new OString("")},
1179*cdf0e10cSrcweir         {"str1 = '' + str1", new OString(kTestStr1),
1180*cdf0e10cSrcweir             new OString(""), new OString(kTestStr1)},
1181*cdf0e10cSrcweir         {" '' = '' + '' ", new OString(""),new OString(""),
1182*cdf0e10cSrcweir             new OString("")},
1183*cdf0e10cSrcweir         {"str1 = str1 + def.constr", new OString(kTestStr1),
1184*cdf0e10cSrcweir             new OString(kTestStr1), new OString()},
1185*cdf0e10cSrcweir         {" str1 = def.constr + str1 ",new OString(kTestStr1),
1186*cdf0e10cSrcweir             new OString(), new OString(kTestStr1)},
1187*cdf0e10cSrcweir         {" def.constr= def.constr + def.constr", new OString(),
1188*cdf0e10cSrcweir             new OString(), new OString()}
1189*cdf0e10cSrcweir     };
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir     sal_Bool res = sal_True;
1192*cdf0e10cSrcweir     sal_uInt32 i;
1193*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1194*cdf0e10cSrcweir     {
1195*cdf0e10cSrcweir         OString str = (*arrTestCase[i].input1) + (*arrTestCase[i].input2);
1196*cdf0e10cSrcweir         sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1197*cdf0e10cSrcweir 
1198*cdf0e10cSrcweir         c_rtl_tres_state
1199*cdf0e10cSrcweir         (
1200*cdf0e10cSrcweir             hRtlTestResult,
1201*cdf0e10cSrcweir             lastRes,
1202*cdf0e10cSrcweir             arrTestCase[i].comments,
1203*cdf0e10cSrcweir             createName( pMeth, "operator +", i )
1204*cdf0e10cSrcweir         );
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir         res &= lastRes;
1207*cdf0e10cSrcweir 
1208*cdf0e10cSrcweir     }
1209*cdf0e10cSrcweir 
1210*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_plus");
1211*cdf0e10cSrcweir //   return ( res );
1212*cdf0e10cSrcweir }
1213*cdf0e10cSrcweir 
1214*cdf0e10cSrcweir //------------------------------------------------------------------------
1215*cdf0e10cSrcweir // testing the operator +=
1216*cdf0e10cSrcweir //------------------------------------------------------------------------
1217*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_peq(
1218*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1219*cdf0e10cSrcweir {
1220*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1221*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "op_peq");
1224*cdf0e10cSrcweir     typedef struct TestCase
1225*cdf0e10cSrcweir     {
1226*cdf0e10cSrcweir     sal_Char*                    comments;
1227*cdf0e10cSrcweir     OString*                     expVal;
1228*cdf0e10cSrcweir     OString*                     input1;
1229*cdf0e10cSrcweir     OString*                     input2;
1230*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2; delete expVal;}
1231*cdf0e10cSrcweir     } TestCase;
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir     TestCase arrTestCase[] =
1234*cdf0e10cSrcweir     {
1235*cdf0e10cSrcweir         {"str1 == (str7 += str8)",new OString(kTestStr1),
1236*cdf0e10cSrcweir             new OString(kTestStr7), new OString(kTestStr8)},
1237*cdf0e10cSrcweir         {"str1 == (str1 += '')",new OString(kTestStr1),
1238*cdf0e10cSrcweir             new OString(kTestStr1), new OString("")},
1239*cdf0e10cSrcweir         {"str1 == ('' += str1)", new OString(kTestStr1),
1240*cdf0e10cSrcweir             new OString(""), new OString(kTestStr1)},
1241*cdf0e10cSrcweir         {" '' == ('' += '')", new OString(""),
1242*cdf0e10cSrcweir             new OString(""), new OString("")},
1243*cdf0e10cSrcweir         {"str1 == (str1 += def.constr)", new OString(kTestStr1),
1244*cdf0e10cSrcweir             new OString(kTestStr1), new OString()},
1245*cdf0e10cSrcweir         {" str1 == (def.constr += str1)",new OString(kTestStr1),
1246*cdf0e10cSrcweir             new OString(), new OString(kTestStr1)},
1247*cdf0e10cSrcweir         {" def.constr== (def.constr += def.constr)",
1248*cdf0e10cSrcweir             new OString(),new OString(), new OString()}
1249*cdf0e10cSrcweir     };
1250*cdf0e10cSrcweir 
1251*cdf0e10cSrcweir     sal_Bool res = sal_True;
1252*cdf0e10cSrcweir     sal_uInt32 i;
1253*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1254*cdf0e10cSrcweir     {   OString str;
1255*cdf0e10cSrcweir         str += (*arrTestCase[i].input1); str += (*arrTestCase[i].input2);
1256*cdf0e10cSrcweir         sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir         c_rtl_tres_state
1259*cdf0e10cSrcweir         (
1260*cdf0e10cSrcweir             hRtlTestResult,
1261*cdf0e10cSrcweir             lastRes,
1262*cdf0e10cSrcweir             arrTestCase[i].comments,
1263*cdf0e10cSrcweir             createName( pMeth, "operator +", i )
1264*cdf0e10cSrcweir         );
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir         res &= lastRes;
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir     }
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_peq");
1271*cdf0e10cSrcweir //   return ( res );
1272*cdf0e10cSrcweir }
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir //------------------------------------------------------------------------
1275*cdf0e10cSrcweir // testing the operator const sal_Char * (cscs for short)
1276*cdf0e10cSrcweir //------------------------------------------------------------------------
1277*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_cscs(
1278*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1279*cdf0e10cSrcweir {
1280*cdf0e10cSrcweir sal_Char methName[MAXBUFLENGTH];
1281*cdf0e10cSrcweir sal_Char* pMeth = methName;
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir  c_rtl_tres_state_start(hRtlTestResult, "op_cscs");
1284*cdf0e10cSrcweir typedef struct TestCase
1285*cdf0e10cSrcweir     {
1286*cdf0e10cSrcweir         sal_Char*                   comments;
1287*cdf0e10cSrcweir         const sal_Char*              expVal;
1288*cdf0e10cSrcweir         sal_Int32                    cmpLen;
1289*cdf0e10cSrcweir         OString*                    input1;
1290*cdf0e10cSrcweir         ~TestCase() { delete input1;}
1291*cdf0e10cSrcweir     } TestCase;
1292*cdf0e10cSrcweir 
1293*cdf0e10cSrcweir     TestCase arrTestCase[] =
1294*cdf0e10cSrcweir     {
1295*cdf0e10cSrcweir         {"test normal string",kTestStr1,kTestStr1Len,new OString(kTestStr1)},
1296*cdf0e10cSrcweir         {"test empty string","",1,new OString()}
1297*cdf0e10cSrcweir     };
1298*cdf0e10cSrcweir 
1299*cdf0e10cSrcweir     sal_Bool res = sal_True;
1300*cdf0e10cSrcweir     sal_uInt32 i;
1301*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1302*cdf0e10cSrcweir     {
1303*cdf0e10cSrcweir         const sal_Char* pstr = (*arrTestCase[i].input1);
1304*cdf0e10cSrcweir 
1305*cdf0e10cSrcweir         res &= c_rtl_tres_state
1306*cdf0e10cSrcweir                 (
1307*cdf0e10cSrcweir                     hRtlTestResult,
1308*cdf0e10cSrcweir                     cmpstr((sal_Char*)pstr,(sal_Char*)arrTestCase[i].expVal,
1309*cdf0e10cSrcweir                         arrTestCase[i].cmpLen),
1310*cdf0e10cSrcweir                     arrTestCase[i].comments,
1311*cdf0e10cSrcweir                     createName( pMeth, "const sal_Char*", i )
1312*cdf0e10cSrcweir                 );
1313*cdf0e10cSrcweir     }
1314*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "op_cscs");
1315*cdf0e10cSrcweir //    return ( res );
1316*cdf0e10cSrcweir }
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir //------------------------------------------------------------------------
1320*cdf0e10cSrcweir // testing the method getStr()
1321*cdf0e10cSrcweir //------------------------------------------------------------------------
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_getStr(
1325*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1326*cdf0e10cSrcweir {
1327*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1328*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1329*cdf0e10cSrcweir 
1330*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "getStr");
1331*cdf0e10cSrcweir     typedef struct TestCase
1332*cdf0e10cSrcweir     {
1333*cdf0e10cSrcweir         sal_Char*                    comments;
1334*cdf0e10cSrcweir         const sal_Char*              expVal;
1335*cdf0e10cSrcweir         sal_Int32                    cmpLen;
1336*cdf0e10cSrcweir         OString*                     input1;
1337*cdf0e10cSrcweir         ~TestCase() { delete input1;}
1338*cdf0e10cSrcweir     } TestCase;
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir     TestCase arrTestCase[] =
1341*cdf0e10cSrcweir     {
1342*cdf0e10cSrcweir         {"test normal string",kTestStr1,kTestStr1Len,new OString(kTestStr1)},
1343*cdf0e10cSrcweir         {"test empty string","",0,new OString()}
1344*cdf0e10cSrcweir     };
1345*cdf0e10cSrcweir 
1346*cdf0e10cSrcweir     sal_Bool res = sal_True;
1347*cdf0e10cSrcweir     sal_uInt32 i;
1348*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1349*cdf0e10cSrcweir     {
1350*cdf0e10cSrcweir         const sal_Char* pstr = arrTestCase[i].input1->getStr();
1351*cdf0e10cSrcweir         res &= c_rtl_tres_state
1352*cdf0e10cSrcweir                     (
1353*cdf0e10cSrcweir                         hRtlTestResult,
1354*cdf0e10cSrcweir                         cmpstr(pstr, arrTestCase[i].expVal,
1355*cdf0e10cSrcweir                             arrTestCase[i].cmpLen),
1356*cdf0e10cSrcweir                         arrTestCase[i].comments,
1357*cdf0e10cSrcweir                         createName( pMeth, "getStr", i )
1358*cdf0e10cSrcweir                     );
1359*cdf0e10cSrcweir     }
1360*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "getStr");
1361*cdf0e10cSrcweir //    return ( res );
1362*cdf0e10cSrcweir }
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir 
1366*cdf0e10cSrcweir //------------------------------------------------------------------------
1367*cdf0e10cSrcweir // testing the method copy( sal_Int32 beginIndex )
1368*cdf0e10cSrcweir //------------------------------------------------------------------------
1369*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_copy_001(
1370*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1371*cdf0e10cSrcweir {
1372*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1373*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1374*cdf0e10cSrcweir 
1375*cdf0e10cSrcweir     typedef struct TestCase
1376*cdf0e10cSrcweir     {
1377*cdf0e10cSrcweir     sal_Char*                    comments;
1378*cdf0e10cSrcweir     const sal_Char*              srcStr;
1379*cdf0e10cSrcweir     const sal_Char*              arrExpStr;
1380*cdf0e10cSrcweir                     // string for comparing with result
1381*cdf0e10cSrcweir     sal_Int32                    beginIndex;
1382*cdf0e10cSrcweir                     // beginIndex for the method copy
1383*cdf0e10cSrcweir     sal_Int32                    lengthForCmp;
1384*cdf0e10cSrcweir                     // number of symbols for comparing
1385*cdf0e10cSrcweir     // (if value is equal to 0 then pointers to buffers must be equal)
1386*cdf0e10cSrcweir     sal_Int32                    expLength;
1387*cdf0e10cSrcweir                     //expected length of the result string
1388*cdf0e10cSrcweir     } TestCase;
1389*cdf0e10cSrcweir 
1390*cdf0e10cSrcweir     TestCase arrTestCase[] =
1391*cdf0e10cSrcweir     {
1392*cdf0e10cSrcweir         {"beginIndex == 0 ( whole string )", kTestStr2,kTestStr2,
1393*cdf0e10cSrcweir          0, kTestStr2Len, kTestStr2Len},
1394*cdf0e10cSrcweir         {"beginIndex == strlen-2 ( last two char )",  kTestStr2,"gy",
1395*cdf0e10cSrcweir                     kTestStr2Len-2, 2, 2},
1396*cdf0e10cSrcweir         {"beginIndex == strlen-1( last char )", kTestStr2, "y",
1397*cdf0e10cSrcweir             kTestStr2Len-1, 1, 1}
1398*cdf0e10cSrcweir     };
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir     sal_Bool res = sal_True;
1401*cdf0e10cSrcweir     sal_uInt32 i;
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir     for(i = 0; i <(sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1404*cdf0e10cSrcweir     {
1405*cdf0e10cSrcweir         OString src(arrTestCase[i].srcStr);
1406*cdf0e10cSrcweir         OString dst;
1407*cdf0e10cSrcweir         // rtl_String* pDataSrc = src.pData;
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir         dst = src.copy(arrTestCase[i].beginIndex);
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir         // rtl_String* pDataDst = dst.pData;
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir         sal_Bool lastRes;
1414*cdf0e10cSrcweir 
1415*cdf0e10cSrcweir         lastRes= (dst== arrTestCase[i].arrExpStr);
1416*cdf0e10cSrcweir 
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir         c_rtl_tres_state
1419*cdf0e10cSrcweir         (
1420*cdf0e10cSrcweir             hRtlTestResult,
1421*cdf0e10cSrcweir             lastRes,
1422*cdf0e10cSrcweir             arrTestCase[i].comments,
1423*cdf0e10cSrcweir             createName( pMeth,
1424*cdf0e10cSrcweir                 "copy_001(beginIndex)(check buffer and length)", i )
1425*cdf0e10cSrcweir         );
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir         res &= lastRes;
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir     }
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir     return (res);
1432*cdf0e10cSrcweir }
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir 
1435*cdf0e10cSrcweir //------------------------------------------------------------------------
1436*cdf0e10cSrcweir // testing the method copy( sal_Int32 beginIndex, sal_Int32 count )
1437*cdf0e10cSrcweir //------------------------------------------------------------------------
1438*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_copy_002(
1439*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1440*cdf0e10cSrcweir {
1441*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1442*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir     typedef struct TestCase
1445*cdf0e10cSrcweir     {
1446*cdf0e10cSrcweir     sal_Char*               comments;
1447*cdf0e10cSrcweir     const sal_Char*          arrExpStr;
1448*cdf0e10cSrcweir     sal_Int32                beginIndex;
1449*cdf0e10cSrcweir     sal_Int32                count;
1450*cdf0e10cSrcweir     sal_Int32                expLen;
1451*cdf0e10cSrcweir 
1452*cdf0e10cSrcweir     } TestCase;
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir     TestCase arrTestCase[] ={
1455*cdf0e10cSrcweir 
1456*cdf0e10cSrcweir         {"copy substring",                            kTestStr6, kTestStr11Len, kTestStr2Len - kTestStr11Len,kTestStr6Len},
1457*cdf0e10cSrcweir         /* LLA: it is a bug, beginIndex + count > kTestStr2.getLength() */
1458*cdf0e10cSrcweir         /* {"copy normal substring with incorrect count",kTestStr6, kTestStr11Len, 31, 15}, */
1459*cdf0e10cSrcweir         {"copy whole string", kTestStr2, 0, kTestStr2Len, kTestStr2Len},
1460*cdf0e10cSrcweir         /* {"copy whole string with incorrect count larger than len and index 0", kTestStr2, 0, 40, 32}, */
1461*cdf0e10cSrcweir         /* LLA: bug beginIndex + count > kTestStr2 {"copy last character",                                               "y",kTestStr2Len - 1, 31,1}, */
1462*cdf0e10cSrcweir         {"copy last character",                                               "y",kTestStr2Len - 1, 1,1},
1463*cdf0e10cSrcweir         /* LLA: bug, beginIndex > kTestStr2 {"beginindex larger than len","",60, 0,0}, */
1464*cdf0e10cSrcweir         {"beginindex exact as large as it's length","",kTestStr2Len, 0,0}
1465*cdf0e10cSrcweir         /* LLA: bug, negative count is not allowed. {"count is nagative int","",3, -1,0} */
1466*cdf0e10cSrcweir     };
1467*cdf0e10cSrcweir     sal_Bool res = sal_True;
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir     sal_uInt32 i;
1470*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) {
1471*cdf0e10cSrcweir         OString src(kTestStr2);
1472*cdf0e10cSrcweir         OString dst;
1473*cdf0e10cSrcweir         dst = src.copy(arrTestCase[i].beginIndex, arrTestCase[i].count);
1474*cdf0e10cSrcweir         // rtl_String* pDataSrc = src.pData;
1475*cdf0e10cSrcweir         // rtl_String* pDataDst = dst.pData;
1476*cdf0e10cSrcweir 
1477*cdf0e10cSrcweir         sal_Bool lastRes=sal_True;
1478*cdf0e10cSrcweir         // checks buffer and length
1479*cdf0e10cSrcweir         //t_print("this is copy__002 #%d\n", i);
1480*cdf0e10cSrcweir         //t_print("dst buffer =%s\n", pDataDst->buffer);
1481*cdf0e10cSrcweir         //t_print("expStr =%s\n", arrTestCase[i].arrExpStr);
1482*cdf0e10cSrcweir         //t_print("dst length =%d\n", pDataDst->length);
1483*cdf0e10cSrcweir         //t_print("count =%d\n", arrTestCase[i].count);
1484*cdf0e10cSrcweir         //t_print("expLen =%d\n", arrTestCase[i].expLen);
1485*cdf0e10cSrcweir 
1486*cdf0e10cSrcweir         lastRes = (dst.equals(arrTestCase[i].arrExpStr)) ? sal_True : sal_False;
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir         c_rtl_tres_state
1489*cdf0e10cSrcweir         (
1490*cdf0e10cSrcweir             hRtlTestResult,
1491*cdf0e10cSrcweir             lastRes,
1492*cdf0e10cSrcweir             arrTestCase[i].comments,
1493*cdf0e10cSrcweir             createName( pMeth,
1494*cdf0e10cSrcweir                 "copy_002(beginIndex,count)(check buffer and length)", i)
1495*cdf0e10cSrcweir         );
1496*cdf0e10cSrcweir         res &= lastRes;
1497*cdf0e10cSrcweir 
1498*cdf0e10cSrcweir 
1499*cdf0e10cSrcweir     }
1500*cdf0e10cSrcweir 
1501*cdf0e10cSrcweir     return (res);
1502*cdf0e10cSrcweir }
1503*cdf0e10cSrcweir 
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_copy_003(
1506*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1507*cdf0e10cSrcweir {
1508*cdf0e10cSrcweir     sal_Bool res = sal_True;
1509*cdf0e10cSrcweir     char comment[] = "copy whole short string to long string";
1510*cdf0e10cSrcweir 
1511*cdf0e10cSrcweir     OString src(kTestStr1);
1512*cdf0e10cSrcweir     // rtl_String* pDataSrc = src.pData;
1513*cdf0e10cSrcweir     OString dst(kTestStr2);
1514*cdf0e10cSrcweir 
1515*cdf0e10cSrcweir     dst = src.copy(0);
1516*cdf0e10cSrcweir     // rtl_String* pDataDst = dst.pData;
1517*cdf0e10cSrcweir     //check buffer and length
1518*cdf0e10cSrcweir     sal_Bool lastRes =(dst==src);
1519*cdf0e10cSrcweir     c_rtl_tres_state
1520*cdf0e10cSrcweir     (
1521*cdf0e10cSrcweir         hRtlTestResult,
1522*cdf0e10cSrcweir         lastRes,
1523*cdf0e10cSrcweir         comment,
1524*cdf0e10cSrcweir         "copy_003(beginIndex)(check buffer and length)"
1525*cdf0e10cSrcweir     );
1526*cdf0e10cSrcweir     res &= lastRes;
1527*cdf0e10cSrcweir 
1528*cdf0e10cSrcweir     return (res);
1529*cdf0e10cSrcweir }
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir 
1532*cdf0e10cSrcweir static sal_Bool SAL_CALL test_rtl_OString_copy_004(
1533*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1534*cdf0e10cSrcweir {
1535*cdf0e10cSrcweir     sal_Bool res = sal_True;
1536*cdf0e10cSrcweir     sal_Char comment[] = "copy whole long string to short string";
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir     OString src(kTestStr2);
1539*cdf0e10cSrcweir     // rtl_String* pDataSrc = src.pData;
1540*cdf0e10cSrcweir     OString dst(kTestStr1);
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir     dst = src.copy(0);
1543*cdf0e10cSrcweir     // rtl_String* pDataDst = dst.pData;
1544*cdf0e10cSrcweir     //check buffer and length
1545*cdf0e10cSrcweir     sal_Bool lastRes =(dst==src);
1546*cdf0e10cSrcweir     c_rtl_tres_state
1547*cdf0e10cSrcweir     (
1548*cdf0e10cSrcweir         hRtlTestResult,
1549*cdf0e10cSrcweir         lastRes,
1550*cdf0e10cSrcweir         comment,
1551*cdf0e10cSrcweir         "copy_004(beginIndex)(check buffer and length)"
1552*cdf0e10cSrcweir     );
1553*cdf0e10cSrcweir 
1554*cdf0e10cSrcweir     res &= lastRes;
1555*cdf0e10cSrcweir     return (res);
1556*cdf0e10cSrcweir }
1557*cdf0e10cSrcweir 
1558*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_copy(
1559*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1560*cdf0e10cSrcweir {
1561*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "copy");
1562*cdf0e10cSrcweir     sal_Bool res = test_rtl_OString_copy_001(hRtlTestResult);
1563*cdf0e10cSrcweir     res &= test_rtl_OString_copy_002(hRtlTestResult);
1564*cdf0e10cSrcweir     res &= test_rtl_OString_copy_003(hRtlTestResult);
1565*cdf0e10cSrcweir     res &= test_rtl_OString_copy_004(hRtlTestResult);
1566*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "copy");
1567*cdf0e10cSrcweir 
1568*cdf0e10cSrcweir //    return ( res );
1569*cdf0e10cSrcweir }
1570*cdf0e10cSrcweir 
1571*cdf0e10cSrcweir //------------------------------------------------------------------------
1572*cdf0e10cSrcweir // testing the method concat( const OString & aStr )
1573*cdf0e10cSrcweir //------------------------------------------------------------------------
1574*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_concat(
1575*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1576*cdf0e10cSrcweir {
1577*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1578*cdf0e10cSrcweir     sal_Char* pMeth =methName;
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "concat");
1581*cdf0e10cSrcweir     typedef struct TestCase
1582*cdf0e10cSrcweir     {
1583*cdf0e10cSrcweir     sal_Char*                    comments;
1584*cdf0e10cSrcweir     OString*                     expVal;
1585*cdf0e10cSrcweir     OString*                     input1;
1586*cdf0e10cSrcweir     OString*                     input2;
1587*cdf0e10cSrcweir     ~TestCase() { delete input1;delete input2; delete expVal;}
1588*cdf0e10cSrcweir     } TestCase;
1589*cdf0e10cSrcweir 
1590*cdf0e10cSrcweir     TestCase arrTestCase[] =
1591*cdf0e10cSrcweir     {
1592*cdf0e10cSrcweir         {"concatenates two strings",new OString(kTestStr1),
1593*cdf0e10cSrcweir             new OString(kTestStr7),
1594*cdf0e10cSrcweir             new OString(kTestStr8)},
1595*cdf0e10cSrcweir         {"concatenates empty string",new OString(kTestStr1),
1596*cdf0e10cSrcweir             new OString(kTestStr1),
1597*cdf0e10cSrcweir             new OString("")},
1598*cdf0e10cSrcweir         {"concatenates to empty string",new OString(kTestStr1),
1599*cdf0e10cSrcweir             new OString(""),
1600*cdf0e10cSrcweir             new OString(kTestStr1)},
1601*cdf0e10cSrcweir         {"concatenates two empty strings",new OString(""),new OString(""),
1602*cdf0e10cSrcweir              new OString("")},
1603*cdf0e10cSrcweir         {"concatenates string constructed by default constructor",
1604*cdf0e10cSrcweir             new OString(kTestStr1),
1605*cdf0e10cSrcweir             new OString(kTestStr1), new OString()},
1606*cdf0e10cSrcweir         {"concatenates to string constructed by default constructor",
1607*cdf0e10cSrcweir             new OString(kTestStr1),
1608*cdf0e10cSrcweir             new OString(), new OString(kTestStr1)},
1609*cdf0e10cSrcweir         {"concatenates two strings constructed by default constructor",
1610*cdf0e10cSrcweir             new OString(),
1611*cdf0e10cSrcweir             new OString(), new OString()}
1612*cdf0e10cSrcweir     };
1613*cdf0e10cSrcweir 
1614*cdf0e10cSrcweir     sal_Bool res = sal_True;
1615*cdf0e10cSrcweir     sal_uInt32 i;
1616*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1617*cdf0e10cSrcweir     {
1618*cdf0e10cSrcweir         OString str =
1619*cdf0e10cSrcweir             arrTestCase[i].input1->concat(*arrTestCase[i].input2);
1620*cdf0e10cSrcweir         sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1621*cdf0e10cSrcweir 
1622*cdf0e10cSrcweir         c_rtl_tres_state
1623*cdf0e10cSrcweir         (
1624*cdf0e10cSrcweir             hRtlTestResult,
1625*cdf0e10cSrcweir             lastRes,
1626*cdf0e10cSrcweir             arrTestCase[i].comments,
1627*cdf0e10cSrcweir             createName( pMeth, "concat", i)
1628*cdf0e10cSrcweir         );
1629*cdf0e10cSrcweir 
1630*cdf0e10cSrcweir         res &= lastRes;
1631*cdf0e10cSrcweir 
1632*cdf0e10cSrcweir      }
1633*cdf0e10cSrcweir 
1634*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "concat");
1635*cdf0e10cSrcweir //    return ( res );
1636*cdf0e10cSrcweir }
1637*cdf0e10cSrcweir 
1638*cdf0e10cSrcweir 
1639*cdf0e10cSrcweir //------------------------------------------------------------------------
1640*cdf0e10cSrcweir // testing the method toAsciiLowerCase()
1641*cdf0e10cSrcweir //-----------------------------------------------------------------------
1642*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toAsciiLowerCase(
1643*cdf0e10cSrcweir                                       hTestResult hRtlTestResult )
1644*cdf0e10cSrcweir {
1645*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1646*cdf0e10cSrcweir     sal_Char* pMeth =methName;
1647*cdf0e10cSrcweir 
1648*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toAsciiLowerCase");
1649*cdf0e10cSrcweir     typedef struct TestCase
1650*cdf0e10cSrcweir     {
1651*cdf0e10cSrcweir     sal_Char*                    comments;
1652*cdf0e10cSrcweir     OString*                     expVal;
1653*cdf0e10cSrcweir     OString*                     input1;
1654*cdf0e10cSrcweir     ~TestCase() { delete input1; delete expVal;}
1655*cdf0e10cSrcweir     } TestCase;
1656*cdf0e10cSrcweir 
1657*cdf0e10cSrcweir     TestCase arrTestCase[] =
1658*cdf0e10cSrcweir     {
1659*cdf0e10cSrcweir 
1660*cdf0e10cSrcweir         {"only uppercase",new OString(kTestStr5),new OString(kTestStr4)},
1661*cdf0e10cSrcweir         {"different cases",new OString(kTestStr5),new OString(kTestStr1)},
1662*cdf0e10cSrcweir         {"different cases",new OString(kTestStr5),new OString(kTestStr3)},
1663*cdf0e10cSrcweir         {"only lowercase",new OString(kTestStr5),new OString(kTestStr5)},
1664*cdf0e10cSrcweir         {"empty string",new OString(""),new OString("")},
1665*cdf0e10cSrcweir         {"string constructed by default constructor",
1666*cdf0e10cSrcweir             new OString(),new OString()}
1667*cdf0e10cSrcweir     };
1668*cdf0e10cSrcweir 
1669*cdf0e10cSrcweir     sal_Bool res = sal_True;
1670*cdf0e10cSrcweir     sal_uInt32 i;
1671*cdf0e10cSrcweir 
1672*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1673*cdf0e10cSrcweir     {
1674*cdf0e10cSrcweir         OString str = arrTestCase[i].input1->toAsciiLowerCase();
1675*cdf0e10cSrcweir         sal_Bool lastRes = (str ==* arrTestCase[i].expVal);
1676*cdf0e10cSrcweir 
1677*cdf0e10cSrcweir         c_rtl_tres_state
1678*cdf0e10cSrcweir         (
1679*cdf0e10cSrcweir             hRtlTestResult,
1680*cdf0e10cSrcweir             lastRes,
1681*cdf0e10cSrcweir             arrTestCase[i].comments,
1682*cdf0e10cSrcweir             createName( pMeth, "toAsciiLowerCase", i)
1683*cdf0e10cSrcweir         );
1684*cdf0e10cSrcweir 
1685*cdf0e10cSrcweir         res &= lastRes;
1686*cdf0e10cSrcweir     }
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toAsciiLowerCase");
1689*cdf0e10cSrcweir //    return ( res );
1690*cdf0e10cSrcweir }
1691*cdf0e10cSrcweir 
1692*cdf0e10cSrcweir //------------------------------------------------------------------------
1693*cdf0e10cSrcweir // testing the method toAsciiUpperCase()
1694*cdf0e10cSrcweir //------------------------------------------------------------------------
1695*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toAsciiUpperCase(
1696*cdf0e10cSrcweir                                             hTestResult hRtlTestResult )
1697*cdf0e10cSrcweir {
1698*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1699*cdf0e10cSrcweir     sal_Char* pMeth =methName;
1700*cdf0e10cSrcweir 
1701*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toAsciiUpperCase");
1702*cdf0e10cSrcweir     typedef struct TestCase
1703*cdf0e10cSrcweir     {
1704*cdf0e10cSrcweir     sal_Char*                    comments;
1705*cdf0e10cSrcweir     OString*                     expVal;
1706*cdf0e10cSrcweir     OString*                     input1;
1707*cdf0e10cSrcweir     ~TestCase() { delete input1; delete expVal;}
1708*cdf0e10cSrcweir     } TestCase;
1709*cdf0e10cSrcweir 
1710*cdf0e10cSrcweir     TestCase arrTestCase[] =
1711*cdf0e10cSrcweir     {
1712*cdf0e10cSrcweir         {"only lowercase",new OString(kTestStr4),new OString(kTestStr5)},
1713*cdf0e10cSrcweir         {"mixed cases",new OString(kTestStr4),new OString(kTestStr3)},
1714*cdf0e10cSrcweir         {"miced cases",new OString(kTestStr4),new OString(kTestStr1)},
1715*cdf0e10cSrcweir         {"only uppercase",new OString(kTestStr4),new OString(kTestStr4)},
1716*cdf0e10cSrcweir         {"empty string",new OString(""),new OString("")},
1717*cdf0e10cSrcweir         {"string constructed by default constructor",
1718*cdf0e10cSrcweir             new OString(),new OString()}
1719*cdf0e10cSrcweir     };
1720*cdf0e10cSrcweir 
1721*cdf0e10cSrcweir     sal_Bool res = sal_True;
1722*cdf0e10cSrcweir     sal_uInt32 i;
1723*cdf0e10cSrcweir 
1724*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1725*cdf0e10cSrcweir     {
1726*cdf0e10cSrcweir         OString str = arrTestCase[i].input1->toAsciiUpperCase();
1727*cdf0e10cSrcweir         sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir         c_rtl_tres_state
1730*cdf0e10cSrcweir         (
1731*cdf0e10cSrcweir             hRtlTestResult,
1732*cdf0e10cSrcweir             lastRes,
1733*cdf0e10cSrcweir             arrTestCase[i].comments,
1734*cdf0e10cSrcweir             createName( pMeth, "toAsciiLowerCase", i)
1735*cdf0e10cSrcweir         );
1736*cdf0e10cSrcweir 
1737*cdf0e10cSrcweir         res &= lastRes;
1738*cdf0e10cSrcweir     }
1739*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toAsciiUpperCase");
1740*cdf0e10cSrcweir 
1741*cdf0e10cSrcweir //    return ( res );
1742*cdf0e10cSrcweir }
1743*cdf0e10cSrcweir 
1744*cdf0e10cSrcweir 
1745*cdf0e10cSrcweir //------------------------------------------------------------------------
1746*cdf0e10cSrcweir // testing the method trim()
1747*cdf0e10cSrcweir //------------------------------------------------------------------------
1748*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_trim(
1749*cdf0e10cSrcweir                                            hTestResult hRtlTestResult )
1750*cdf0e10cSrcweir {
1751*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1752*cdf0e10cSrcweir     sal_Char* pMeth =methName;
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "trim");
1755*cdf0e10cSrcweir     typedef struct TestCase
1756*cdf0e10cSrcweir     {
1757*cdf0e10cSrcweir     sal_Char*                    comments;
1758*cdf0e10cSrcweir     OString*                     expVal;
1759*cdf0e10cSrcweir     OString*                     input1;
1760*cdf0e10cSrcweir     ~TestCase() { delete input1; delete expVal;}
1761*cdf0e10cSrcweir     } TestCase;
1762*cdf0e10cSrcweir 
1763*cdf0e10cSrcweir     TestCase arrTestCase[] =
1764*cdf0e10cSrcweir     {
1765*cdf0e10cSrcweir         {"removes space from the front",new OString(kTestStr1),
1766*cdf0e10cSrcweir             new OString(kTestStr10)},
1767*cdf0e10cSrcweir         {"removes space from the end",new OString(kTestStr1),
1768*cdf0e10cSrcweir             new OString(kTestStr11)},
1769*cdf0e10cSrcweir         {"removes space from the front and end",new OString(kTestStr1),
1770*cdf0e10cSrcweir             new OString(kTestStr12)},
1771*cdf0e10cSrcweir         {"removes several spaces from the end",new OString(kTestStr1),
1772*cdf0e10cSrcweir             new OString(kTestStr13)},
1773*cdf0e10cSrcweir         {"removes several spaces from the front",new OString(kTestStr1),
1774*cdf0e10cSrcweir             new OString(kTestStr14)},
1775*cdf0e10cSrcweir         {"removes several spaces from the front and one from the end",
1776*cdf0e10cSrcweir             new OString(kTestStr1),
1777*cdf0e10cSrcweir             new OString(kTestStr15)},
1778*cdf0e10cSrcweir         {"removes one space from the front and several from the end",
1779*cdf0e10cSrcweir             new OString(kTestStr1),
1780*cdf0e10cSrcweir             new OString(kTestStr16)},
1781*cdf0e10cSrcweir         {"removes several spaces from the front and end",
1782*cdf0e10cSrcweir             new OString(kTestStr1),
1783*cdf0e10cSrcweir             new OString(kTestStr17)},
1784*cdf0e10cSrcweir         {"removes characters that have codes <= 32",new OString(kTestStr20),
1785*cdf0e10cSrcweir             new OString("\1\3\5\7\11\13\15\17sun\21\23\25\27\31\33\40")},
1786*cdf0e10cSrcweir         {"no spaces",new OString(kTestStr8),new OString(kTestStr8)}
1787*cdf0e10cSrcweir     };
1788*cdf0e10cSrcweir 
1789*cdf0e10cSrcweir     sal_Bool res = sal_True;
1790*cdf0e10cSrcweir     sal_uInt32 i;
1791*cdf0e10cSrcweir 
1792*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1793*cdf0e10cSrcweir     {
1794*cdf0e10cSrcweir         OString strRes = arrTestCase[i].input1->trim();
1795*cdf0e10cSrcweir         sal_Bool lastRes = (strRes == *arrTestCase[i].expVal);
1796*cdf0e10cSrcweir 
1797*cdf0e10cSrcweir         c_rtl_tres_state
1798*cdf0e10cSrcweir         (
1799*cdf0e10cSrcweir             hRtlTestResult,
1800*cdf0e10cSrcweir             lastRes,
1801*cdf0e10cSrcweir             arrTestCase[i].comments,
1802*cdf0e10cSrcweir             createName( pMeth, "trim", i)
1803*cdf0e10cSrcweir         );
1804*cdf0e10cSrcweir 
1805*cdf0e10cSrcweir         res &= lastRes;
1806*cdf0e10cSrcweir 
1807*cdf0e10cSrcweir     }
1808*cdf0e10cSrcweir 
1809*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "trim");
1810*cdf0e10cSrcweir //    return ( res );
1811*cdf0e10cSrcweir }
1812*cdf0e10cSrcweir 
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir 
1815*cdf0e10cSrcweir //------------------------------------------------------------------------
1816*cdf0e10cSrcweir // testing the method valueOf( sal_Bool b )
1817*cdf0e10cSrcweir //------------------------------------------------------------------------
1818*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_sal_Bool(
1819*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1820*cdf0e10cSrcweir {
1821*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1822*cdf0e10cSrcweir     sal_Char* pMeth =methName;
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir     typedef struct TestCase
1825*cdf0e10cSrcweir     {
1826*cdf0e10cSrcweir     sal_Char*                    comments;
1827*cdf0e10cSrcweir     sal_Bool                     input1;
1828*cdf0e10cSrcweir     OString*                     expVal;
1829*cdf0e10cSrcweir     ~TestCase() {delete expVal;}
1830*cdf0e10cSrcweir     } TestCase;
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir     TestCase arrTestCase[] =
1833*cdf0e10cSrcweir     {
1834*cdf0e10cSrcweir         {"true",sal_True,new OString("true")},
1835*cdf0e10cSrcweir         {"false",sal_False, new OString("false")}
1836*cdf0e10cSrcweir     };
1837*cdf0e10cSrcweir 
1838*cdf0e10cSrcweir     sal_Bool res = sal_True;
1839*cdf0e10cSrcweir     sal_uInt32 i;
1840*cdf0e10cSrcweir 
1841*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1842*cdf0e10cSrcweir     {
1843*cdf0e10cSrcweir         ::rtl::OString aStr1;
1844*cdf0e10cSrcweir         aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
1845*cdf0e10cSrcweir         sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
1846*cdf0e10cSrcweir 
1847*cdf0e10cSrcweir         c_rtl_tres_state
1848*cdf0e10cSrcweir         (
1849*cdf0e10cSrcweir             hRtlTestResult,
1850*cdf0e10cSrcweir             lastRes,
1851*cdf0e10cSrcweir             arrTestCase[i].comments,
1852*cdf0e10cSrcweir             createName( pMeth, "valueof_bool", i)
1853*cdf0e10cSrcweir         );
1854*cdf0e10cSrcweir 
1855*cdf0e10cSrcweir         res &= lastRes;
1856*cdf0e10cSrcweir 
1857*cdf0e10cSrcweir     }
1858*cdf0e10cSrcweir 
1859*cdf0e10cSrcweir     return ( res );
1860*cdf0e10cSrcweir }
1861*cdf0e10cSrcweir 
1862*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_sal_Char(
1863*cdf0e10cSrcweir                     hTestResult hRtlTestResult )
1864*cdf0e10cSrcweir {
1865*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1866*cdf0e10cSrcweir     sal_Char* pMeth =methName;
1867*cdf0e10cSrcweir 
1868*cdf0e10cSrcweir     typedef struct TestCase
1869*cdf0e10cSrcweir     {
1870*cdf0e10cSrcweir     sal_Char*                    comments;
1871*cdf0e10cSrcweir     sal_Char                     input1;
1872*cdf0e10cSrcweir     OString*                     expVal;
1873*cdf0e10cSrcweir     ~TestCase() {delete expVal;}
1874*cdf0e10cSrcweir     } TestCase;
1875*cdf0e10cSrcweir 
1876*cdf0e10cSrcweir     TestCase arrTestCase[] =
1877*cdf0e10cSrcweir     {
1878*cdf0e10cSrcweir         {"A",'A',new OString("A")},
1879*cdf0e10cSrcweir         {"a",'a', new OString("a")},
1880*cdf0e10cSrcweir         {"0",'0', new OString("0")},
1881*cdf0e10cSrcweir         {"-",'-', new OString("-")},
1882*cdf0e10cSrcweir         {"_",'_', new OString("_")},
1883*cdf0e10cSrcweir         {"|",'|', new OString("|")},
1884*cdf0e10cSrcweir         {"?",'?', new OString("?")},
1885*cdf0e10cSrcweir         {"?",'?', new OString("?")},
1886*cdf0e10cSrcweir         {"\n",'\n', new OString("\n")},
1887*cdf0e10cSrcweir         {"\'",'\'', new OString("\'")},
1888*cdf0e10cSrcweir         {"\"",'\"', new OString("\"")}
1889*cdf0e10cSrcweir 
1890*cdf0e10cSrcweir     };
1891*cdf0e10cSrcweir 
1892*cdf0e10cSrcweir     sal_Bool res = sal_True;
1893*cdf0e10cSrcweir     sal_uInt32 i;
1894*cdf0e10cSrcweir 
1895*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1896*cdf0e10cSrcweir     {
1897*cdf0e10cSrcweir         ::rtl::OString aStr1;
1898*cdf0e10cSrcweir         aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
1899*cdf0e10cSrcweir         sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
1900*cdf0e10cSrcweir 
1901*cdf0e10cSrcweir         c_rtl_tres_state
1902*cdf0e10cSrcweir         (
1903*cdf0e10cSrcweir             hRtlTestResult,
1904*cdf0e10cSrcweir             lastRes,
1905*cdf0e10cSrcweir             arrTestCase[i].comments,
1906*cdf0e10cSrcweir             createName( pMeth, "valueof_char", i)
1907*cdf0e10cSrcweir         );
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir         res &= lastRes;
1910*cdf0e10cSrcweir 
1911*cdf0e10cSrcweir     }
1912*cdf0e10cSrcweir 
1913*cdf0e10cSrcweir     return ( res );
1914*cdf0e10cSrcweir }
1915*cdf0e10cSrcweir 
1916*cdf0e10cSrcweir /**
1917*cdf0e10cSrcweir  * Calls the method valueOf(T, radix) and compares
1918*cdf0e10cSrcweir  * returned strings with strings that passed in the array resArray.
1919*cdf0e10cSrcweir  *
1920*cdf0e10cSrcweir  * @param T, type of argument, passed to valueOf
1921*cdf0e10cSrcweir  * @param resArray, array of result strings to compare to
1922*cdf0e10cSrcweir  * @param n the number of elements in the array resArray (testcases)
1923*cdf0e10cSrcweir  * @param pTestResult the instance of the class TestResult
1924*cdf0e10cSrcweir  * @param inArray [optional], array of value that is passed as first argument
1925*cdf0e10cSrcweir  *                            to valueOf
1926*cdf0e10cSrcweir  *
1927*cdf0e10cSrcweir  * @return true, if all returned strings are equal to corresponding string in
1928*cdf0e10cSrcweir  *               resArray else, false.
1929*cdf0e10cSrcweir  */
1930*cdf0e10cSrcweir template <class T>
1931*cdf0e10cSrcweir sal_Bool test_valueOf( const char** resArray, int n, sal_Int16 radix,
1932*cdf0e10cSrcweir                             hTestResult hRtlTestResult, const T *inArray )
1933*cdf0e10cSrcweir {
1934*cdf0e10cSrcweir     sal_Bool bRes = sal_True;
1935*cdf0e10cSrcweir 
1936*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
1937*cdf0e10cSrcweir     sal_Char* pMeth = methName;
1938*cdf0e10cSrcweir     sal_Int32 i;
1939*cdf0e10cSrcweir 
1940*cdf0e10cSrcweir     for (i = 0; i < n; i++)
1941*cdf0e10cSrcweir     {
1942*cdf0e10cSrcweir         ::rtl::OString aStr1;
1943*cdf0e10cSrcweir         ::rtl::OString aStr2( resArray[i] );
1944*cdf0e10cSrcweir 
1945*cdf0e10cSrcweir         if (inArray == 0)
1946*cdf0e10cSrcweir             aStr1 = ::rtl::OString::valueOf((T)i, radix);
1947*cdf0e10cSrcweir         else
1948*cdf0e10cSrcweir         {
1949*cdf0e10cSrcweir             if ( inArray[i] < 0 )
1950*cdf0e10cSrcweir             {
1951*cdf0e10cSrcweir                 aStr2 = "-";
1952*cdf0e10cSrcweir                 aStr2 += resArray[i];
1953*cdf0e10cSrcweir             }
1954*cdf0e10cSrcweir             aStr1 = ::rtl::OString::valueOf((T)inArray[i], radix);
1955*cdf0e10cSrcweir         }
1956*cdf0e10cSrcweir 
1957*cdf0e10cSrcweir         bRes &= c_rtl_tres_state
1958*cdf0e10cSrcweir                 (
1959*cdf0e10cSrcweir                     hRtlTestResult,
1960*cdf0e10cSrcweir                     aStr2.compareTo(aStr1) == 0,
1961*cdf0e10cSrcweir                     (sal_Char*)resArray[i],
1962*cdf0e10cSrcweir                     createName( pMeth, "valueOf", i )
1963*cdf0e10cSrcweir                 );
1964*cdf0e10cSrcweir     }
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir     return (bRes);
1967*cdf0e10cSrcweir }
1968*cdf0e10cSrcweir 
1969*cdf0e10cSrcweir 
1970*cdf0e10cSrcweir #define test_valueOf_Int32      test_valueOf<sal_Int32>
1971*cdf0e10cSrcweir #define test_valueOf_Int64      test_valueOf<sal_Int64>
1972*cdf0e10cSrcweir // LLA: #define test_valueOf_float      test_valueOf<float>
1973*cdf0e10cSrcweir // LLA: #define test_valueOf_double     test_valueOf<double>
1974*cdf0e10cSrcweir 
1975*cdf0e10cSrcweir //------------------------------------------------------------------------
1976*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=2 )
1977*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=8 )
1978*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=10 )
1979*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=16 )
1980*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=36 )
1981*cdf0e10cSrcweir //------------------------------------------------------------------------
1982*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32(
1983*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
1984*cdf0e10cSrcweir {
1985*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
1986*cdf0e10cSrcweir 
1987*cdf0e10cSrcweir     bRes = c_rtl_tres_state
1988*cdf0e10cSrcweir             (
1989*cdf0e10cSrcweir                 hRtlTestResult,
1990*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kBinaryNumsStr,
1991*cdf0e10cSrcweir                         kBinaryNumsCount, kRadixBinary, hRtlTestResult, 0 ),
1992*cdf0e10cSrcweir                 "kRadixBinary",
1993*cdf0e10cSrcweir                 "valueOf(sal_Int32, radix 2)"
1994*cdf0e10cSrcweir             );
1995*cdf0e10cSrcweir 
1996*cdf0e10cSrcweir 
1997*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
1998*cdf0e10cSrcweir             (
1999*cdf0e10cSrcweir                 hRtlTestResult,
2000*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kOctolNumsStr,
2001*cdf0e10cSrcweir                         kOctolNumsCount, kRadixOctol, hRtlTestResult, 0),
2002*cdf0e10cSrcweir                 "kRadixOctol",
2003*cdf0e10cSrcweir                 "valueOf(sal_Int32, radix 8)"
2004*cdf0e10cSrcweir             );
2005*cdf0e10cSrcweir 
2006*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2007*cdf0e10cSrcweir             (
2008*cdf0e10cSrcweir                 hRtlTestResult,
2009*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kDecimalNumsStr,
2010*cdf0e10cSrcweir                         kDecimalNumsCount, kRadixDecimal, hRtlTestResult, 0),
2011*cdf0e10cSrcweir                 "kRadixDecimal",
2012*cdf0e10cSrcweir                 "valueOf(sal_Int32, radix 10)"
2013*cdf0e10cSrcweir             );
2014*cdf0e10cSrcweir 
2015*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2016*cdf0e10cSrcweir             (
2017*cdf0e10cSrcweir                 hRtlTestResult,
2018*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kHexDecimalNumsStr,
2019*cdf0e10cSrcweir                 kHexDecimalNumsCount, kRadixHexdecimal, hRtlTestResult, 0),
2020*cdf0e10cSrcweir                 "kRadixHexdecimal",
2021*cdf0e10cSrcweir                 "valueOf(sal_Int32, radix 16)"
2022*cdf0e10cSrcweir             );
2023*cdf0e10cSrcweir 
2024*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2025*cdf0e10cSrcweir             (
2026*cdf0e10cSrcweir                 hRtlTestResult,
2027*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kBase36NumsStr,
2028*cdf0e10cSrcweir                         kBase36NumsCount, kRadixBase36, hRtlTestResult, 0),
2029*cdf0e10cSrcweir                 "kRadixBase36",
2030*cdf0e10cSrcweir                 "valueOf(sal_Int32, radix 36)"
2031*cdf0e10cSrcweir             );
2032*cdf0e10cSrcweir 
2033*cdf0e10cSrcweir 
2034*cdf0e10cSrcweir     return ( bRes );
2035*cdf0e10cSrcweir }
2036*cdf0e10cSrcweir 
2037*cdf0e10cSrcweir //------------------------------------------------------------------------
2038*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix=2 )
2039*cdf0e10cSrcweir // where l = large constants
2040*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix=8 )
2041*cdf0e10cSrcweir // where l = large constants
2042*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix=10 )
2043*cdf0e10cSrcweir // where l = large constants
2044*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix=16 )
2045*cdf0e10cSrcweir // where l = large constants
2046*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix=36 )
2047*cdf0e10cSrcweir // where l = large constants
2048*cdf0e10cSrcweir //------------------------------------------------------------------------
2049*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_Bounderies(
2050*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2051*cdf0e10cSrcweir {
2052*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2053*cdf0e10cSrcweir 
2054*cdf0e10cSrcweir     bRes =  c_rtl_tres_state
2055*cdf0e10cSrcweir             (
2056*cdf0e10cSrcweir                 hRtlTestResult,
2057*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kBinaryMaxNumsStr,
2058*cdf0e10cSrcweir                 kInt32MaxNumsCount, kRadixBinary, hRtlTestResult,
2059*cdf0e10cSrcweir                     kInt32MaxNums),
2060*cdf0e10cSrcweir                 "kRadixBinary",
2061*cdf0e10cSrcweir                 "valueOf(salInt32, radix 2) Bounderies"
2062*cdf0e10cSrcweir             );
2063*cdf0e10cSrcweir 
2064*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2065*cdf0e10cSrcweir             (
2066*cdf0e10cSrcweir                 hRtlTestResult,
2067*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kOctolMaxNumsStr,
2068*cdf0e10cSrcweir                  kInt32MaxNumsCount, kRadixOctol, hRtlTestResult,
2069*cdf0e10cSrcweir                     kInt32MaxNums),
2070*cdf0e10cSrcweir                 "kRadixOctol",
2071*cdf0e10cSrcweir                 "valueOf(salInt32, radix 8) Bounderies"
2072*cdf0e10cSrcweir             );
2073*cdf0e10cSrcweir 
2074*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2075*cdf0e10cSrcweir             (
2076*cdf0e10cSrcweir                 hRtlTestResult,
2077*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kDecimalMaxNumsStr,
2078*cdf0e10cSrcweir                                     kInt32MaxNumsCount, kRadixDecimal,
2079*cdf0e10cSrcweir                                     hRtlTestResult, kInt32MaxNums),
2080*cdf0e10cSrcweir                 "kRadixDecimal",
2081*cdf0e10cSrcweir                 "valueOf(salInt32, radix 10) Bounderies"
2082*cdf0e10cSrcweir             );
2083*cdf0e10cSrcweir 
2084*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2085*cdf0e10cSrcweir             (
2086*cdf0e10cSrcweir                 hRtlTestResult,
2087*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kHexDecimalMaxNumsStr,
2088*cdf0e10cSrcweir                                 kInt32MaxNumsCount, kRadixHexdecimal,
2089*cdf0e10cSrcweir                                 hRtlTestResult, kInt32MaxNums),
2090*cdf0e10cSrcweir                 "kRadixHexdecimal",
2091*cdf0e10cSrcweir                 "valueOf(salInt32, radix 16) Bounderies"
2092*cdf0e10cSrcweir             );
2093*cdf0e10cSrcweir 
2094*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2095*cdf0e10cSrcweir             (
2096*cdf0e10cSrcweir                 hRtlTestResult,
2097*cdf0e10cSrcweir                 test_valueOf_Int32((const char**)kBase36MaxNumsStr,
2098*cdf0e10cSrcweir                                     kInt32MaxNumsCount, kRadixBase36,
2099*cdf0e10cSrcweir                                     hRtlTestResult, kInt32MaxNums),
2100*cdf0e10cSrcweir                 "kRadixBase36",
2101*cdf0e10cSrcweir                 "valueOf(salInt32, radix 36) Bounderies"
2102*cdf0e10cSrcweir             );
2103*cdf0e10cSrcweir 
2104*cdf0e10cSrcweir     return ( bRes );
2105*cdf0e10cSrcweir }
2106*cdf0e10cSrcweir 
2107*cdf0e10cSrcweir //------------------------------------------------------------------------
2108*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=2 )
2109*cdf0e10cSrcweir // for negative value
2110*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=8 )
2111*cdf0e10cSrcweir // for negative value
2112*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=10 )
2113*cdf0e10cSrcweir // for negative value
2114*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=16 )
2115*cdf0e10cSrcweir // for negative value
2116*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 i, sal_Int16 radix=36 )
2117*cdf0e10cSrcweir // for negative value
2118*cdf0e10cSrcweir //------------------------------------------------------------------------
2119*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_Negative(
2120*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2121*cdf0e10cSrcweir {
2122*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2123*cdf0e10cSrcweir     sal_Int32 inArr[kBase36NumsCount];
2124*cdf0e10cSrcweir     sal_Int32 i;
2125*cdf0e10cSrcweir 
2126*cdf0e10cSrcweir     for (i = 0; i < kBase36NumsCount; i++ )
2127*cdf0e10cSrcweir         inArr[i] = -i;
2128*cdf0e10cSrcweir 
2129*cdf0e10cSrcweir     bRes =  c_rtl_tres_state
2130*cdf0e10cSrcweir             (
2131*cdf0e10cSrcweir                 hRtlTestResult,
2132*cdf0e10cSrcweir                 test_valueOf_Int32( kBinaryNumsStr, kBinaryNumsCount,
2133*cdf0e10cSrcweir                                     kRadixBinary, hRtlTestResult, inArr ),
2134*cdf0e10cSrcweir                 "negative Int32, kRadixBinary",
2135*cdf0e10cSrcweir                 "valueOf( negative Int32, radix 2 )"
2136*cdf0e10cSrcweir             );
2137*cdf0e10cSrcweir 
2138*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2139*cdf0e10cSrcweir             (
2140*cdf0e10cSrcweir                 hRtlTestResult,
2141*cdf0e10cSrcweir                 test_valueOf_Int32( kOctolNumsStr, kOctolNumsCount,
2142*cdf0e10cSrcweir                                     kRadixOctol, hRtlTestResult, inArr ),
2143*cdf0e10cSrcweir                 "negative Int32, kRadixOctol",
2144*cdf0e10cSrcweir                 "valueOf( negative Int32, radix 8 )"
2145*cdf0e10cSrcweir             );
2146*cdf0e10cSrcweir 
2147*cdf0e10cSrcweir 
2148*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2149*cdf0e10cSrcweir             (
2150*cdf0e10cSrcweir                 hRtlTestResult,
2151*cdf0e10cSrcweir                 test_valueOf_Int32( kDecimalNumsStr, kDecimalNumsCount,
2152*cdf0e10cSrcweir                              kRadixDecimal, hRtlTestResult, inArr ),
2153*cdf0e10cSrcweir                 "negative Int32, kRadixDecimal",
2154*cdf0e10cSrcweir                 "valueOf( negative Int32, radix 10 )"
2155*cdf0e10cSrcweir             );
2156*cdf0e10cSrcweir 
2157*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2158*cdf0e10cSrcweir             (
2159*cdf0e10cSrcweir                 hRtlTestResult,
2160*cdf0e10cSrcweir                 test_valueOf_Int32( kHexDecimalNumsStr, kHexDecimalNumsCount,
2161*cdf0e10cSrcweir                                 kRadixHexdecimal, hRtlTestResult, inArr ),
2162*cdf0e10cSrcweir                 "negative Int32, kRadixHexdecimal",
2163*cdf0e10cSrcweir                 "valueOf( negative Int32, radix 16 )"
2164*cdf0e10cSrcweir             );
2165*cdf0e10cSrcweir 
2166*cdf0e10cSrcweir 
2167*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2168*cdf0e10cSrcweir             (
2169*cdf0e10cSrcweir                 hRtlTestResult,
2170*cdf0e10cSrcweir                 test_valueOf_Int32( kBase36NumsStr, kBase36NumsCount,
2171*cdf0e10cSrcweir                                         kRadixBase36, hRtlTestResult, inArr ),
2172*cdf0e10cSrcweir                 "negative Int32, kRadixBase36",
2173*cdf0e10cSrcweir                 "valueOf( negative Int32, radix 36 )"
2174*cdf0e10cSrcweir             );
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir     return ( bRes );
2177*cdf0e10cSrcweir }
2178*cdf0e10cSrcweir //------------------------------------------------------------------------
2179*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix ) where radix = -5
2180*cdf0e10cSrcweir //------------------------------------------------------------------------
2181*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_WrongRadix(
2182*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2183*cdf0e10cSrcweir {
2184*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2185*cdf0e10cSrcweir 
2186*cdf0e10cSrcweir     sal_Int32 intVal = 11;
2187*cdf0e10cSrcweir 
2188*cdf0e10cSrcweir     ::rtl::OString aStr1;
2189*cdf0e10cSrcweir     ::rtl::OString aStr2("11");
2190*cdf0e10cSrcweir 
2191*cdf0e10cSrcweir     aStr1 = aStr1.valueOf( intVal, -5 );
2192*cdf0e10cSrcweir 
2193*cdf0e10cSrcweir     bRes = c_rtl_tres_state
2194*cdf0e10cSrcweir             (
2195*cdf0e10cSrcweir                 hRtlTestResult,
2196*cdf0e10cSrcweir                 aStr2.compareTo( aStr1 ) == 0,
2197*cdf0e10cSrcweir                 "if radix not valid then radix must be 10",
2198*cdf0e10cSrcweir                 "valueOf(sal_Int32, sal_Int32 radix): radix = -5"
2199*cdf0e10cSrcweir             );
2200*cdf0e10cSrcweir 
2201*cdf0e10cSrcweir     return (bRes);
2202*cdf0e10cSrcweir }
2203*cdf0e10cSrcweir 
2204*cdf0e10cSrcweir //------------------------------------------------------------------------
2205*cdf0e10cSrcweir // testing the method valueOf( sal_Int32 l, sal_Int32 radix )
2206*cdf0e10cSrcweir // where l = -2147483648 (smallest negative value)
2207*cdf0e10cSrcweir //------------------------------------------------------------------------
2208*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_SmallestNegativeValue(
2209*cdf0e10cSrcweir     hTestResult  hRtlTestResult)
2210*cdf0e10cSrcweir {
2211*cdf0e10cSrcweir     // Standard-conforming way to assign -2147483648 to n:
2212*cdf0e10cSrcweir     sal_Int32 n = -1;
2213*cdf0e10cSrcweir     for (int i = 1; i < 32; ++i)
2214*cdf0e10cSrcweir         n *= 2;
2215*cdf0e10cSrcweir     return c_rtl_tres_state
2216*cdf0e10cSrcweir             (
2217*cdf0e10cSrcweir                 hRtlTestResult,
2218*cdf0e10cSrcweir                 ::rtl::OString::valueOf(n) == "-2147483648",
2219*cdf0e10cSrcweir                 "-2147483648",
2220*cdf0e10cSrcweir                 "valueOf(sal_Int32 -2147483648)"
2221*cdf0e10cSrcweir             );
2222*cdf0e10cSrcweir }
2223*cdf0e10cSrcweir 
2224*cdf0e10cSrcweir //------------------------------------------------------------------------
2225*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=2 )
2226*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=8 )
2227*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=10 )
2228*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=16 )
2229*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=36 )
2230*cdf0e10cSrcweir //------------------------------------------------------------------------
2231*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64(
2232*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2233*cdf0e10cSrcweir {
2234*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2235*cdf0e10cSrcweir 
2236*cdf0e10cSrcweir     bRes =  c_rtl_tres_state
2237*cdf0e10cSrcweir             (
2238*cdf0e10cSrcweir                 hRtlTestResult,
2239*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kBinaryNumsStr,
2240*cdf0e10cSrcweir                         kBinaryNumsCount, kRadixBinary, hRtlTestResult, 0),
2241*cdf0e10cSrcweir                 "kRadixBinary",
2242*cdf0e10cSrcweir                 "valueOf(sal_Int64, radix 2)_"
2243*cdf0e10cSrcweir             );
2244*cdf0e10cSrcweir 
2245*cdf0e10cSrcweir     bRes &=  c_rtl_tres_state
2246*cdf0e10cSrcweir             (
2247*cdf0e10cSrcweir                 hRtlTestResult,
2248*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kOctolNumsStr,
2249*cdf0e10cSrcweir                             kOctolNumsCount, kRadixOctol, hRtlTestResult, 0),
2250*cdf0e10cSrcweir                 "kRadixOctol",
2251*cdf0e10cSrcweir                 "valueOf(sal_Int64, radix 8)_"
2252*cdf0e10cSrcweir             );
2253*cdf0e10cSrcweir 
2254*cdf0e10cSrcweir     bRes &=  c_rtl_tres_state
2255*cdf0e10cSrcweir             (
2256*cdf0e10cSrcweir                 hRtlTestResult,
2257*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kDecimalNumsStr,
2258*cdf0e10cSrcweir                         kDecimalNumsCount, kRadixDecimal, hRtlTestResult, 0),
2259*cdf0e10cSrcweir                 "kRadixDecimal",
2260*cdf0e10cSrcweir                 "valueOf(sal_Int64, radix 10)_"
2261*cdf0e10cSrcweir             );
2262*cdf0e10cSrcweir     bRes &=  c_rtl_tres_state
2263*cdf0e10cSrcweir             (
2264*cdf0e10cSrcweir                 hRtlTestResult,
2265*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kHexDecimalNumsStr,
2266*cdf0e10cSrcweir                   kHexDecimalNumsCount, kRadixHexdecimal, hRtlTestResult, 0),
2267*cdf0e10cSrcweir                 "kRadixHexdecimal",
2268*cdf0e10cSrcweir                 "valueOf(sal_Int64, radix 16)_"
2269*cdf0e10cSrcweir             );
2270*cdf0e10cSrcweir 
2271*cdf0e10cSrcweir     bRes &=  c_rtl_tres_state
2272*cdf0e10cSrcweir             (
2273*cdf0e10cSrcweir                 hRtlTestResult,
2274*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kBase36NumsStr,
2275*cdf0e10cSrcweir                           kBase36NumsCount, kRadixBase36, hRtlTestResult, 0),
2276*cdf0e10cSrcweir                 "kRadixBase36",
2277*cdf0e10cSrcweir                 "valueOf(sal_Int64, radix 36)_"
2278*cdf0e10cSrcweir             );
2279*cdf0e10cSrcweir 
2280*cdf0e10cSrcweir     return (bRes);
2281*cdf0e10cSrcweir }
2282*cdf0e10cSrcweir 
2283*cdf0e10cSrcweir //------------------------------------------------------------------------
2284*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix=2 )
2285*cdf0e10cSrcweir // where l = large constants
2286*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix=8 )
2287*cdf0e10cSrcweir // where l = large constants
2288*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix=10 )
2289*cdf0e10cSrcweir // where l = large constants
2290*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix=16 )
2291*cdf0e10cSrcweir // where l = large constants
2292*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix=36 )
2293*cdf0e10cSrcweir // where l = large constants
2294*cdf0e10cSrcweir //------------------------------------------------------------------------
2295*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_Bounderies(
2296*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2297*cdf0e10cSrcweir {
2298*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2299*cdf0e10cSrcweir 
2300*cdf0e10cSrcweir     bRes =  c_rtl_tres_state
2301*cdf0e10cSrcweir             (
2302*cdf0e10cSrcweir                 hRtlTestResult,
2303*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kBinaryMaxNumsStr,
2304*cdf0e10cSrcweir                                     kInt64MaxNumsCount, kRadixBinary,
2305*cdf0e10cSrcweir                                             hRtlTestResult, kInt64MaxNums),
2306*cdf0e10cSrcweir                 "kRadixBinary",
2307*cdf0e10cSrcweir                 "valueOf(salInt64, radix 2) Bounderies"
2308*cdf0e10cSrcweir             );
2309*cdf0e10cSrcweir 
2310*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2311*cdf0e10cSrcweir             (
2312*cdf0e10cSrcweir                 hRtlTestResult,
2313*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kOctolMaxNumsStr,
2314*cdf0e10cSrcweir                                     kInt64MaxNumsCount, kRadixOctol,
2315*cdf0e10cSrcweir                                             hRtlTestResult, kInt64MaxNums),
2316*cdf0e10cSrcweir                 "kRadixOctol",
2317*cdf0e10cSrcweir                 "valueOf(salInt64, radix 8) Bounderies"
2318*cdf0e10cSrcweir             );
2319*cdf0e10cSrcweir 
2320*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2321*cdf0e10cSrcweir             (
2322*cdf0e10cSrcweir                 hRtlTestResult,
2323*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kDecimalMaxNumsStr,
2324*cdf0e10cSrcweir                                     kInt64MaxNumsCount, kRadixDecimal,
2325*cdf0e10cSrcweir                                             hRtlTestResult, kInt64MaxNums),
2326*cdf0e10cSrcweir                 "kRadixDecimal",
2327*cdf0e10cSrcweir                 "valueOf(salInt64, radix 10) Bounderies"
2328*cdf0e10cSrcweir             );
2329*cdf0e10cSrcweir 
2330*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2331*cdf0e10cSrcweir             (
2332*cdf0e10cSrcweir                 hRtlTestResult,
2333*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kHexDecimalMaxNumsStr,
2334*cdf0e10cSrcweir                                     kInt64MaxNumsCount, kRadixHexdecimal,
2335*cdf0e10cSrcweir                                             hRtlTestResult, kInt64MaxNums),
2336*cdf0e10cSrcweir                 "kRadixHexdecimal",
2337*cdf0e10cSrcweir                 "valueOf(salInt64, radix 16) Bounderies"
2338*cdf0e10cSrcweir             );
2339*cdf0e10cSrcweir 
2340*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2341*cdf0e10cSrcweir             (
2342*cdf0e10cSrcweir                 hRtlTestResult,
2343*cdf0e10cSrcweir                 test_valueOf_Int64((const char**)kBase36MaxNumsStr,
2344*cdf0e10cSrcweir                                     kInt64MaxNumsCount, kRadixBase36,
2345*cdf0e10cSrcweir                                             hRtlTestResult, kInt64MaxNums),
2346*cdf0e10cSrcweir                 "kRadixBase36",
2347*cdf0e10cSrcweir                 "valueOf(salInt64, radix 36) Bounderies"
2348*cdf0e10cSrcweir             );
2349*cdf0e10cSrcweir 
2350*cdf0e10cSrcweir     return ( bRes );
2351*cdf0e10cSrcweir }
2352*cdf0e10cSrcweir 
2353*cdf0e10cSrcweir //------------------------------------------------------------------------
2354*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=2 )
2355*cdf0e10cSrcweir // for negative value
2356*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=8 )
2357*cdf0e10cSrcweir // for negative value
2358*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=10 )
2359*cdf0e10cSrcweir // for negative value
2360*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=16 )
2361*cdf0e10cSrcweir // for negative value
2362*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int16 radix=36 )
2363*cdf0e10cSrcweir // for negative value
2364*cdf0e10cSrcweir //------------------------------------------------------------------------
2365*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_Negative(
2366*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2367*cdf0e10cSrcweir {
2368*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2369*cdf0e10cSrcweir 
2370*cdf0e10cSrcweir     sal_Int64 inArr[36];
2371*cdf0e10cSrcweir     sal_Int32 i;
2372*cdf0e10cSrcweir 
2373*cdf0e10cSrcweir     for (i = 0; i < 36; i++) {
2374*cdf0e10cSrcweir         inArr[i] = -i;
2375*cdf0e10cSrcweir     }
2376*cdf0e10cSrcweir 
2377*cdf0e10cSrcweir 
2378*cdf0e10cSrcweir     bRes = c_rtl_tres_state
2379*cdf0e10cSrcweir             (
2380*cdf0e10cSrcweir                 hRtlTestResult,
2381*cdf0e10cSrcweir                 test_valueOf_Int64( kBinaryNumsStr, kBinaryNumsCount,
2382*cdf0e10cSrcweir                                     kRadixBinary, hRtlTestResult, inArr ),
2383*cdf0e10cSrcweir                 "negative Int64, kRadixBinary",
2384*cdf0e10cSrcweir                 "valueOf( negative Int64, radix 2 )"
2385*cdf0e10cSrcweir             );
2386*cdf0e10cSrcweir 
2387*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2388*cdf0e10cSrcweir             (
2389*cdf0e10cSrcweir                 hRtlTestResult,
2390*cdf0e10cSrcweir                 test_valueOf_Int64( kOctolNumsStr, kOctolNumsCount,
2391*cdf0e10cSrcweir                                         kRadixOctol, hRtlTestResult, inArr ),
2392*cdf0e10cSrcweir                 "negative Int64, kRadixOctol",
2393*cdf0e10cSrcweir                 "valueOf( negative Int64, radix 8 )"
2394*cdf0e10cSrcweir             );
2395*cdf0e10cSrcweir 
2396*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2397*cdf0e10cSrcweir             (
2398*cdf0e10cSrcweir                 hRtlTestResult,
2399*cdf0e10cSrcweir                 test_valueOf_Int64( kDecimalNumsStr, kDecimalNumsCount,
2400*cdf0e10cSrcweir                                     kRadixDecimal, hRtlTestResult, inArr ),
2401*cdf0e10cSrcweir                 "negative Int64, kRadixDecimal",
2402*cdf0e10cSrcweir                 "valueOf( negative Int64, radix 10 )"
2403*cdf0e10cSrcweir             );
2404*cdf0e10cSrcweir 
2405*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2406*cdf0e10cSrcweir             (
2407*cdf0e10cSrcweir                 hRtlTestResult,
2408*cdf0e10cSrcweir                 test_valueOf_Int64( kHexDecimalNumsStr, kHexDecimalNumsCount,
2409*cdf0e10cSrcweir                                     kRadixHexdecimal, hRtlTestResult, inArr ),
2410*cdf0e10cSrcweir                 "negative Int64, kRadixHexDecimal",
2411*cdf0e10cSrcweir                 "valueOf( negative Int64, radix 16 )"
2412*cdf0e10cSrcweir             );
2413*cdf0e10cSrcweir 
2414*cdf0e10cSrcweir     bRes &= c_rtl_tres_state
2415*cdf0e10cSrcweir             (
2416*cdf0e10cSrcweir                 hRtlTestResult,
2417*cdf0e10cSrcweir                 test_valueOf_Int64( kBase36NumsStr, kBase36NumsCount,
2418*cdf0e10cSrcweir                                       kRadixBase36, hRtlTestResult, inArr),
2419*cdf0e10cSrcweir                 "negative Int64, kRadixBase36",
2420*cdf0e10cSrcweir                 "valueOf( negative Int64, radix 36 )"
2421*cdf0e10cSrcweir             );
2422*cdf0e10cSrcweir 
2423*cdf0e10cSrcweir     return (bRes);
2424*cdf0e10cSrcweir }
2425*cdf0e10cSrcweir //------------------------------------------------------------------------
2426*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix )
2427*cdf0e10cSrcweir // where radix = -5
2428*cdf0e10cSrcweir //------------------------------------------------------------------------
2429*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_WrongRadix(
2430*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2431*cdf0e10cSrcweir {
2432*cdf0e10cSrcweir     sal_Bool bRes = sal_False;
2433*cdf0e10cSrcweir 
2434*cdf0e10cSrcweir     sal_Int64 intVal = 11;
2435*cdf0e10cSrcweir 
2436*cdf0e10cSrcweir     ::rtl::OString aStr1;
2437*cdf0e10cSrcweir     ::rtl::OString aStr2("11");
2438*cdf0e10cSrcweir 
2439*cdf0e10cSrcweir     aStr1 = aStr1.valueOf( intVal, -5 );
2440*cdf0e10cSrcweir 
2441*cdf0e10cSrcweir     bRes = c_rtl_tres_state
2442*cdf0e10cSrcweir             (
2443*cdf0e10cSrcweir                 hRtlTestResult,
2444*cdf0e10cSrcweir                 aStr2.compareTo(aStr1) == 0,
2445*cdf0e10cSrcweir                 "if radix not valid then radix must be 10",
2446*cdf0e10cSrcweir                 "valueOf(sal_Int64, sal_Int32 radix): radix = -5"
2447*cdf0e10cSrcweir             );
2448*cdf0e10cSrcweir 
2449*cdf0e10cSrcweir     return (bRes);
2450*cdf0e10cSrcweir }
2451*cdf0e10cSrcweir 
2452*cdf0e10cSrcweir //------------------------------------------------------------------------
2453*cdf0e10cSrcweir // testing the method valueOf( sal_Int64 l, sal_Int32 radix )
2454*cdf0e10cSrcweir // where l = -9223372036854775808 (smallest negative value)
2455*cdf0e10cSrcweir //------------------------------------------------------------------------
2456*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_SmallestNegativeValue(
2457*cdf0e10cSrcweir     hTestResult hRtlTestResult)
2458*cdf0e10cSrcweir {
2459*cdf0e10cSrcweir     // Standard-conforming way to assign -9223372036854775808 to n:
2460*cdf0e10cSrcweir     sal_Int64 n = -1;
2461*cdf0e10cSrcweir     for (int i = 1; i < 64; ++i)
2462*cdf0e10cSrcweir         n *= 2;
2463*cdf0e10cSrcweir     return c_rtl_tres_state
2464*cdf0e10cSrcweir             (
2465*cdf0e10cSrcweir                 hRtlTestResult,
2466*cdf0e10cSrcweir                 ::rtl::OString::valueOf(n) == "-9223372036854775808",
2467*cdf0e10cSrcweir                 "-9223372036854775808",
2468*cdf0e10cSrcweir                 "valueOf(sal_Int64 -9223372036854775808)"
2469*cdf0e10cSrcweir             );
2470*cdf0e10cSrcweir }
2471*cdf0e10cSrcweir 
2472*cdf0e10cSrcweir //------------------------------------------------------------------------
2473*cdf0e10cSrcweir // testing the method valueOf( float f )
2474*cdf0e10cSrcweir //------------------------------------------------------------------------
2475*cdf0e10cSrcweir // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_float(
2476*cdf0e10cSrcweir // LLA:                         hTestResult hRtlTestResult )
2477*cdf0e10cSrcweir // LLA: {
2478*cdf0e10cSrcweir // LLA:     sal_Char methName[MAXBUFLENGTH];
2479*cdf0e10cSrcweir // LLA:     sal_Char* pMeth =methName;
2480*cdf0e10cSrcweir // LLA:
2481*cdf0e10cSrcweir // LLA:     typedef struct TestCase
2482*cdf0e10cSrcweir // LLA:     {
2483*cdf0e10cSrcweir // LLA:     sal_Char*                    comments;
2484*cdf0e10cSrcweir // LLA:     float                         input1;
2485*cdf0e10cSrcweir // LLA:     OString*                     expVal;
2486*cdf0e10cSrcweir // LLA:
2487*cdf0e10cSrcweir // LLA:     ~TestCase() {delete expVal;}
2488*cdf0e10cSrcweir // LLA:     } TestCase;
2489*cdf0e10cSrcweir // LLA:
2490*cdf0e10cSrcweir // LLA:     TestCase arrTestCase[] =
2491*cdf0e10cSrcweir // LLA:     {
2492*cdf0e10cSrcweir // LLA:         { "3.0", 3.0, new OString("3.0") },
2493*cdf0e10cSrcweir // LLA:         { "3.5", 3.5f, new OString("3.5")},
2494*cdf0e10cSrcweir // LLA:         { "3.0625", 3.0625f, new OString("3.0625")},
2495*cdf0e10cSrcweir // LLA:         { "3.502525", 3.502525f, new OString("3.502525") },
2496*cdf0e10cSrcweir // LLA:         { "3.141592", 3.141592f, new OString("3.141592") },
2497*cdf0e10cSrcweir // LLA:         { "3.5025255", 3.5025255f, new OString("3.5025255") },
2498*cdf0e10cSrcweir // LLA:         { "3.0039062", 3.00390625f, new OString("3.0039062") }
2499*cdf0e10cSrcweir // LLA:     };
2500*cdf0e10cSrcweir // LLA:
2501*cdf0e10cSrcweir // LLA:     sal_Bool res = sal_True;
2502*cdf0e10cSrcweir // LLA:     sal_Int32 i;
2503*cdf0e10cSrcweir // LLA:
2504*cdf0e10cSrcweir // LLA:     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2505*cdf0e10cSrcweir // LLA:     {
2506*cdf0e10cSrcweir // LLA:         ::rtl::OString aStr1;
2507*cdf0e10cSrcweir // LLA:         aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2508*cdf0e10cSrcweir // LLA:         sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2509*cdf0e10cSrcweir // LLA:
2510*cdf0e10cSrcweir // LLA:         c_rtl_tres_state
2511*cdf0e10cSrcweir // LLA:         (
2512*cdf0e10cSrcweir // LLA:             hRtlTestResult,
2513*cdf0e10cSrcweir // LLA:             lastRes,
2514*cdf0e10cSrcweir // LLA:             arrTestCase[i].comments,
2515*cdf0e10cSrcweir // LLA:             createName( pMeth, "valueof_float", i)
2516*cdf0e10cSrcweir // LLA:         );
2517*cdf0e10cSrcweir // LLA:
2518*cdf0e10cSrcweir // LLA:         res &= lastRes;
2519*cdf0e10cSrcweir // LLA:
2520*cdf0e10cSrcweir // LLA:     }
2521*cdf0e10cSrcweir // LLA:
2522*cdf0e10cSrcweir // LLA:     return ( res );
2523*cdf0e10cSrcweir // LLA: }
2524*cdf0e10cSrcweir 
2525*cdf0e10cSrcweir 
2526*cdf0e10cSrcweir 
2527*cdf0e10cSrcweir 
2528*cdf0e10cSrcweir //------------------------------------------------------------------------
2529*cdf0e10cSrcweir // testing the method valueOf( float f ) for negative value
2530*cdf0e10cSrcweir //------------------------------------------------------------------------
2531*cdf0e10cSrcweir // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_Float_Negative(
2532*cdf0e10cSrcweir // LLA:                                               hTestResult hRtlTestResult )
2533*cdf0e10cSrcweir // LLA: {
2534*cdf0e10cSrcweir // LLA:     sal_Char methName[MAXBUFLENGTH];
2535*cdf0e10cSrcweir // LLA:     sal_Char* pMeth =methName;
2536*cdf0e10cSrcweir // LLA:
2537*cdf0e10cSrcweir // LLA:     typedef struct TestCase
2538*cdf0e10cSrcweir // LLA:     {
2539*cdf0e10cSrcweir // LLA:     sal_Char*                    comments;
2540*cdf0e10cSrcweir // LLA:     float                         input1;
2541*cdf0e10cSrcweir // LLA:     OString*                     expVal;
2542*cdf0e10cSrcweir // LLA:
2543*cdf0e10cSrcweir // LLA:     ~TestCase() {delete expVal;}
2544*cdf0e10cSrcweir // LLA:     } TestCase;
2545*cdf0e10cSrcweir // LLA:
2546*cdf0e10cSrcweir // LLA:     TestCase arrTestCase[] =
2547*cdf0e10cSrcweir // LLA:     {
2548*cdf0e10cSrcweir // LLA:         { "-3.0", -3.0, new OString("-3.0") },
2549*cdf0e10cSrcweir // LLA:         { "-3.5", -3.5f, new OString("-3.5")},
2550*cdf0e10cSrcweir // LLA:         { "-3.0625", -3.0625f, new OString("-3.0625")},
2551*cdf0e10cSrcweir // LLA:         { "-3.502525", -3.502525f, new OString("-3.502525") },
2552*cdf0e10cSrcweir // LLA:         { "-3.141592", -3.141592f, new OString("-3.141592") },
2553*cdf0e10cSrcweir // LLA:         { "-3.5025255", -3.5025255f, new OString("-3.5025255") },
2554*cdf0e10cSrcweir // LLA:         { "-3.0039062", -3.00390625f, new OString("-3.0039062") }
2555*cdf0e10cSrcweir // LLA:     };
2556*cdf0e10cSrcweir // LLA:
2557*cdf0e10cSrcweir // LLA:     sal_Bool res = sal_True;
2558*cdf0e10cSrcweir // LLA:     sal_Int32 i;
2559*cdf0e10cSrcweir // LLA:
2560*cdf0e10cSrcweir // LLA:     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2561*cdf0e10cSrcweir // LLA:     {
2562*cdf0e10cSrcweir // LLA:         ::rtl::OString aStr1;
2563*cdf0e10cSrcweir // LLA:         aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2564*cdf0e10cSrcweir // LLA:         sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2565*cdf0e10cSrcweir // LLA:
2566*cdf0e10cSrcweir // LLA:         c_rtl_tres_state
2567*cdf0e10cSrcweir // LLA:         (
2568*cdf0e10cSrcweir // LLA:             hRtlTestResult,
2569*cdf0e10cSrcweir // LLA:             lastRes,
2570*cdf0e10cSrcweir // LLA:             arrTestCase[i].comments,
2571*cdf0e10cSrcweir // LLA:             createName( pMeth, "valueof_negative float", i)
2572*cdf0e10cSrcweir // LLA:         );
2573*cdf0e10cSrcweir // LLA:
2574*cdf0e10cSrcweir // LLA:         res &= lastRes;
2575*cdf0e10cSrcweir // LLA:
2576*cdf0e10cSrcweir // LLA:     }
2577*cdf0e10cSrcweir // LLA:
2578*cdf0e10cSrcweir // LLA:     return ( res );
2579*cdf0e10cSrcweir // LLA: }
2580*cdf0e10cSrcweir 
2581*cdf0e10cSrcweir //------------------------------------------------------------------------
2582*cdf0e10cSrcweir // testing the method valueOf( double f )
2583*cdf0e10cSrcweir //------------------------------------------------------------------------
2584*cdf0e10cSrcweir // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_double(
2585*cdf0e10cSrcweir // LLA:                                                 hTestResult hRtlTestResult )
2586*cdf0e10cSrcweir // LLA: {
2587*cdf0e10cSrcweir // LLA:     sal_Char methName[MAXBUFLENGTH];
2588*cdf0e10cSrcweir // LLA:     sal_Char* pMeth =methName;
2589*cdf0e10cSrcweir // LLA:
2590*cdf0e10cSrcweir // LLA:     typedef struct TestCase
2591*cdf0e10cSrcweir // LLA:     {
2592*cdf0e10cSrcweir // LLA:     sal_Char*                    comments;
2593*cdf0e10cSrcweir // LLA:     double                         input1;
2594*cdf0e10cSrcweir // LLA:     OString*                     expVal;
2595*cdf0e10cSrcweir // LLA:
2596*cdf0e10cSrcweir // LLA:     ~TestCase() {delete expVal;}
2597*cdf0e10cSrcweir // LLA:     } TestCase;
2598*cdf0e10cSrcweir // LLA:
2599*cdf0e10cSrcweir // LLA:     TestCase arrTestCase[] =
2600*cdf0e10cSrcweir // LLA:     {
2601*cdf0e10cSrcweir // LLA:         {"3.0", 3.0, new OString("3.0")},
2602*cdf0e10cSrcweir // LLA:         {"3.5", 3.5, new OString("3.5")},
2603*cdf0e10cSrcweir // LLA:         {"3.0625", 3.0625, new OString("3.0625")},
2604*cdf0e10cSrcweir // LLA:         {"3.1415926535", 3.1415926535, new OString("3.1415926535")},
2605*cdf0e10cSrcweir // LLA:         {"3.1415926535897931", 3.141592653589793,
2606*cdf0e10cSrcweir // LLA:             new OString("3.1415926535897931")},
2607*cdf0e10cSrcweir // LLA:         {"3.1415926535897931", 3.1415926535897932,
2608*cdf0e10cSrcweir // LLA:             new OString("3.1415926535897931")},
2609*cdf0e10cSrcweir // LLA:         {"3.1415926535897931", 3.14159265358979323,
2610*cdf0e10cSrcweir // LLA:             new OString("3.1415926535897931")},
2611*cdf0e10cSrcweir // LLA:         {"3.1415926535897931", 3.141592653589793238462643,
2612*cdf0e10cSrcweir // LLA:             new OString("3.1415926535897931")}
2613*cdf0e10cSrcweir // LLA:     };
2614*cdf0e10cSrcweir // LLA:
2615*cdf0e10cSrcweir // LLA:     sal_Bool res = sal_True;
2616*cdf0e10cSrcweir // LLA:     sal_Int32 i;
2617*cdf0e10cSrcweir // LLA:
2618*cdf0e10cSrcweir // LLA:     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2619*cdf0e10cSrcweir // LLA:     {
2620*cdf0e10cSrcweir // LLA:         ::rtl::OString aStr1;
2621*cdf0e10cSrcweir // LLA:         aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2622*cdf0e10cSrcweir // LLA:         sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2623*cdf0e10cSrcweir // LLA:
2624*cdf0e10cSrcweir // LLA:         c_rtl_tres_state
2625*cdf0e10cSrcweir // LLA:         (
2626*cdf0e10cSrcweir // LLA:             hRtlTestResult,
2627*cdf0e10cSrcweir // LLA:             lastRes,
2628*cdf0e10cSrcweir // LLA:             arrTestCase[i].comments,
2629*cdf0e10cSrcweir // LLA:             createName( pMeth, "valueof_double", i)
2630*cdf0e10cSrcweir // LLA:         );
2631*cdf0e10cSrcweir // LLA:
2632*cdf0e10cSrcweir // LLA:         res &= lastRes;
2633*cdf0e10cSrcweir // LLA:
2634*cdf0e10cSrcweir // LLA:     }
2635*cdf0e10cSrcweir // LLA:
2636*cdf0e10cSrcweir // LLA:     return ( res );
2637*cdf0e10cSrcweir // LLA: }
2638*cdf0e10cSrcweir 
2639*cdf0e10cSrcweir 
2640*cdf0e10cSrcweir //------------------------------------------------------------------------
2641*cdf0e10cSrcweir // testing the method valueOf( double f ) for negative value
2642*cdf0e10cSrcweir //------------------------------------------------------------------------
2643*cdf0e10cSrcweir // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_Double_Negative(
2644*cdf0e10cSrcweir // LLA:                                                 hTestResult hRtlTestResult )
2645*cdf0e10cSrcweir // LLA: {
2646*cdf0e10cSrcweir // LLA:     sal_Char methName[MAXBUFLENGTH];
2647*cdf0e10cSrcweir // LLA:     sal_Char* pMeth =methName;
2648*cdf0e10cSrcweir // LLA:
2649*cdf0e10cSrcweir // LLA:     typedef struct TestCase
2650*cdf0e10cSrcweir // LLA:     {
2651*cdf0e10cSrcweir // LLA:     sal_Char*                    comments;
2652*cdf0e10cSrcweir // LLA:     double                         input1;
2653*cdf0e10cSrcweir // LLA:     OString*                     expVal;
2654*cdf0e10cSrcweir // LLA:
2655*cdf0e10cSrcweir // LLA:     ~TestCase() {delete expVal;}
2656*cdf0e10cSrcweir // LLA:     } TestCase;
2657*cdf0e10cSrcweir // LLA:
2658*cdf0e10cSrcweir // LLA:     TestCase arrTestCase[] =
2659*cdf0e10cSrcweir // LLA:     {
2660*cdf0e10cSrcweir // LLA:         {"-3.0", -3.0, new OString("-3.0")},
2661*cdf0e10cSrcweir // LLA:         {"-3.5", -3.5, new OString("-3.5")},
2662*cdf0e10cSrcweir // LLA:         {"-3.0625", -3.0625, new OString("-3.0625")},
2663*cdf0e10cSrcweir // LLA:         {"-3.1415926535", -3.1415926535, new OString("-3.1415926535")},
2664*cdf0e10cSrcweir // LLA:         {"-3.1415926535897931", -3.141592653589793,
2665*cdf0e10cSrcweir // LLA:             new OString("-3.1415926535897931")},
2666*cdf0e10cSrcweir // LLA:         {"-3.1415926535897931", -3.1415926535897932,
2667*cdf0e10cSrcweir // LLA:             new OString("-3.1415926535897931")},
2668*cdf0e10cSrcweir // LLA:         {"-3.1415926535897931", -3.14159265358979323,
2669*cdf0e10cSrcweir // LLA:             new OString("-3.1415926535897931")},
2670*cdf0e10cSrcweir // LLA:         {"-3.1415926535897931", -3.141592653589793238462643,
2671*cdf0e10cSrcweir // LLA:             new OString("-3.1415926535897931")}
2672*cdf0e10cSrcweir // LLA:     };
2673*cdf0e10cSrcweir // LLA:
2674*cdf0e10cSrcweir // LLA:     sal_Bool res = sal_True;
2675*cdf0e10cSrcweir // LLA:     sal_Int32 i;
2676*cdf0e10cSrcweir // LLA:
2677*cdf0e10cSrcweir // LLA:     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2678*cdf0e10cSrcweir // LLA:     {
2679*cdf0e10cSrcweir // LLA:         ::rtl::OString aStr1;
2680*cdf0e10cSrcweir // LLA:         aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2681*cdf0e10cSrcweir // LLA:         sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2682*cdf0e10cSrcweir // LLA:
2683*cdf0e10cSrcweir // LLA:         c_rtl_tres_state
2684*cdf0e10cSrcweir // LLA:         (
2685*cdf0e10cSrcweir // LLA:             hRtlTestResult,
2686*cdf0e10cSrcweir // LLA:             lastRes,
2687*cdf0e10cSrcweir // LLA:             arrTestCase[i].comments,
2688*cdf0e10cSrcweir // LLA:             createName( pMeth, "valueof_nagative double", i)
2689*cdf0e10cSrcweir // LLA:         );
2690*cdf0e10cSrcweir // LLA:
2691*cdf0e10cSrcweir // LLA:         res &= lastRes;
2692*cdf0e10cSrcweir // LLA:
2693*cdf0e10cSrcweir // LLA:     }
2694*cdf0e10cSrcweir // LLA:
2695*cdf0e10cSrcweir // LLA:     return ( res );
2696*cdf0e10cSrcweir // LLA: }
2697*cdf0e10cSrcweir 
2698*cdf0e10cSrcweir //------------------------------------------------------------------------
2699*cdf0e10cSrcweir // testing the method valueOf()
2700*cdf0e10cSrcweir //------------------------------------------------------------------------
2701*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_valueOf(
2702*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2703*cdf0e10cSrcweir {
2704*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "valueOf");
2705*cdf0e10cSrcweir     sal_Bool bTState = test_rtl_OString_valueOf_sal_Bool( hRtlTestResult );
2706*cdf0e10cSrcweir 
2707*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_sal_Char( hRtlTestResult );
2708*cdf0e10cSrcweir 
2709*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int32( hRtlTestResult );
2710*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int32_Bounderies( hRtlTestResult );
2711*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int32_Negative( hRtlTestResult );
2712*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int32_WrongRadix( hRtlTestResult );
2713*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int32_SmallestNegativeValue(
2714*cdf0e10cSrcweir                                                             hRtlTestResult );
2715*cdf0e10cSrcweir 
2716*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int64( hRtlTestResult );
2717*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int64_Bounderies( hRtlTestResult );
2718*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int64_Negative( hRtlTestResult );
2719*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int64_WrongRadix( hRtlTestResult );
2720*cdf0e10cSrcweir     bTState &= test_rtl_OString_valueOf_Int64_SmallestNegativeValue(
2721*cdf0e10cSrcweir                                                             hRtlTestResult );
2722*cdf0e10cSrcweir 
2723*cdf0e10cSrcweir     // LLA: the tests for valueOf(float) and valueOf(double) are moved to file
2724*cdf0e10cSrcweir     //      sal/qa/rtl/ostring/rtl_OString2.cxx
2725*cdf0e10cSrcweir 
2726*cdf0e10cSrcweir     // LLA: bTState &= test_rtl_OString_valueOf_float( hRtlTestResult );
2727*cdf0e10cSrcweir     // LLA: bTState &= test_rtl_OString_valueOf_Float_Negative( hRtlTestResult );
2728*cdf0e10cSrcweir 
2729*cdf0e10cSrcweir     // LLA: bTState &= test_rtl_OString_valueOf_double( hRtlTestResult );
2730*cdf0e10cSrcweir     // LLA: bTState &= test_rtl_OString_valueOf_Double_Negative( hRtlTestResult );
2731*cdf0e10cSrcweir 
2732*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "valueOf");
2733*cdf0e10cSrcweir //    return ( bTState );
2734*cdf0e10cSrcweir }
2735*cdf0e10cSrcweir 
2736*cdf0e10cSrcweir 
2737*cdf0e10cSrcweir //------------------------------------------------------------------------
2738*cdf0e10cSrcweir // testing the method toChar()
2739*cdf0e10cSrcweir //------------------------------------------------------------------------
2740*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toChar(
2741*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
2742*cdf0e10cSrcweir {
2743*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
2744*cdf0e10cSrcweir     sal_Char* pMeth = methName;
2745*cdf0e10cSrcweir 
2746*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toChar");
2747*cdf0e10cSrcweir     typedef struct TestCase
2748*cdf0e10cSrcweir     {
2749*cdf0e10cSrcweir     sal_Char*                    comments;
2750*cdf0e10cSrcweir     sal_Char                     expVal;
2751*cdf0e10cSrcweir     OString*                     input1;
2752*cdf0e10cSrcweir     ~TestCase() {delete input1;}
2753*cdf0e10cSrcweir     } TestCase;
2754*cdf0e10cSrcweir 
2755*cdf0e10cSrcweir 
2756*cdf0e10cSrcweir     TestCase arrTestCase[] =
2757*cdf0e10cSrcweir     {
2758*cdf0e10cSrcweir         {"A", 'A', new OString("A")},
2759*cdf0e10cSrcweir         {"a", 'a', new OString("a")},
2760*cdf0e10cSrcweir         {"0", '0',new OString("0")},
2761*cdf0e10cSrcweir         {"-", '-',new OString("-")},
2762*cdf0e10cSrcweir         {"_", '_',new OString("_")},
2763*cdf0e10cSrcweir 
2764*cdf0e10cSrcweir //  TODO: may be UTF-8 values
2765*cdf0e10cSrcweir //        {"�0�6", '�0�6',new OString("�0�6")},
2766*cdf0e10cSrcweir //        { "�0�7", '�0�7',new OString("�0�7")},
2767*cdf0e10cSrcweir //        {"�0�0", '�0�0',new OString("�0�0")},
2768*cdf0e10cSrcweir //        {"�0�6", '�0�6',new OString("�0�6")},
2769*cdf0e10cSrcweir         {"\n", '\n',new OString("\n")},
2770*cdf0e10cSrcweir         {"\'", '\'',new OString("\'")},
2771*cdf0e10cSrcweir         {"\"", '\"',new OString("\"")},
2772*cdf0e10cSrcweir         {"\0", '\0',new OString("\0")},
2773*cdf0e10cSrcweir         {"", '\0',new OString("")},
2774*cdf0e10cSrcweir         {"Sun Microsystems", 'S', new OString(kTestStr1)}
2775*cdf0e10cSrcweir     };
2776*cdf0e10cSrcweir 
2777*cdf0e10cSrcweir 
2778*cdf0e10cSrcweir     // sal_Bool res = sal_True;
2779*cdf0e10cSrcweir     sal_uInt32 i;
2780*cdf0e10cSrcweir 
2781*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++ )
2782*cdf0e10cSrcweir     {
2783*cdf0e10cSrcweir         sal_Char strRes = arrTestCase[i].input1->toChar();
2784*cdf0e10cSrcweir         sal_Bool lastRes = ( strRes == arrTestCase[i].expVal );
2785*cdf0e10cSrcweir 
2786*cdf0e10cSrcweir         char com[MAXBUFLENGTH];
2787*cdf0e10cSrcweir         com[0] = '\'';
2788*cdf0e10cSrcweir         cpynstr(com + 1, (*arrTestCase[i].input1), MAXBUFLENGTH);
2789*cdf0e10cSrcweir         int length = AStringLen( (*arrTestCase[i].input1) );
2790*cdf0e10cSrcweir         com[length + 1] = '\'';
2791*cdf0e10cSrcweir         com[length + 2] = 0;
2792*cdf0e10cSrcweir 
2793*cdf0e10cSrcweir         c_rtl_tres_state
2794*cdf0e10cSrcweir         (
2795*cdf0e10cSrcweir             hRtlTestResult,
2796*cdf0e10cSrcweir             lastRes,
2797*cdf0e10cSrcweir             com,
2798*cdf0e10cSrcweir             createName( pMeth, "toChar", i )
2799*cdf0e10cSrcweir         );
2800*cdf0e10cSrcweir 
2801*cdf0e10cSrcweir     }
2802*cdf0e10cSrcweir 
2803*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toChar");
2804*cdf0e10cSrcweir //    return (res);
2805*cdf0e10cSrcweir }
2806*cdf0e10cSrcweir 
2807*cdf0e10cSrcweir 
2808*cdf0e10cSrcweir //------------------------------------------------------------------------
2809*cdf0e10cSrcweir // testing the method toFloat()
2810*cdf0e10cSrcweir //------------------------------------------------------------------------
2811*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toFloat(
2812*cdf0e10cSrcweir                                             hTestResult hRtlTestResult )
2813*cdf0e10cSrcweir {
2814*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
2815*cdf0e10cSrcweir     sal_Char* pMeth = methName;
2816*cdf0e10cSrcweir 
2817*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toFloat");
2818*cdf0e10cSrcweir     typedef struct TestCase
2819*cdf0e10cSrcweir     {
2820*cdf0e10cSrcweir         float                        expVal;
2821*cdf0e10cSrcweir         OString*                     input1;
2822*cdf0e10cSrcweir         float         m_nPrecision;
2823*cdf0e10cSrcweir         ~TestCase() {delete input1;}
2824*cdf0e10cSrcweir     } TestCase;
2825*cdf0e10cSrcweir 
2826*cdf0e10cSrcweir 
2827*cdf0e10cSrcweir     TestCase arrTestCase[] =
2828*cdf0e10cSrcweir     {
2829*cdf0e10cSrcweir         {3.0f, new OString("3"), 3e-7f},
2830*cdf0e10cSrcweir         {3.1f, new OString("3.1"), 3e-7f},
2831*cdf0e10cSrcweir         {3.1415f, new OString("3.1415"), 3e-7f},
2832*cdf0e10cSrcweir         {3.14159f, new OString("3.14159"), 3e-7f},
2833*cdf0e10cSrcweir         {3.141592f, new OString("3.141592"), 3e-7f},
2834*cdf0e10cSrcweir         {3.1415926f, new OString("3.1415926"), 3e-7f},
2835*cdf0e10cSrcweir         {3.14159265f, new OString("3.14159265"), 3e-7f},
2836*cdf0e10cSrcweir         {3.141592653589793238462643f,
2837*cdf0e10cSrcweir             new OString("3.141592653589793238462643"), 3e-7f},
2838*cdf0e10cSrcweir         {6.5822e-16f, new OString("6.5822e-16"), 6e-16f * 1e-7f},
2839*cdf0e10cSrcweir         {9.1096e-31f, new OString("9.1096e-31"), 9e-31f * 1e-7f},
2840*cdf0e10cSrcweir         {2.997925e8f, new OString("2.997925e8"), 3e8f * 1e-7f},
2841*cdf0e10cSrcweir         {6.241e18f, new OString("6.241e18"), 6e18f * 1e-7f},
2842*cdf0e10cSrcweir         {3.1f, new OString("03.1"), 3e-7f},
2843*cdf0e10cSrcweir         {3.1f, new OString(" 3.1"), 3e-7f},
2844*cdf0e10cSrcweir         {-3.1f, new OString("-3.1"), 3e-7f},
2845*cdf0e10cSrcweir         {3.1f, new OString("+3.1"), 3e-7f},
2846*cdf0e10cSrcweir         {0.0f, new OString("-0.0"), 1e-7f}
2847*cdf0e10cSrcweir     };
2848*cdf0e10cSrcweir 
2849*cdf0e10cSrcweir 
2850*cdf0e10cSrcweir     // sal_Bool res = sal_True;
2851*cdf0e10cSrcweir     sal_uInt32 i;
2852*cdf0e10cSrcweir 
2853*cdf0e10cSrcweir     t_print("sizeof(float)=%d, sizeof(double)=%d\n", sizeof(float), sizeof(double));
2854*cdf0e10cSrcweir 
2855*cdf0e10cSrcweir     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++ )
2856*cdf0e10cSrcweir     {
2857*cdf0e10cSrcweir         float fA = arrTestCase[i].input1->toFloat();
2858*cdf0e10cSrcweir         float fB = arrTestCase[i].expVal;
2859*cdf0e10cSrcweir         float fPrec = arrTestCase[i].m_nPrecision;
2860*cdf0e10cSrcweir         float fResult = (float) fabs(fA - fB);
2861*cdf0e10cSrcweir         // t_print("float result: A:(%.9f) B:(%.9f) fabs(A-B):%E\n", fA, fB, fResult);
2862*cdf0e10cSrcweir         t_print("float result: A:(%E) B:(%E) fabs(A-B):%E\n", fA, fB, (float) fResult);
2863*cdf0e10cSrcweir         sal_Bool lastRes = ( fResult <= fPrec );
2864*cdf0e10cSrcweir 
2865*cdf0e10cSrcweir         char com[MAXBUFLENGTH];
2866*cdf0e10cSrcweir         com[0] = '\'';
2867*cdf0e10cSrcweir         cpynstr(com + 1, (*arrTestCase[i].input1), MAXBUFLENGTH);
2868*cdf0e10cSrcweir         int length = AStringLen( (*arrTestCase[i].input1) );
2869*cdf0e10cSrcweir         com[length + 1] = '\'';
2870*cdf0e10cSrcweir         com[length + 2] = 0;
2871*cdf0e10cSrcweir 
2872*cdf0e10cSrcweir         c_rtl_tres_state
2873*cdf0e10cSrcweir         (
2874*cdf0e10cSrcweir             hRtlTestResult,
2875*cdf0e10cSrcweir             lastRes,
2876*cdf0e10cSrcweir             com,
2877*cdf0e10cSrcweir             createName( pMeth, "toFloat", i )
2878*cdf0e10cSrcweir         );
2879*cdf0e10cSrcweir 
2880*cdf0e10cSrcweir     }
2881*cdf0e10cSrcweir 
2882*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toFloat");
2883*cdf0e10cSrcweir //    return (res);
2884*cdf0e10cSrcweir }
2885*cdf0e10cSrcweir 
2886*cdf0e10cSrcweir 
2887*cdf0e10cSrcweir //------------------------------------------------------------------------
2888*cdf0e10cSrcweir // testing the method toDouble()
2889*cdf0e10cSrcweir //------------------------------------------------------------------------
2890*cdf0e10cSrcweir // LLA: extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toDouble(
2891*cdf0e10cSrcweir // LLA:                                                 hTestResult hRtlTestResult )
2892*cdf0e10cSrcweir // LLA: {
2893*cdf0e10cSrcweir // LLA:     sal_Char methName[MAXBUFLENGTH];
2894*cdf0e10cSrcweir // LLA:     sal_Char* pMeth = methName;
2895*cdf0e10cSrcweir // LLA:
2896*cdf0e10cSrcweir // LLA:     c_rtl_tres_state_start(hRtlTestResult, "toDouble");
2897*cdf0e10cSrcweir // LLA:     typedef struct TestCase
2898*cdf0e10cSrcweir // LLA:     {
2899*cdf0e10cSrcweir // LLA:     double                       expVal;
2900*cdf0e10cSrcweir // LLA:     double                       expDiff;
2901*cdf0e10cSrcweir // LLA:     OString*                     input1;
2902*cdf0e10cSrcweir // LLA:     ~TestCase() {delete input1;}
2903*cdf0e10cSrcweir // LLA:     } TestCase;
2904*cdf0e10cSrcweir // LLA:
2905*cdf0e10cSrcweir // LLA:
2906*cdf0e10cSrcweir // LLA:     TestCase arrTestCase[] =
2907*cdf0e10cSrcweir // LLA:     {
2908*cdf0e10cSrcweir // LLA:         {3.0, 1e-35, new OString("3")},
2909*cdf0e10cSrcweir // LLA:         {3.1, 1e-2, new OString("3.1")},
2910*cdf0e10cSrcweir // LLA:         {3.1415, 1e-5, new OString("3.1415")},
2911*cdf0e10cSrcweir // LLA:         {3.1415926535, 1e-11, new OString("3.1415926535")},
2912*cdf0e10cSrcweir // LLA:         {3.141592653589793, 1e-15,
2913*cdf0e10cSrcweir // LLA:             new OString("3.141592653589793")},
2914*cdf0e10cSrcweir // LLA:         {3.1415926535897932, 1e-16,
2915*cdf0e10cSrcweir // LLA:             new OString("3.1415926535897932")},
2916*cdf0e10cSrcweir // LLA:         {3.14159265358979323, 1e-15,
2917*cdf0e10cSrcweir // LLA:             new OString("3.14159265358979323")},
2918*cdf0e10cSrcweir // LLA:         {3.141592653589793238462643, 1e-15,
2919*cdf0e10cSrcweir // LLA:             new OString("3.141592653589793238462643")},
2920*cdf0e10cSrcweir // LLA:         {6.5822e-16, 1e-20, new OString("6.5822e-16")},
2921*cdf0e10cSrcweir // LLA:         {9.1096e-31, 1e-35, new OString("9.1096e-31")},
2922*cdf0e10cSrcweir // LLA:         {2.997925e8, 10, new OString("2.997925e8")},
2923*cdf0e10cSrcweir // LLA:         {6.241e18, 100, new OString("6.241e18")},
2924*cdf0e10cSrcweir // LLA:         {1.7e-308, 1e-35, new OString("1.7e-308")},
2925*cdf0e10cSrcweir // LLA:         {1.7e+308, 100, new OString("1.7e+308")},
2926*cdf0e10cSrcweir // LLA:         {3.1, 1e-2, new OString("03.1")},
2927*cdf0e10cSrcweir // LLA:         {3.1, 1e-2, new OString(" 3.1")},
2928*cdf0e10cSrcweir // LLA:         {-3.1, 1e-2, new OString("-3.1")},
2929*cdf0e10cSrcweir // LLA:         {3.1, 1e-2, new OString("+3.1")},
2930*cdf0e10cSrcweir // LLA:         {0.0, 1e-2, new OString("-0.0")}
2931*cdf0e10cSrcweir // LLA:     };
2932*cdf0e10cSrcweir // LLA:
2933*cdf0e10cSrcweir // LLA:     sal_Bool res = sal_True;
2934*cdf0e10cSrcweir // LLA:     sal_Int32 i;
2935*cdf0e10cSrcweir // LLA:
2936*cdf0e10cSrcweir // LLA:     for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++ )
2937*cdf0e10cSrcweir // LLA:     {
2938*cdf0e10cSrcweir // LLA:         double dRes = arrTestCase[i].input1->toDouble();
2939*cdf0e10cSrcweir // LLA:         double dErg = dRes - arrTestCase[i].expVal ;
2940*cdf0e10cSrcweir // LLA:         double dComp = fabs( dErg );
2941*cdf0e10cSrcweir // LLA:         sal_Bool lastRes = ( dComp <= arrTestCase[i].expDiff );
2942*cdf0e10cSrcweir // LLA:
2943*cdf0e10cSrcweir // LLA:         char com[MAXBUFLENGTH];
2944*cdf0e10cSrcweir // LLA:         com[0] = '\'';
2945*cdf0e10cSrcweir // LLA:         cpynstr(com + 1, (*arrTestCase[i].input1), MAXBUFLENGTH);
2946*cdf0e10cSrcweir // LLA:         int length = AStringLen( (*arrTestCase[i].input1) );
2947*cdf0e10cSrcweir // LLA:         com[length + 1] = '\'';
2948*cdf0e10cSrcweir // LLA:         com[length + 2] = 0;
2949*cdf0e10cSrcweir // LLA:
2950*cdf0e10cSrcweir // LLA:         c_rtl_tres_state
2951*cdf0e10cSrcweir // LLA:         (
2952*cdf0e10cSrcweir // LLA:             hRtlTestResult,
2953*cdf0e10cSrcweir // LLA:             lastRes,
2954*cdf0e10cSrcweir // LLA:             com,
2955*cdf0e10cSrcweir // LLA:             createName( pMeth, "toDouble", i )
2956*cdf0e10cSrcweir // LLA:         );
2957*cdf0e10cSrcweir // LLA:
2958*cdf0e10cSrcweir // LLA:     }
2959*cdf0e10cSrcweir // LLA:
2960*cdf0e10cSrcweir // LLA:     c_rtl_tres_state_end(hRtlTestResult, "toDouble");
2961*cdf0e10cSrcweir // LLA: //    return (res);
2962*cdf0e10cSrcweir // LLA: }
2963*cdf0e10cSrcweir 
2964*cdf0e10cSrcweir //------------------------------------------------------------------------
2965*cdf0e10cSrcweir // testing the method toBoolean()
2966*cdf0e10cSrcweir //------------------------------------------------------------------------
2967*cdf0e10cSrcweir 
2968*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toBoolean(
2969*cdf0e10cSrcweir                                             hTestResult hRtlTestResult)
2970*cdf0e10cSrcweir {
2971*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
2972*cdf0e10cSrcweir     sal_Char* pMeth = methName;
2973*cdf0e10cSrcweir 
2974*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toBoolean");
2975*cdf0e10cSrcweir     typedef struct TestCase
2976*cdf0e10cSrcweir     {
2977*cdf0e10cSrcweir     sal_Char*                    comments;
2978*cdf0e10cSrcweir     sal_Bool                     expVal;
2979*cdf0e10cSrcweir     OString*                     input;
2980*cdf0e10cSrcweir 
2981*cdf0e10cSrcweir     } TestCase;
2982*cdf0e10cSrcweir 
2983*cdf0e10cSrcweir     TestCase arrTestCase[]={
2984*cdf0e10cSrcweir 
2985*cdf0e10cSrcweir     {"expected true", sal_True, new OString("True")},
2986*cdf0e10cSrcweir     {"expected false", sal_False, new OString("False")},
2987*cdf0e10cSrcweir     {"expected true", sal_True, new OString("1")}
2988*cdf0e10cSrcweir     };
2989*cdf0e10cSrcweir 
2990*cdf0e10cSrcweir 
2991*cdf0e10cSrcweir     sal_Bool res = sal_True;
2992*cdf0e10cSrcweir     sal_uInt32 i;
2993*cdf0e10cSrcweir 
2994*cdf0e10cSrcweir     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2995*cdf0e10cSrcweir     {
2996*cdf0e10cSrcweir         sal_Bool bRes = arrTestCase[i].input->toBoolean();
2997*cdf0e10cSrcweir         sal_Bool lastRes = (bRes == arrTestCase[i].expVal);
2998*cdf0e10cSrcweir         c_rtl_tres_state
2999*cdf0e10cSrcweir         (
3000*cdf0e10cSrcweir             hRtlTestResult,
3001*cdf0e10cSrcweir             lastRes,
3002*cdf0e10cSrcweir             arrTestCase[i].comments,
3003*cdf0e10cSrcweir             createName( pMeth, "toBoolean", i )
3004*cdf0e10cSrcweir 
3005*cdf0e10cSrcweir         );
3006*cdf0e10cSrcweir         res &= lastRes;
3007*cdf0e10cSrcweir     }
3008*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toBoolean");
3009*cdf0e10cSrcweir //     return ( res );
3010*cdf0e10cSrcweir }
3011*cdf0e10cSrcweir 
3012*cdf0e10cSrcweir 
3013*cdf0e10cSrcweir 
3014*cdf0e10cSrcweir //------------------------------------------------------------------------
3015*cdf0e10cSrcweir // testing the method toInt32( sal_Int16 radix = 2,8,10,16,36 )
3016*cdf0e10cSrcweir //------------------------------------------------------------------------
3017*cdf0e10cSrcweir sal_Bool test_toInt32(  int num, const sal_Char** in,
3018*cdf0e10cSrcweir const sal_Int32 *expVal,sal_Int16 radix, hTestResult hRtlTestResult )
3019*cdf0e10cSrcweir {
3020*cdf0e10cSrcweir     sal_Bool res = sal_True;
3021*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
3022*cdf0e10cSrcweir     sal_Char* pMeth = methName;
3023*cdf0e10cSrcweir     sal_Int32 i;
3024*cdf0e10cSrcweir 
3025*cdf0e10cSrcweir     for( i = 0; i < num; i++ )
3026*cdf0e10cSrcweir     {
3027*cdf0e10cSrcweir         OString str(in[i]);
3028*cdf0e10cSrcweir         sal_Int32 intRes = str.toInt32(radix);
3029*cdf0e10cSrcweir         sal_Bool lastRes = (intRes == expVal[i]);
3030*cdf0e10cSrcweir 
3031*cdf0e10cSrcweir         char buf[MAXBUFLENGTH];
3032*cdf0e10cSrcweir         buf[0] = '\'';
3033*cdf0e10cSrcweir         cpynstr( buf + 1, in[i], MAXBUFLENGTH );
3034*cdf0e10cSrcweir         int length = AStringLen( in[i] );
3035*cdf0e10cSrcweir         buf[length + 1] = '\'';
3036*cdf0e10cSrcweir         buf[length + 2] = 0;
3037*cdf0e10cSrcweir 
3038*cdf0e10cSrcweir         c_rtl_tres_state
3039*cdf0e10cSrcweir         (
3040*cdf0e10cSrcweir             hRtlTestResult,
3041*cdf0e10cSrcweir             lastRes,
3042*cdf0e10cSrcweir             buf,
3043*cdf0e10cSrcweir             createName( pMeth,"toInt32", i )
3044*cdf0e10cSrcweir         );
3045*cdf0e10cSrcweir 
3046*cdf0e10cSrcweir         res &= lastRes;
3047*cdf0e10cSrcweir     }
3048*cdf0e10cSrcweir 
3049*cdf0e10cSrcweir     return( res );
3050*cdf0e10cSrcweir }
3051*cdf0e10cSrcweir 
3052*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_toInt32_wrongRadix(
3053*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
3054*cdf0e10cSrcweir {
3055*cdf0e10cSrcweir     ::rtl::OString str("0");
3056*cdf0e10cSrcweir 
3057*cdf0e10cSrcweir     sal_Int32 iRes = str.toInt32(-1);
3058*cdf0e10cSrcweir 
3059*cdf0e10cSrcweir     return
3060*cdf0e10cSrcweir     (
3061*cdf0e10cSrcweir         c_rtl_tres_state
3062*cdf0e10cSrcweir         (
3063*cdf0e10cSrcweir             hRtlTestResult,
3064*cdf0e10cSrcweir             iRes == 0,
3065*cdf0e10cSrcweir             "wrong radix -1",
3066*cdf0e10cSrcweir             "toInt32( 0, wrong radix -1 )"
3067*cdf0e10cSrcweir         )
3068*cdf0e10cSrcweir     );
3069*cdf0e10cSrcweir }
3070*cdf0e10cSrcweir 
3071*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toInt32(
3072*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
3073*cdf0e10cSrcweir {
3074*cdf0e10cSrcweir     sal_Int32 expValues[kBase36NumsCount];
3075*cdf0e10cSrcweir     sal_Int32 i;
3076*cdf0e10cSrcweir 
3077*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toInt32");
3078*cdf0e10cSrcweir     for ( i = 0; i < kBase36NumsCount; i++ )
3079*cdf0e10cSrcweir             expValues[i] = i;
3080*cdf0e10cSrcweir 
3081*cdf0e10cSrcweir     sal_Bool res = c_rtl_tres_state
3082*cdf0e10cSrcweir     (
3083*cdf0e10cSrcweir         hRtlTestResult,
3084*cdf0e10cSrcweir         test_toInt32( kBinaryNumsCount, kBinaryNumsStr,
3085*cdf0e10cSrcweir                                 expValues, kRadixBinary, hRtlTestResult ),
3086*cdf0e10cSrcweir         "kBinaryNumsStr",
3087*cdf0e10cSrcweir         "toInt32( radix 2 )"
3088*cdf0e10cSrcweir     );
3089*cdf0e10cSrcweir     res &= c_rtl_tres_state
3090*cdf0e10cSrcweir     (
3091*cdf0e10cSrcweir         hRtlTestResult,
3092*cdf0e10cSrcweir         test_toInt32( kInt32MaxNumsCount, kBinaryMaxNumsStr,
3093*cdf0e10cSrcweir                             kInt32MaxNums, kRadixBinary, hRtlTestResult ),
3094*cdf0e10cSrcweir         "kBinaryMaxNumsStr",
3095*cdf0e10cSrcweir         "toInt32_Boundaries( radix 2 )"
3096*cdf0e10cSrcweir     );
3097*cdf0e10cSrcweir 
3098*cdf0e10cSrcweir     res &= c_rtl_tres_state
3099*cdf0e10cSrcweir     (
3100*cdf0e10cSrcweir         hRtlTestResult,
3101*cdf0e10cSrcweir         test_toInt32( kOctolNumsCount, kOctolNumsStr,
3102*cdf0e10cSrcweir                             expValues, kRadixOctol, hRtlTestResult ),
3103*cdf0e10cSrcweir         "kOctolNumsStr",
3104*cdf0e10cSrcweir         "toInt32( radix 8 )"
3105*cdf0e10cSrcweir     );
3106*cdf0e10cSrcweir 
3107*cdf0e10cSrcweir     res &= c_rtl_tres_state
3108*cdf0e10cSrcweir     (
3109*cdf0e10cSrcweir         hRtlTestResult,
3110*cdf0e10cSrcweir         test_toInt32( kInt32MaxNumsCount, kOctolMaxNumsStr,
3111*cdf0e10cSrcweir                     (sal_Int32*)kInt32MaxNums, kRadixOctol, hRtlTestResult ),
3112*cdf0e10cSrcweir         "kOctolMaxNumsStr",
3113*cdf0e10cSrcweir         "toInt32_Boundaries( radix 8 )"
3114*cdf0e10cSrcweir     );
3115*cdf0e10cSrcweir 
3116*cdf0e10cSrcweir     res &= c_rtl_tres_state
3117*cdf0e10cSrcweir     (
3118*cdf0e10cSrcweir         hRtlTestResult,
3119*cdf0e10cSrcweir         test_toInt32( kDecimalNumsCount, kDecimalNumsStr, expValues,
3120*cdf0e10cSrcweir                                             kRadixDecimal, hRtlTestResult ),
3121*cdf0e10cSrcweir         "kDecimalNumsStr",
3122*cdf0e10cSrcweir         "toInt32( radix 10 )"
3123*cdf0e10cSrcweir     );
3124*cdf0e10cSrcweir 
3125*cdf0e10cSrcweir     res &= c_rtl_tres_state
3126*cdf0e10cSrcweir     (
3127*cdf0e10cSrcweir         hRtlTestResult,
3128*cdf0e10cSrcweir         test_toInt32( kInt32MaxNumsCount, kDecimalMaxNumsStr,
3129*cdf0e10cSrcweir                 (sal_Int32*)kInt32MaxNums, kRadixDecimal, hRtlTestResult ),
3130*cdf0e10cSrcweir         "kDecimalMaxNumsStr",
3131*cdf0e10cSrcweir         "toInt32_Boundaries( radix 10 )"
3132*cdf0e10cSrcweir     );
3133*cdf0e10cSrcweir 
3134*cdf0e10cSrcweir     res &= c_rtl_tres_state
3135*cdf0e10cSrcweir     (
3136*cdf0e10cSrcweir         hRtlTestResult,
3137*cdf0e10cSrcweir         test_toInt32( kHexDecimalNumsCount, kHexDecimalNumsStr, expValues,
3138*cdf0e10cSrcweir                                         kRadixHexdecimal, hRtlTestResult ),
3139*cdf0e10cSrcweir         "kHexDecimalNumsStr",
3140*cdf0e10cSrcweir         "toInt32( radix 16 )"
3141*cdf0e10cSrcweir     );
3142*cdf0e10cSrcweir 
3143*cdf0e10cSrcweir     res &= c_rtl_tres_state
3144*cdf0e10cSrcweir     (
3145*cdf0e10cSrcweir         hRtlTestResult,
3146*cdf0e10cSrcweir         test_toInt32( kInt32MaxNumsCount, kHexDecimalMaxNumsStr,
3147*cdf0e10cSrcweir             (sal_Int32*)kInt32MaxNums, kRadixHexdecimal, hRtlTestResult ),
3148*cdf0e10cSrcweir         "kHexDecimalMaxNumsStr",
3149*cdf0e10cSrcweir         "toInt32_Boundaries( radix 16 )"
3150*cdf0e10cSrcweir     );
3151*cdf0e10cSrcweir 
3152*cdf0e10cSrcweir     res &= c_rtl_tres_state
3153*cdf0e10cSrcweir     (
3154*cdf0e10cSrcweir         hRtlTestResult,
3155*cdf0e10cSrcweir         test_toInt32( kBase36NumsCount, kBase36NumsStr, expValues,
3156*cdf0e10cSrcweir                                             kRadixBase36, hRtlTestResult ),
3157*cdf0e10cSrcweir         "kBase36NumsStr",
3158*cdf0e10cSrcweir         "toInt32( radix 36 )"
3159*cdf0e10cSrcweir     );
3160*cdf0e10cSrcweir 
3161*cdf0e10cSrcweir     res &= c_rtl_tres_state
3162*cdf0e10cSrcweir     (
3163*cdf0e10cSrcweir         hRtlTestResult,
3164*cdf0e10cSrcweir         test_toInt32( kInt32MaxNumsCount, kBase36MaxNumsStr,
3165*cdf0e10cSrcweir                 (sal_Int32*)kInt32MaxNums, kRadixBase36, hRtlTestResult ),
3166*cdf0e10cSrcweir         "kBase36MaxNumsStr",
3167*cdf0e10cSrcweir         "toInt32_Boundaries( radix 36 )"
3168*cdf0e10cSrcweir     );
3169*cdf0e10cSrcweir 
3170*cdf0e10cSrcweir     const sal_Int16 nSpecCases = 5;
3171*cdf0e10cSrcweir     static const sal_Char *spString[nSpecCases] =
3172*cdf0e10cSrcweir     {
3173*cdf0e10cSrcweir         "-1",
3174*cdf0e10cSrcweir         "+1",
3175*cdf0e10cSrcweir         " 1",
3176*cdf0e10cSrcweir         " -1",
3177*cdf0e10cSrcweir         "001"
3178*cdf0e10cSrcweir     };
3179*cdf0e10cSrcweir 
3180*cdf0e10cSrcweir     sal_Int32 expSpecVal[nSpecCases] =
3181*cdf0e10cSrcweir     {
3182*cdf0e10cSrcweir         -1,
3183*cdf0e10cSrcweir         1,
3184*cdf0e10cSrcweir         1,
3185*cdf0e10cSrcweir         -1,
3186*cdf0e10cSrcweir         1
3187*cdf0e10cSrcweir     };
3188*cdf0e10cSrcweir 
3189*cdf0e10cSrcweir     res &= c_rtl_tres_state
3190*cdf0e10cSrcweir     (
3191*cdf0e10cSrcweir         hRtlTestResult,
3192*cdf0e10cSrcweir         test_toInt32( nSpecCases, spString, expSpecVal,
3193*cdf0e10cSrcweir                                             kRadixDecimal, hRtlTestResult ),
3194*cdf0e10cSrcweir         "special cases",
3195*cdf0e10cSrcweir         "toInt32( specialcases )"
3196*cdf0e10cSrcweir     );
3197*cdf0e10cSrcweir 
3198*cdf0e10cSrcweir     res &= test_rtl_OString_toInt32_wrongRadix( hRtlTestResult );
3199*cdf0e10cSrcweir 
3200*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toInt32");
3201*cdf0e10cSrcweir //    return ( res );
3202*cdf0e10cSrcweir }
3203*cdf0e10cSrcweir 
3204*cdf0e10cSrcweir //------------------------------------------------------------------------
3205*cdf0e10cSrcweir // testing the method toInt64( sal_Int16 radix = 2,8,10,16,36 )
3206*cdf0e10cSrcweir //------------------------------------------------------------------------
3207*cdf0e10cSrcweir sal_Bool test_toInt64( int num, const sal_Char** in,
3208*cdf0e10cSrcweir const sal_Int64 *expVal,sal_Int16 radix, hTestResult hRtlTestResult )
3209*cdf0e10cSrcweir {
3210*cdf0e10cSrcweir     sal_Bool res = sal_True;
3211*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
3212*cdf0e10cSrcweir     sal_Char* pMeth = methName;
3213*cdf0e10cSrcweir     sal_Int32 i;
3214*cdf0e10cSrcweir 
3215*cdf0e10cSrcweir     for( i = 0; i < num; i++ )
3216*cdf0e10cSrcweir     {
3217*cdf0e10cSrcweir         OString str( in[i] );
3218*cdf0e10cSrcweir         sal_Int64 intRes = str.toInt64( radix );
3219*cdf0e10cSrcweir         sal_Bool lastRes = ( intRes == expVal[i] );
3220*cdf0e10cSrcweir 
3221*cdf0e10cSrcweir         char buf[MAXBUFLENGTH];
3222*cdf0e10cSrcweir         buf[0] = '\'';
3223*cdf0e10cSrcweir         cpynstr( buf + 1, in[i], MAXBUFLENGTH );
3224*cdf0e10cSrcweir         int length = AStringLen(in[i]);
3225*cdf0e10cSrcweir         buf[length + 1] = '\'';
3226*cdf0e10cSrcweir         buf[length + 2] = 0;
3227*cdf0e10cSrcweir 
3228*cdf0e10cSrcweir         c_rtl_tres_state
3229*cdf0e10cSrcweir         (
3230*cdf0e10cSrcweir             hRtlTestResult,
3231*cdf0e10cSrcweir             lastRes,
3232*cdf0e10cSrcweir             buf,
3233*cdf0e10cSrcweir             createName( pMeth, "toInt64", i )
3234*cdf0e10cSrcweir         );
3235*cdf0e10cSrcweir 
3236*cdf0e10cSrcweir         res &= lastRes;
3237*cdf0e10cSrcweir     }
3238*cdf0e10cSrcweir     return (res);
3239*cdf0e10cSrcweir }
3240*cdf0e10cSrcweir 
3241*cdf0e10cSrcweir sal_Bool SAL_CALL test_rtl_OString_toInt64_wrongRadix(
3242*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
3243*cdf0e10cSrcweir {
3244*cdf0e10cSrcweir     ::rtl::OString str("0");
3245*cdf0e10cSrcweir 
3246*cdf0e10cSrcweir     sal_Int64 iRes = str.toInt64(-1);
3247*cdf0e10cSrcweir 
3248*cdf0e10cSrcweir     return (
3249*cdf0e10cSrcweir 
3250*cdf0e10cSrcweir         c_rtl_tres_state
3251*cdf0e10cSrcweir         ( hRtlTestResult,
3252*cdf0e10cSrcweir           iRes == 0,
3253*cdf0e10cSrcweir           "wrong radix -1",
3254*cdf0e10cSrcweir           "toInt64( wrong radix -1)"
3255*cdf0e10cSrcweir         )
3256*cdf0e10cSrcweir      );
3257*cdf0e10cSrcweir }
3258*cdf0e10cSrcweir 
3259*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toInt64(
3260*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult )
3261*cdf0e10cSrcweir {
3262*cdf0e10cSrcweir     sal_Int64 expValues[kBase36NumsCount];
3263*cdf0e10cSrcweir     sal_Int32 i;
3264*cdf0e10cSrcweir 
3265*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "toInt64");
3266*cdf0e10cSrcweir     for (i = 0; i < kBase36NumsCount; expValues[i] = i, i++);
3267*cdf0e10cSrcweir 
3268*cdf0e10cSrcweir     sal_Bool res = c_rtl_tres_state
3269*cdf0e10cSrcweir     (
3270*cdf0e10cSrcweir         hRtlTestResult,
3271*cdf0e10cSrcweir         test_toInt64( kBinaryNumsCount, kBinaryNumsStr, expValues,
3272*cdf0e10cSrcweir                                             kRadixBinary, hRtlTestResult ),
3273*cdf0e10cSrcweir         "kBinaryNumsStr",
3274*cdf0e10cSrcweir         "toInt64( radix 2 )"
3275*cdf0e10cSrcweir     );
3276*cdf0e10cSrcweir 
3277*cdf0e10cSrcweir     res &= c_rtl_tres_state
3278*cdf0e10cSrcweir     (
3279*cdf0e10cSrcweir         hRtlTestResult,
3280*cdf0e10cSrcweir         test_toInt64( kInt32MaxNumsCount, kBinaryMaxNumsStr,
3281*cdf0e10cSrcweir                 (sal_Int64*)kInt64MaxNums, kRadixBinary, hRtlTestResult ),
3282*cdf0e10cSrcweir         "kBinaryMaxNumsStr",
3283*cdf0e10cSrcweir         "toInt64_Boundaries( radix 2 )"
3284*cdf0e10cSrcweir     );
3285*cdf0e10cSrcweir 
3286*cdf0e10cSrcweir     res &= c_rtl_tres_state
3287*cdf0e10cSrcweir     (
3288*cdf0e10cSrcweir         hRtlTestResult,
3289*cdf0e10cSrcweir         test_toInt64( kOctolNumsCount, kOctolNumsStr, expValues,
3290*cdf0e10cSrcweir                                             kRadixOctol, hRtlTestResult ),
3291*cdf0e10cSrcweir         "kOctolNumsStr",
3292*cdf0e10cSrcweir         "toInt64( radix 8 )"
3293*cdf0e10cSrcweir     );
3294*cdf0e10cSrcweir 
3295*cdf0e10cSrcweir     res &= c_rtl_tres_state
3296*cdf0e10cSrcweir     (
3297*cdf0e10cSrcweir         hRtlTestResult,
3298*cdf0e10cSrcweir         test_toInt64( kInt32MaxNumsCount, kOctolMaxNumsStr,
3299*cdf0e10cSrcweir                     (sal_Int64*)kInt64MaxNums, kRadixOctol, hRtlTestResult ),
3300*cdf0e10cSrcweir         "kOctolMaxNumsStr",
3301*cdf0e10cSrcweir         "toInt64_Boundaries( radix 8 )"
3302*cdf0e10cSrcweir     );
3303*cdf0e10cSrcweir 
3304*cdf0e10cSrcweir     res &= c_rtl_tres_state
3305*cdf0e10cSrcweir     (
3306*cdf0e10cSrcweir         hRtlTestResult,
3307*cdf0e10cSrcweir         test_toInt64( kDecimalNumsCount, kDecimalNumsStr, expValues,
3308*cdf0e10cSrcweir                                             kRadixDecimal, hRtlTestResult ),
3309*cdf0e10cSrcweir         "kDecimalNumsStr",
3310*cdf0e10cSrcweir         "toInt64( radix 10 )"
3311*cdf0e10cSrcweir     );
3312*cdf0e10cSrcweir 
3313*cdf0e10cSrcweir     res &= c_rtl_tres_state
3314*cdf0e10cSrcweir     (
3315*cdf0e10cSrcweir         hRtlTestResult,
3316*cdf0e10cSrcweir         test_toInt64( kInt32MaxNumsCount, kDecimalMaxNumsStr,
3317*cdf0e10cSrcweir                 (sal_Int64*)kInt64MaxNums, kRadixDecimal, hRtlTestResult ),
3318*cdf0e10cSrcweir         "kDecimalMaxNumsStr",
3319*cdf0e10cSrcweir         "toInt64_Boundaries( radix 10 )"
3320*cdf0e10cSrcweir     );
3321*cdf0e10cSrcweir 
3322*cdf0e10cSrcweir     res &= c_rtl_tres_state
3323*cdf0e10cSrcweir     (
3324*cdf0e10cSrcweir         hRtlTestResult,
3325*cdf0e10cSrcweir         test_toInt64( kHexDecimalNumsCount, kHexDecimalNumsStr, expValues,
3326*cdf0e10cSrcweir                                         kRadixHexdecimal, hRtlTestResult ),
3327*cdf0e10cSrcweir         "kHexDecimalNumsStr",
3328*cdf0e10cSrcweir         "toInt64( radix 16 )"
3329*cdf0e10cSrcweir     );
3330*cdf0e10cSrcweir 
3331*cdf0e10cSrcweir     res &= c_rtl_tres_state
3332*cdf0e10cSrcweir     (
3333*cdf0e10cSrcweir         hRtlTestResult,
3334*cdf0e10cSrcweir         test_toInt64( kInt32MaxNumsCount, kHexDecimalMaxNumsStr,
3335*cdf0e10cSrcweir             (sal_Int64*)kInt64MaxNums, kRadixHexdecimal, hRtlTestResult ),
3336*cdf0e10cSrcweir         "kHexDecimalMaxNumsStr",
3337*cdf0e10cSrcweir         "toInt64_Boundaries( radix 16 )"
3338*cdf0e10cSrcweir     );
3339*cdf0e10cSrcweir 
3340*cdf0e10cSrcweir     res &= c_rtl_tres_state
3341*cdf0e10cSrcweir     (
3342*cdf0e10cSrcweir         hRtlTestResult,
3343*cdf0e10cSrcweir         test_toInt64( kBase36NumsCount, kBase36NumsStr, expValues,
3344*cdf0e10cSrcweir                                            kRadixBase36, hRtlTestResult ),
3345*cdf0e10cSrcweir         "kBase36NumsStr",
3346*cdf0e10cSrcweir         "toInt64( radix 36 )"
3347*cdf0e10cSrcweir     );
3348*cdf0e10cSrcweir 
3349*cdf0e10cSrcweir     res &= c_rtl_tres_state
3350*cdf0e10cSrcweir     (
3351*cdf0e10cSrcweir         hRtlTestResult,
3352*cdf0e10cSrcweir         test_toInt64( kInt32MaxNumsCount, kBase36MaxNumsStr,
3353*cdf0e10cSrcweir             (sal_Int64*)kInt64MaxNums, kRadixBase36, hRtlTestResult ),
3354*cdf0e10cSrcweir         "kBase36MaxNumsStr",
3355*cdf0e10cSrcweir         "toInt64_Boundaries( radix 36 )"
3356*cdf0e10cSrcweir     );
3357*cdf0e10cSrcweir 
3358*cdf0e10cSrcweir 
3359*cdf0e10cSrcweir 
3360*cdf0e10cSrcweir     const sal_Int16 nSpecCases = 5;
3361*cdf0e10cSrcweir     static const sal_Char *spString[nSpecCases] =
3362*cdf0e10cSrcweir     {
3363*cdf0e10cSrcweir         "-1",
3364*cdf0e10cSrcweir         "+1",
3365*cdf0e10cSrcweir         " 1",
3366*cdf0e10cSrcweir         " -1",
3367*cdf0e10cSrcweir         "001"
3368*cdf0e10cSrcweir     };
3369*cdf0e10cSrcweir 
3370*cdf0e10cSrcweir     sal_Int64 expSpecVal[nSpecCases] =
3371*cdf0e10cSrcweir     {
3372*cdf0e10cSrcweir         -1,
3373*cdf0e10cSrcweir         1,
3374*cdf0e10cSrcweir         1,
3375*cdf0e10cSrcweir         -1,
3376*cdf0e10cSrcweir         1
3377*cdf0e10cSrcweir     };
3378*cdf0e10cSrcweir 
3379*cdf0e10cSrcweir     res &= c_rtl_tres_state
3380*cdf0e10cSrcweir     (
3381*cdf0e10cSrcweir         hRtlTestResult,
3382*cdf0e10cSrcweir         test_toInt64( nSpecCases, spString, expSpecVal,
3383*cdf0e10cSrcweir                                         kRadixDecimal, hRtlTestResult ),
3384*cdf0e10cSrcweir         "special cases",
3385*cdf0e10cSrcweir         "toInt64( specialcases )"
3386*cdf0e10cSrcweir     );
3387*cdf0e10cSrcweir 
3388*cdf0e10cSrcweir     res &= test_rtl_OString_toInt64_wrongRadix( hRtlTestResult );
3389*cdf0e10cSrcweir 
3390*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "toInt64");
3391*cdf0e10cSrcweir //    return (res);
3392*cdf0e10cSrcweir }
3393*cdf0e10cSrcweir 
3394*cdf0e10cSrcweir //------------------------------------------------------------------------
3395*cdf0e10cSrcweir // testing the method replace( sal_Char oldChar, sal_Char newChar )
3396*cdf0e10cSrcweir //------------------------------------------------------------------------
3397*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_replace(
3398*cdf0e10cSrcweir                                             hTestResult hRtlTestResult)
3399*cdf0e10cSrcweir {
3400*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
3401*cdf0e10cSrcweir     sal_Char* pMeth = methName;
3402*cdf0e10cSrcweir 
3403*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "replace");
3404*cdf0e10cSrcweir typedef struct TestCase
3405*cdf0e10cSrcweir {
3406*cdf0e10cSrcweir     sal_Char*                    comments;
3407*cdf0e10cSrcweir     OString*                     expVal;
3408*cdf0e10cSrcweir     OString*                     input;
3409*cdf0e10cSrcweir     sal_Char                     oldChar;
3410*cdf0e10cSrcweir     sal_Char                     newChar;
3411*cdf0e10cSrcweir 
3412*cdf0e10cSrcweir     ~TestCase() { delete input; delete expVal;}
3413*cdf0e10cSrcweir } TestCase;
3414*cdf0e10cSrcweir 
3415*cdf0e10cSrcweir TestCase arrTestCase[]={
3416*cdf0e10cSrcweir 
3417*cdf0e10cSrcweir     {"string differs", new OString(kTestStr18),
3418*cdf0e10cSrcweir         new OString(kTestStr4),'S','s'},
3419*cdf0e10cSrcweir     {"string differs", new OString(kTestStr19),
3420*cdf0e10cSrcweir         new OString(kTestStr17),(sal_Char)' ',(sal_Char)'-'},
3421*cdf0e10cSrcweir     {"same string, no replace ", new OString(kTestStr22),
3422*cdf0e10cSrcweir         new OString(kTestStr22),'*','8'}
3423*cdf0e10cSrcweir     };
3424*cdf0e10cSrcweir 
3425*cdf0e10cSrcweir 
3426*cdf0e10cSrcweir     sal_Bool res = sal_True;
3427*cdf0e10cSrcweir     sal_uInt32 i;
3428*cdf0e10cSrcweir 
3429*cdf0e10cSrcweir     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3430*cdf0e10cSrcweir     {
3431*cdf0e10cSrcweir         ::rtl::OString aStr1;
3432*cdf0e10cSrcweir         aStr1= arrTestCase[i].input->replace(arrTestCase[i].oldChar,
3433*cdf0e10cSrcweir                             arrTestCase[i].newChar);
3434*cdf0e10cSrcweir 
3435*cdf0e10cSrcweir         res &= c_rtl_tres_state
3436*cdf0e10cSrcweir                         (
3437*cdf0e10cSrcweir                             hRtlTestResult,
3438*cdf0e10cSrcweir                             (arrTestCase[i].expVal->compareTo(aStr1) == 0),
3439*cdf0e10cSrcweir                             arrTestCase[i].comments,
3440*cdf0e10cSrcweir                             createName( pMeth, "replace", i )
3441*cdf0e10cSrcweir 
3442*cdf0e10cSrcweir                         );
3443*cdf0e10cSrcweir     }
3444*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "replace");
3445*cdf0e10cSrcweir //     return ( res );
3446*cdf0e10cSrcweir }
3447*cdf0e10cSrcweir 
3448*cdf0e10cSrcweir 
3449*cdf0e10cSrcweir 
3450*cdf0e10cSrcweir //------------------------------------------------------------------------
3451*cdf0e10cSrcweir // testing the method replaceAt( sal_Int32 index, sal_Int32 count,
3452*cdf0e10cSrcweir // const OString& newStr )
3453*cdf0e10cSrcweir //------------------------------------------------------------------------
3454*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_replaceAt(
3455*cdf0e10cSrcweir                                                 hTestResult hRtlTestResult)
3456*cdf0e10cSrcweir {
3457*cdf0e10cSrcweir     sal_Char methName[MAXBUFLENGTH];
3458*cdf0e10cSrcweir     sal_Char* pMeth = methName;
3459*cdf0e10cSrcweir 
3460*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "replaceAt");
3461*cdf0e10cSrcweir     typedef struct TestCase
3462*cdf0e10cSrcweir     {
3463*cdf0e10cSrcweir         sal_Char*                    comments;
3464*cdf0e10cSrcweir         OString*                     expVal;
3465*cdf0e10cSrcweir         OString*                     input;
3466*cdf0e10cSrcweir         OString*                     newStr;
3467*cdf0e10cSrcweir         sal_Int32                    index;
3468*cdf0e10cSrcweir         sal_Int32                    count;
3469*cdf0e10cSrcweir 
3470*cdf0e10cSrcweir         ~TestCase() { delete input; delete expVal; delete newStr;}
3471*cdf0e10cSrcweir     } TestCase;
3472*cdf0e10cSrcweir 
3473*cdf0e10cSrcweir     TestCase arrTestCase[]=
3474*cdf0e10cSrcweir     {
3475*cdf0e10cSrcweir 
3476*cdf0e10cSrcweir         { "string differs", new OString(kTestStr2), new OString(kTestStr22),
3477*cdf0e10cSrcweir                                 new OString(kTestStr2), 0, kTestStr22Len },
3478*cdf0e10cSrcweir 
3479*cdf0e10cSrcweir         { "larger index", new OString(kTestStr1), new OString(kTestStr7),
3480*cdf0e10cSrcweir                                 new OString(kTestStr8), 64, kTestStr8Len },
3481*cdf0e10cSrcweir 
3482*cdf0e10cSrcweir         { "larger count", new OString(kTestStr2), new OString(kTestStr22),
3483*cdf0e10cSrcweir                                 new OString(kTestStr2),0, 64 },
3484*cdf0e10cSrcweir 
3485*cdf0e10cSrcweir         { "navigate index", new OString(kTestStr2), new OString(kTestStr22),
3486*cdf0e10cSrcweir                                 new OString(kTestStr2), -64, 64 },
3487*cdf0e10cSrcweir 
3488*cdf0e10cSrcweir         { "null string", new OString(""),
3489*cdf0e10cSrcweir                 new OString(kTestStr14),new OString(""), 0, kTestStr14Len }
3490*cdf0e10cSrcweir     };
3491*cdf0e10cSrcweir 
3492*cdf0e10cSrcweir     sal_Bool res = sal_True;
3493*cdf0e10cSrcweir     sal_uInt32 i;
3494*cdf0e10cSrcweir 
3495*cdf0e10cSrcweir     for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3496*cdf0e10cSrcweir     {
3497*cdf0e10cSrcweir         ::rtl::OString aStr1;
3498*cdf0e10cSrcweir         aStr1= arrTestCase[i].input->replaceAt( arrTestCase[i].index,
3499*cdf0e10cSrcweir                             arrTestCase[i].count, *arrTestCase[i].newStr );
3500*cdf0e10cSrcweir 
3501*cdf0e10cSrcweir         sal_Bool lastRes = ( arrTestCase[i].expVal->compareTo(aStr1) == 0 );
3502*cdf0e10cSrcweir 
3503*cdf0e10cSrcweir         c_rtl_tres_state
3504*cdf0e10cSrcweir         (
3505*cdf0e10cSrcweir             hRtlTestResult,
3506*cdf0e10cSrcweir             lastRes,
3507*cdf0e10cSrcweir             arrTestCase[i].comments,
3508*cdf0e10cSrcweir             createName( pMeth, "replaceAt", i )
3509*cdf0e10cSrcweir 
3510*cdf0e10cSrcweir         );
3511*cdf0e10cSrcweir         res &= lastRes;
3512*cdf0e10cSrcweir     }
3513*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "replaceAt");
3514*cdf0e10cSrcweir //     return ( res );
3515*cdf0e10cSrcweir }
3516*cdf0e10cSrcweir 
3517*cdf0e10cSrcweir extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString( hTestResult hRtlTestResult )
3518*cdf0e10cSrcweir {
3519*cdf0e10cSrcweir 
3520*cdf0e10cSrcweir     c_rtl_tres_state_start(hRtlTestResult, "rtl_OString" );
3521*cdf0e10cSrcweir 
3522*cdf0e10cSrcweir     test_rtl_OString_ctors( hRtlTestResult );
3523*cdf0e10cSrcweir     test_rtl_OString_getLength( hRtlTestResult );
3524*cdf0e10cSrcweir     test_rtl_OString_equals( hRtlTestResult );
3525*cdf0e10cSrcweir     test_rtl_OString_equalsIgnoreAsciiCase( hRtlTestResult );
3526*cdf0e10cSrcweir     test_rtl_OString_compareTo( hRtlTestResult );
3527*cdf0e10cSrcweir     test_rtl_OString_op_cmp( hRtlTestResult );
3528*cdf0e10cSrcweir     test_rtl_OString_op_neq( hRtlTestResult );
3529*cdf0e10cSrcweir     test_rtl_OString_op_g( hRtlTestResult );
3530*cdf0e10cSrcweir     test_rtl_OString_op_l( hRtlTestResult );
3531*cdf0e10cSrcweir     test_rtl_OString_op_ge( hRtlTestResult );
3532*cdf0e10cSrcweir     test_rtl_OString_op_le( hRtlTestResult );
3533*cdf0e10cSrcweir     test_rtl_OString_op_eq( hRtlTestResult );
3534*cdf0e10cSrcweir     test_rtl_OString_op_plus( hRtlTestResult );
3535*cdf0e10cSrcweir     test_rtl_OString_op_peq( hRtlTestResult );
3536*cdf0e10cSrcweir     test_rtl_OString_op_cscs( hRtlTestResult );
3537*cdf0e10cSrcweir     test_rtl_OString_getStr( hRtlTestResult );
3538*cdf0e10cSrcweir     test_rtl_OString_copy( hRtlTestResult );
3539*cdf0e10cSrcweir     test_rtl_OString_concat( hRtlTestResult );
3540*cdf0e10cSrcweir     test_rtl_OString_toAsciiLowerCase( hRtlTestResult );
3541*cdf0e10cSrcweir     test_rtl_OString_toAsciiUpperCase( hRtlTestResult );
3542*cdf0e10cSrcweir     test_rtl_OString_trim( hRtlTestResult );
3543*cdf0e10cSrcweir     test_rtl_OString_valueOf( hRtlTestResult );
3544*cdf0e10cSrcweir     test_rtl_OString_toChar( hRtlTestResult );
3545*cdf0e10cSrcweir     test_rtl_OString_toFloat( hRtlTestResult );
3546*cdf0e10cSrcweir     // LLA: test_rtl_OString_toDouble( hRtlTestResult );
3547*cdf0e10cSrcweir     test_rtl_OString_toBoolean( hRtlTestResult );
3548*cdf0e10cSrcweir     test_rtl_OString_toInt32( hRtlTestResult );
3549*cdf0e10cSrcweir     test_rtl_OString_toInt64( hRtlTestResult );
3550*cdf0e10cSrcweir     test_rtl_OString_replace( hRtlTestResult );
3551*cdf0e10cSrcweir     test_rtl_OString_replaceAt( hRtlTestResult );
3552*cdf0e10cSrcweir 
3553*cdf0e10cSrcweir     c_rtl_tres_state_end(hRtlTestResult, "rtl_OString");
3554*cdf0e10cSrcweir }
3555*cdf0e10cSrcweir 
3556*cdf0e10cSrcweir 
3557*cdf0e10cSrcweir // -----------------------------------------------------------------------------
3558*cdf0e10cSrcweir void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
3559*cdf0e10cSrcweir {
3560*cdf0e10cSrcweir     if (_pFunc)
3561*cdf0e10cSrcweir     {
3562*cdf0e10cSrcweir         (_pFunc)(&test_rtl_OString, "");
3563*cdf0e10cSrcweir 
3564*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_ctors,                 "");
3565*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_getLength, "");
3566*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_equals, "");
3567*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_equalsIgnoreAsciiCase, "");
3568*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_compareTo, "");
3569*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_cmp, "");
3570*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_neq, "");
3571*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_g, "");
3572*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_l, "");
3573*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_ge, "");
3574*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_le, "");
3575*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_eq, "");
3576*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_plus, "");
3577*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_peq, "");
3578*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_op_cscs, "");
3579*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_getStr, "");
3580*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_copy, "");
3581*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_concat, "");
3582*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toAsciiLowerCase, "");
3583*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toAsciiUpperCase, "");
3584*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_trim, "");
3585*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_valueOf, "");
3586*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toChar, "");
3587*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toFloat, "");
3588*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toDouble, "");
3589*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toBoolean, "");
3590*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toInt32, "");
3591*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_toInt64, "");
3592*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_replace, "");
3593*cdf0e10cSrcweir         //# (_pFunc)(&test_rtl_OString_replaceAt, "");
3594*cdf0e10cSrcweir     }
3595*cdf0e10cSrcweir }
3596*cdf0e10cSrcweir 
3597*cdf0e10cSrcweir /*
3598*cdf0e10cSrcweir D:\local\644\SRX644\sal\qa\rtl_OString.cxx(3559) : error C2664:
3599*cdf0e10cSrcweir 'unsigned char (void (__cdecl *)(void *),const char *)'
3600*cdf0e10cSrcweir  : cannot convert parameter 1 from
3601*cdf0e10cSrcweir 'unsigned char (__cdecl *)(void *)' to 'void (__cdecl *)(void *)'
3602*cdf0e10cSrcweir 
3603*cdf0e10cSrcweir         This conversion requires a reinterpret_cast, a C-style cast or function-
3604*cdf0e10cSrcweir style cast
3605*cdf0e10cSrcweir */
3606