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