update dev300-m57
[ooovba.git] / sal / qa / rtl_strings / rtl_OString.cxx
blob8c5fbf3dae977361c6bfc65a8a5ac3490647ef05
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtl_OString.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
33 #include <string.h>
35 #ifndef _SAL_TYPES_H_
36 #include <sal/types.h>
37 #endif
39 // #ifndef _RTL_TRES_H_
40 // #include <rtl/tres.h>
41 // #endif
43 #include <testshl/tresstatewrapper.hxx>
45 #ifndef _RTL_STRING_HXX_
46 #include <rtl/string.hxx>
47 #endif
49 #ifndef _RTL_STRING_CONST_H_
50 #include <rtl_String_Const.h>
51 #endif
53 #ifndef _RTL_STRING_UTILS_HXX_
54 #include <rtl_String_Utils.hxx>
55 #endif
56 #include <rtl/ustring.h>
58 using namespace rtl;
60 //------------------------------------------------------------------------
61 // test classes
62 //------------------------------------------------------------------------
63 const int MAXBUFLENGTH = 255;
64 //------------------------------------------------------------------------
65 // helper functions
66 //------------------------------------------------------------------------
68 static void unused()
70 test_ini_uString();
71 (void)inputChar;
72 (void)input1StrDefault;
73 (void)input1StrNormal;
74 (void)input1StrLastDefault;
75 (void)input1StrLastNormal;
76 unused();
79 //------------------------------------------------------------------------
80 // testing constructors
81 //------------------------------------------------------------------------
82 static sal_Bool test_rtl_OString_ctor_001( hTestResult hRtlTestResult )
84 ::rtl::OString aStr;
85 rtl_String* pData = aStr.pData;
88 return
90 c_rtl_tres_state
92 hRtlTestResult,
93 pData->length == 0 &&
94 ! *pData->buffer,
95 "New OString containing no characters",
96 "ctor_001"
101 //------------------------------------------------------------------------
103 static sal_Bool SAL_CALL test_rtl_OString_ctor_002(
104 hTestResult hRtlTestResult )
106 ::rtl::OString aStr(kTestStr1);
107 rtl_String* pData = aStr.pData;
109 return
111 c_rtl_tres_state
113 hRtlTestResult,
114 pData->refCount == 1 &&
115 pData->length == kTestStr1Len &&
116 cmpstr( (const sal_Char*)pData->buffer, kTestStr1, kTestStr1Len ),
117 "New OString from a character buffer array",
118 "ctor_002"
122 //------------------------------------------------------------------------
124 static sal_Bool SAL_CALL test_rtl_OString_ctor_003(
125 hTestResult hRtlTestResult )
127 ::rtl::OString aStr(kTestStr2, kTestStr1Len);
128 rtl_String* pData = aStr.pData;
130 return
132 c_rtl_tres_state
134 hRtlTestResult,
135 pData->refCount == 1 &&
136 pData->length == kTestStr1Len &&
137 cmpstr( (const sal_Char*)pData->buffer, kTestStr2, kTestStr1Len ),
138 "New OString from the first n chars of ascii string",
139 "ctor_003"
144 //------------------------------------------------------------------------
146 static sal_Bool SAL_CALL test_rtl_OString_ctor_004(
147 hTestResult hRtlTestResult)
149 ::rtl::OString aStr1(kTestStr1);
150 ::rtl::OString aStr2(aStr1);
151 rtl_String* pData1 = aStr1.pData;
152 rtl_String* pData2 = aStr2.pData;
154 return
156 c_rtl_tres_state
158 hRtlTestResult,
159 pData1->refCount == pData2->refCount &&
160 pData1->length == kTestStr1Len &&
161 pData1->buffer == pData2->buffer,
162 "New OString from an OString",
163 "ctor_004"
167 //------------------------------------------------------------------------
169 static sal_Bool test_rtl_OString_ctor_005( hTestResult hRtlTestResult )
171 rtl_String *aStr1 = NULL;
173 rtl_string_newFromStr( &aStr1, kTestStr1 );
175 if ( aStr1 != NULL )
177 ::rtl::OString aStr2(aStr1);
178 rtl_String* pData2 = aStr2.pData;
180 sal_Bool bOK = c_rtl_tres_state
182 hRtlTestResult,
183 aStr1->refCount == pData2->refCount &&
184 pData2->length == kTestStr1Len &&
185 aStr1->buffer == pData2->buffer,
186 "new OString from a RTL String",
187 "ctor_005"
190 rtl_string_release( aStr1 );
191 aStr1 = NULL;
192 return ( bOK );
194 return
196 c_rtl_tres_state
198 hRtlTestResult,
199 sal_False,
200 "copying an ascii string to a RTL String!",
201 "ctor_005"
206 //------------------------------------------------------------------------
208 static sal_Bool test_rtl_OString_ctor_006( hTestResult hRtlTestResult )
211 sal_Unicode aStr1[kTestStr1Len+1];
213 if ( AStringToUStringNCopy( aStr1, kTestStr1, kTestStr1Len ) )
215 if ( AStringToUStringNCompare( aStr1, kTestStr1, kTestStr1Len ) == 0 )
217 // const sal_Char *kTCMessage[2] = { "", "array." };
219 ::rtl::OString aStr2
221 aStr1,
222 kTestStr1Len,
223 kEncodingRTLTextUSASCII,
224 kConvertFlagsOUStringToOString
227 return
229 c_rtl_tres_state
231 hRtlTestResult,
232 aStr2 == kTestStr1,
233 "new OString from a unicode character buffer",
234 "ctor_006"
237 } /// end if AStringToUStringNCompare
239 return
241 c_rtl_tres_state
243 hRtlTestResult,
244 sal_False,
245 "compare ascii string with unicode string!",
246 "ctor_006"
249 } /// end if AStringToUStringNCopy
251 return
253 c_rtl_tres_state
255 hRtlTestResult,
256 sal_False,
257 "copy ascii string to unicode string!",
258 "ctor_006"
262 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_ctors(
263 hTestResult hRtlTestResult )
266 c_rtl_tres_state_start(hRtlTestResult, "ctor");
267 sal_Bool bTSState = test_rtl_OString_ctor_001( hRtlTestResult );
269 bTSState &= test_rtl_OString_ctor_002( hRtlTestResult);
270 bTSState &= test_rtl_OString_ctor_003( hRtlTestResult);
271 bTSState &= test_rtl_OString_ctor_004( hRtlTestResult);
272 bTSState &= test_rtl_OString_ctor_005( hRtlTestResult);
273 bTSState &= test_rtl_OString_ctor_006( hRtlTestResult);
275 c_rtl_tres_state_end(hRtlTestResult, "ctor");
277 // return( bTSState );
282 //------------------------------------------------------------------------
283 // testing the method getLength
284 //------------------------------------------------------------------------
286 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_getLength(
287 hTestResult hRtlTestResult)
289 sal_Char methName[MAXBUFLENGTH];
290 sal_Char* pMeth = methName;
292 c_rtl_tres_state_start(hRtlTestResult, "getLength");
294 typedef struct TestCase
296 sal_Char* comments;
297 sal_Int32 expVal;
298 OString* input;
299 ~TestCase() { delete input;}
300 } TestCase;
302 TestCase arrTestCase[]={
304 {"length of ascii string", kTestStr1Len, new OString(kTestStr1)},
305 {"length of ascci string of size 1", 1, new OString("1")},
306 {"length of empty string (default constructor)", 0, new OString()},
307 {"length of empty string (empty ascii string arg)",0,new OString("")},
308 {"length of empty string (string arg = '\\0')",0,new OString("\0")}
312 sal_Bool res = sal_True;
313 sal_uInt32 i;
315 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
317 sal_Int32 length = arrTestCase[i].input->getLength();
318 sal_Bool lastRes = (length == arrTestCase[i].expVal);
319 c_rtl_tres_state
321 hRtlTestResult,
322 lastRes,
323 arrTestCase[i].comments,
324 createName( pMeth, "getLength", i )
327 res &= lastRes;
329 c_rtl_tres_state_end(hRtlTestResult, "getLength");
330 // return ( res );
335 //------------------------------------------------------------------------
336 // testing the method equals( const OString & aStr )
337 //------------------------------------------------------------------------
338 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_equals(
339 hTestResult hRtlTestResult )
341 sal_Char methName[MAXBUFLENGTH];
342 sal_Char* pMeth = methName;
344 c_rtl_tres_state_start(hRtlTestResult, "equals");
346 typedef struct TestCase
348 sal_Char* comments;
349 sal_Bool expVal;
350 OString* input1;
351 OString* input2;
352 ~TestCase() { delete input1;delete input2;}
353 } TestCase;
355 TestCase arrTestCase[]={
357 {"same size", sal_True, new OString(kTestStr1),new OString(kTestStr1)},
358 {"different size", sal_False, new OString(kTestStr1),
359 new OString(kTestStr2)},
360 {"same size, no case match", sal_False, new OString(kTestStr1),
361 new OString(kTestStr3)},
362 {"two empty strings(def. constructor)", sal_True, new OString(),
363 new OString()},
364 {"empty(def.constructor) and non empty", sal_False, new OString(),
365 new OString(kTestStr2)},
366 {"non empty and empty(def. constructor)", sal_False,
367 new OString(kTestStr1),new OString()},
368 {"two empty strings(string arg = '\\0')", sal_True,
369 new OString(""),new OString("")},
370 {"empty(string arg = '\\0') and non empty", sal_False,
371 new OString(""),new OString(kTestStr2)},
372 {"non empty and empty(string arg = '\\0')", sal_False,
373 new OString(kTestStr1),new OString("")}
376 sal_Bool res = sal_True;
377 sal_uInt32 i;
379 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
381 sal_Bool lastRes =
382 ( arrTestCase[i].input1->equals(*(arrTestCase[i].input2)) ==
383 arrTestCase[i].expVal );
385 c_rtl_tres_state
387 hRtlTestResult,
388 lastRes,
389 arrTestCase[i].comments,
390 createName( pMeth, "equals", i )
393 res &= lastRes;
395 c_rtl_tres_state_end(hRtlTestResult, "equals");
396 // return (res);
399 //------------------------------------------------------------------------
400 // testing the method equalsIgnoreAsciiCase( const OString & aStr )
401 //------------------------------------------------------------------------
403 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_equalsIgnoreAsciiCase(
404 hTestResult hRtlTestResult )
406 sal_Char methName[MAXBUFLENGTH];
407 sal_Char* pMeth = methName;
409 c_rtl_tres_state_start(hRtlTestResult, "equalsIgnoreAsciiCase");
410 typedef struct TestCase
412 sal_Char* comments;
413 sal_Bool expVal;
414 OString* input1;
415 OString* input2;
416 ~TestCase() { delete input1;delete input2;}
417 } TestCase;
419 TestCase arrTestCase[]={
420 {"same strings but different cases",sal_True,new OString(kTestStr4),
421 new OString(kTestStr5)},
422 {"same strings",sal_True,new OString(kTestStr4),
423 new OString(kTestStr4)},
424 {"with equal beginning",sal_False,new OString(kTestStr2),
425 new OString(kTestStr4)},
426 {"empty(def.constructor) and non empty",sal_False,new OString(),
427 new OString(kTestStr5)},
428 {"non empty and empty(def.constructor)",sal_False,
429 new OString(kTestStr4), new OString()},
430 {"two empty strings(def.constructor)",sal_True,new OString(),
431 new OString()},
432 {"different strings with equal length",sal_False,
433 new OString(kTestStr10), new OString(kTestStr11)}
436 sal_Bool res = sal_True;
437 sal_uInt32 i;
439 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
441 sal_Bool lastRes =
442 (arrTestCase[i].input1->equalsIgnoreAsciiCase(*arrTestCase[i].input2)
443 == arrTestCase[i].expVal);
445 c_rtl_tres_state
447 hRtlTestResult,
448 lastRes,
449 arrTestCase[i].comments,
450 createName( pMeth, "equalsIgnoreAsciiCase", i )
453 res &= lastRes;
455 c_rtl_tres_state_end(hRtlTestResult, "equalsIgnoreAsciiCase");
457 // return (res);
460 static sal_Bool SAL_CALL test_rtl_OString_compareTo_001(
461 hTestResult hRtlTestResult )
463 sal_Char methName[MAXBUFLENGTH];
464 sal_Char* pMeth = methName;
466 typedef struct TestCase
468 sal_Char* comments;
469 sal_Int32 expVal;
470 OString* input1;
471 OString* input2;
472 ~TestCase() { delete input1;delete input2;}
473 } TestCase;
475 TestCase arrTestCase[]={
477 {"simple compare, str1 to str5",-1,new OString(kTestStr1),
478 new OString(kTestStr5)},
479 {"simple compare, str2 to str5",-1,new OString(kTestStr2),
480 new OString(kTestStr5)},
481 {"simple compare, str1 to str9",-1,new OString(kTestStr1),
482 new OString(kTestStr9)},
483 {"simple compare, str1 to str2",-1,new OString(kTestStr1),
484 new OString(kTestStr2)},
485 {"simple compare, str4 to str5",-1,new OString(kTestStr4),
486 new OString(kTestStr5)},
487 {"simple compare, str1 to str3",-1,new OString(kTestStr1),
488 new OString(kTestStr3)},
489 {"simple compare, str5 to str1",+1,new OString(kTestStr5),
490 new OString(kTestStr1)},
491 {"simple compare, str2 to str1",+1,new OString(kTestStr2),
492 new OString(kTestStr1)},
493 {"simple compare, str9 to str5",+1,new OString(kTestStr9),
494 new OString(kTestStr5)},
495 {"simple compare, str5 to str4",+1,new OString(kTestStr5),
496 new OString(kTestStr4)},
497 {"simple compare, str1 to str1",0,new OString(kTestStr1),
498 new OString(kTestStr1)},
499 {"simple compare, nullString to nullString",0,new OString(),
500 new OString()},
501 {"simple compare, nullString to str2",-1,new OString(),
502 new OString(kTestStr2)},
503 {"simple compare, str1 to nullString",+1,new OString(kTestStr1),
504 new OString()}
507 sal_Bool res = sal_True;
508 sal_uInt32 i;
510 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
512 sal_Int32 cmpRes =
513 arrTestCase[i].input1->compareTo(*arrTestCase[i].input2);
514 cmpRes = ( cmpRes == 0 ) ? 0 : ( cmpRes > 0 ) ? +1 : -1 ;
515 sal_Bool lastRes = ( cmpRes == arrTestCase[i].expVal);
517 c_rtl_tres_state
519 hRtlTestResult,
520 lastRes,
521 arrTestCase[i].comments,
522 createName( pMeth, "compareTo(const OString&)", i )
525 res &= lastRes;
528 return (res);
532 //------------------------------------------------------------------------
533 // testing the method compareTo( const OString & rObj, sal_Int32 length )
534 //------------------------------------------------------------------------
535 static sal_Bool SAL_CALL test_rtl_OString_compareTo_002(
536 hTestResult hRtlTestResult )
538 sal_Char methName[MAXBUFLENGTH];
539 sal_Char* pMeth = methName;
541 typedef struct TestCase
543 sal_Char* comments;
544 sal_Int32 expVal;
545 sal_Int32 maxLength;
546 OString* input1;
547 OString* input2;
548 ~TestCase() { delete input1;delete input2;}
549 } TestCase;
551 TestCase arrTestCase[] =
553 {"compare with maxlength, str1 to str9, 16",-1,16,
554 new OString(kTestStr1), new OString(kTestStr9)},
555 {"compare with maxlength, str2 to str9, 32",-1,32,
556 new OString(kTestStr2), new OString(kTestStr9)},
557 {"compare with maxlength, str9 to str4, 16",+1,16,
558 new OString(kTestStr9), new OString(kTestStr4)},
559 {"compare with maxlength, str9 to str22, 32",+1,32,
560 new OString(kTestStr9), new OString(kTestStr22)},
561 {"compare with maxlength, str9 to str5, 16",0,16,
562 new OString(kTestStr9), new OString(kTestStr5)},
563 {"compare with maxlength, str9 to str9, 32",0,32,
564 new OString(kTestStr9), new OString(kTestStr9)},
565 {"compare with maxlength, str1 to str2, 32",-1,32,
566 new OString(kTestStr1), new OString(kTestStr2)},
567 {"compare with maxlength, str1 to str2, 32",-1,32,
568 new OString(kTestStr1), new OString(kTestStr2)}
571 sal_Bool res = sal_True;
572 sal_uInt32 i;
574 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
576 sal_Int32 cmpRes =
577 arrTestCase[i].input1->compareTo(*arrTestCase[i].input2,
578 arrTestCase[i].maxLength);
579 cmpRes = (cmpRes == 0) ? 0 : (cmpRes > 0) ? +1 : -1 ;
580 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
582 c_rtl_tres_state
584 hRtlTestResult,
585 lastRes,
586 arrTestCase[i].comments,
587 createName( pMeth, "compareTo(const OString&, sal_Int32)", i )
590 res &= lastRes;
593 return (res);
596 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_compareTo(
597 hTestResult hRtlTestResult )
599 c_rtl_tres_state_start(hRtlTestResult, "compareTo");
600 sal_Bool res = test_rtl_OString_compareTo_001(hRtlTestResult);
601 res &= test_rtl_OString_compareTo_002(hRtlTestResult);
602 c_rtl_tres_state_end(hRtlTestResult, "compareTo");
603 // return (res);
606 //------------------------------------------------------------------------
607 // testing the operator == ( const OString& rStr1, const OString& rStr2 )
608 // testing the operator == ( const OString& rStr1, const sal_Char *rStr2 )
609 // testing the operator == ( const sal_Char *rStr1, const OString& rStr2 )
610 //------------------------------------------------------------------------
611 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_cmp(
612 hTestResult hRtlTestResult )
614 c_rtl_tres_state_start(hRtlTestResult, "op_cmp");
615 const sal_Int16 NCASES = 7;
616 sal_Char methName[MAXBUFLENGTH];
617 sal_Char* pMeth = methName;
618 const sal_Char *arrOStr[NCASES][2] =
620 {kTestStr1, kTestStr1},
621 {kTestStr1, kTestStr3},
622 {kTestStr1, kTestStr2},
623 {0, 0},
624 {0, kTestStr2},
625 {kTestStr1, 0},
626 {"", ""}
629 sal_Bool arrExpVal[NCASES] =
631 sal_True,
632 sal_False,
633 sal_False,
634 sal_True,
635 sal_False,
636 sal_False,
637 sal_True
640 sal_Char *arrComments[NCASES] =
642 "'Sun Microsystems'=='Sun Microsystems'",
643 "!('Sun Microsystems'=='Sun microsystems')",
644 "!('Sun Microsystems'=='Sun Microsystems Java Technology')",
645 "two empty strings(def.constructor)",
646 "!(empty string=='Sun Microsystems Java Technology')",
647 "!('Sun Microsystems Java Technology'==empty string)",
648 "''==''"
651 sal_Bool res = sal_True;
652 sal_Int32 i;
654 for(i = 0; i < NCASES; i++)
656 OString *str1, *str2;
657 str1 = (arrOStr[i][0]) ? new OString(arrOStr[i][0]) : new OString() ;
658 str2 = (arrOStr[i][1]) ? new OString(arrOStr[i][1]) : new OString() ;
660 sal_Bool cmpRes = (*str1 == *str2);
661 sal_Bool lastRes = (cmpRes == arrExpVal[i]);
662 res &= lastRes;
664 c_rtl_tres_state
666 hRtlTestResult,
667 lastRes,
668 arrComments[i],
669 createName( pMeth, "operator ==(OString&, OString&)", i )
672 cmpRes = (*str1 == arrOStr[i][1]);
673 lastRes = (cmpRes == arrExpVal[i]);
674 res &= lastRes;
675 c_rtl_tres_state
677 hRtlTestResult,
678 lastRes,
679 arrComments[i],
680 createName( pMeth, "operator ==(OString&, sal_Char *)", i )
683 cmpRes = (arrOStr[i][0] == *str2);
684 lastRes = (cmpRes == arrExpVal[i]);
685 res &= lastRes;
686 c_rtl_tres_state
688 hRtlTestResult,
689 lastRes,
690 arrComments[i],
691 createName( pMeth, "operator ==(sal_Char *, OString&)", i )
694 delete str2;
695 delete str1;
698 c_rtl_tres_state_end(hRtlTestResult, "op_cmp");
699 // return ( res );
702 //------------------------------------------------------------------------
703 // testing the operator != (const OString& rStr1, const OString& rStr2)
704 // testing the operator != (const OString& rStr1, const sal_Char *rStr2)
705 // testing the operator != (const sal_Char *rStr1, const OString& rStr2)
706 //------------------------------------------------------------------------
707 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_neq(
708 hTestResult hRtlTestResult )
710 c_rtl_tres_state_start(hRtlTestResult, "op_neq");
711 const sal_Int16 NCASES = 6;
712 sal_Char methName[MAXBUFLENGTH];
713 sal_Char* pMeth = methName;
715 const sal_Char *arrOStr[NCASES][2] =
717 {kTestStr1, kTestStr3},
718 {kTestStr1, kTestStr2},
719 {kTestStr1, kTestStr1},
720 {0, kTestStr2},
721 {kTestStr1, 0},
722 {0, 0}
725 sal_Bool arrExpVal[NCASES] =
727 sal_True,
728 sal_True,
729 sal_False,
730 sal_True,
731 sal_True,
732 sal_False
735 sal_Char *arrComments[NCASES] =
737 "'Sun Microsystems'!='Sun microsystems'",
738 "'Sun Microsystems'!='Sun Microsystems Java Technology'",
739 "!('Sun Microsystems'!='Sun Microsystems')",
740 "empty string!='Sun Microsystems Java Technology'",
741 "'Sun Microsystems Java Technology'!=empty string", "!(''!='')"
744 sal_Bool res = sal_True;
745 sal_Int32 i;
747 for(i = 0; i < NCASES; i++)
749 OString *str1, *str2;
750 str1 = (arrOStr[i][0]) ? new OString(arrOStr[i][0]) : new OString() ;
751 str2 = (arrOStr[i][1]) ? new OString(arrOStr[i][1]) : new OString() ;
753 sal_Bool cmpRes = (*str1 != *str2);
754 sal_Bool lastRes = (cmpRes == arrExpVal[i]);
755 res &= lastRes;
756 c_rtl_tres_state
758 hRtlTestResult,
759 lastRes,
760 arrComments[i],
761 createName( pMeth, "operator !=(OString&, OString&)", i )
764 cmpRes = (*str1 != arrOStr[i][1]);
765 lastRes = (cmpRes == arrExpVal[i]);
766 res &= lastRes;
767 c_rtl_tres_state
769 hRtlTestResult,
770 lastRes,
771 arrComments[i],
772 createName( pMeth, "operator !=(OString&, sal_Char *)", i )
775 cmpRes = (arrOStr[i][0] != *str2);
776 lastRes = (cmpRes == arrExpVal[i]);
777 res &= lastRes;
778 c_rtl_tres_state
780 hRtlTestResult,
781 lastRes,
782 arrComments[i],
783 createName( pMeth, "operator !=(sal_Char *, OString&)", i )
786 delete str2;
787 delete str1;
790 c_rtl_tres_state_end(hRtlTestResult, "op_neq");
791 // return ( res );
795 //------------------------------------------------------------------------
796 // testing the operator > (const OString& rStr1, const OString& rStr2)
797 //------------------------------------------------------------------------
798 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_g(
799 hTestResult hRtlTestResult )
801 sal_Char methName[MAXBUFLENGTH];
802 sal_Char* pMeth = methName;
804 c_rtl_tres_state_start(hRtlTestResult, "op_g");
805 typedef struct TestCase
807 sal_Char* comments;
808 sal_Bool expVal;
809 OString* input1;
810 OString* input2;
811 ~TestCase() { delete input1;delete input2;}
812 } TestCase;
814 TestCase arrTestCase[] =
816 { "'Sun microsystems'>'Sun Microsystems'",sal_True,
817 new OString(kTestStr3), new OString(kTestStr1)},
818 {"!('Sun Microsystems'>'Sun microsystems')",sal_False,
819 new OString(kTestStr1), new OString(kTestStr3)},
820 {"'Sun Microsystems Java Technology'>'Sun Microsystems'",sal_True,
821 new OString(kTestStr2), new OString(kTestStr1)},
822 {"!('Sun Microsystems'>'Sun Microsystems Java Technology')",sal_False,
823 new OString(kTestStr1), new OString(kTestStr2)},
824 {"!('Sun Microsystems'>'Sun Microsystems'",sal_False,
825 new OString(kTestStr1), new OString(kTestStr1)},
826 {"'Sun Microsystems'>''",sal_True,new OString(kTestStr1),
827 new OString()},
828 {"!(''>'Sun Microsystems')",sal_False,new OString(),
829 new OString(kTestStr1)},
830 {"!(''>'')",sal_False,new OString(), new OString()}
833 sal_Bool res = sal_True;
834 sal_uInt32 i;
836 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
838 sal_Bool cmpRes = (*arrTestCase[i].input1 > *arrTestCase[i].input2);
839 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
841 c_rtl_tres_state
843 hRtlTestResult,
844 lastRes,
845 arrTestCase[i].comments,
846 createName( pMeth, "operator >", i )
849 res &= lastRes;
853 c_rtl_tres_state_end(hRtlTestResult, "op_g");
854 // return ( res );
857 //------------------------------------------------------------------------
858 // testing the operator < (const OString& rStr1, const OString& rStr2)
859 //------------------------------------------------------------------------
861 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_l(
862 hTestResult hRtlTestResult )
864 sal_Char methName[MAXBUFLENGTH];
865 sal_Char* pMeth = methName;
867 c_rtl_tres_state_start(hRtlTestResult, "op_l");
868 typedef struct TestCase
870 sal_Char* comments;
871 sal_Bool expVal;
872 OString* input1;
873 OString* input2;
874 ~TestCase() { delete input1;delete input2;}
875 } TestCase;
877 TestCase arrTestCase[] =
879 {"!('Sun microsystems'<'Sun Microsystems')",sal_False,
880 new OString(kTestStr3), new OString(kTestStr1)},
881 {"'Sun Microsystems'<'Sun microsystems'",sal_True,
882 new OString(kTestStr1), new OString(kTestStr3)},
883 {"'Sun Microsystems'<'Sun Microsystems Java Technology'",sal_True,
884 new OString(kTestStr1), new OString(kTestStr2)},
885 {"!('Sun Microsystems Java Technology'<'Sun Microsystems')",sal_False,
886 new OString(kTestStr2), new OString(kTestStr1)},
887 {"!('Sun Microsystems'<'Sun Microsystems'", sal_False,
888 new OString(kTestStr1), new OString(kTestStr1)},
889 {"'Sun Microsystems'<''",sal_False,new OString(kTestStr1),
890 new OString()},
891 {"''<'Sun Microsystems Java Technology'",sal_True,new OString(),
892 new OString(kTestStr2)},
893 {"!(''<'')",sal_False,new OString(), new OString()}
896 sal_Bool res = sal_True;
897 sal_uInt32 i;
899 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
901 sal_Bool cmpRes = (*arrTestCase[i].input1 < *arrTestCase[i].input2);
902 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
904 c_rtl_tres_state
906 hRtlTestResult,
907 lastRes,
908 arrTestCase[i].comments,
909 createName( pMeth, "operator <", i )
912 res &= lastRes;
916 c_rtl_tres_state_end(hRtlTestResult, "op_l");
917 // return ( res );
920 //------------------------------------------------------------------------
921 // testing the operator >= (const OString& rStr1, const OString& rStr2)
922 //------------------------------------------------------------------------
923 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_ge(
924 hTestResult hRtlTestResult )
926 sal_Char methName[MAXBUFLENGTH];
927 sal_Char* pMeth = methName;
929 c_rtl_tres_state_start(hRtlTestResult, "op_ge");
930 typedef struct TestCase
932 sal_Char* comments;
933 sal_Bool expVal;
934 OString* input1;
935 OString* input2;
936 ~TestCase() { delete input1;delete input2;}
937 } TestCase;
939 TestCase arrTestCase[] =
941 {"'Sun microsystems'>='Sun Microsystems'",sal_True,
942 new OString(kTestStr3), new OString(kTestStr1)},
943 {"!('Sun Microsystems'>='Sun microsystems')",sal_False,
944 new OString(kTestStr1), new OString(kTestStr3)},
945 {"!('Sun Microsystems'>='Sun Microsystems Java Technology')",sal_False,
946 new OString(kTestStr1), new OString(kTestStr2)},
947 {"'Sun Microsystems Java Technology'>='Sun Microsystems'",sal_True,
948 new OString(kTestStr2), new OString(kTestStr1)},
949 {"'Sun Microsystems'>='Sun Microsystems'", sal_True,
950 new OString(kTestStr1), new OString(kTestStr1)},
951 {"'Sun Microsystems'>=''",sal_True,new OString(kTestStr1),
952 new OString()},
953 { "''>='Sun microsystems'",sal_False,new OString(),
954 new OString(kTestStr3)},
955 {"''>=''",sal_True,new OString(), new OString()}
958 sal_Bool res = sal_True;
959 sal_uInt32 i;
961 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
963 sal_Bool cmpRes = (*arrTestCase[i].input1 >= *arrTestCase[i].input2);
964 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
966 c_rtl_tres_state
968 hRtlTestResult,
969 lastRes,
970 arrTestCase[i].comments,
971 createName( pMeth, "operator >=", i )
974 res &= lastRes;
978 c_rtl_tres_state_end(hRtlTestResult, "op_ge");
979 // return ( res );
982 //------------------------------------------------------------------------
983 // testing the operator <= (const OString& rStr1, const OString& rStr2)
984 //------------------------------------------------------------------------
985 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_le(
986 hTestResult hRtlTestResult )
988 sal_Char methName[MAXBUFLENGTH];
989 sal_Char* pMeth = methName;
991 c_rtl_tres_state_start(hRtlTestResult, "op_le");
992 typedef struct TestCase
994 sal_Char* comments;
995 sal_Bool expVal;
996 OString* input1;
997 OString* input2;
998 ~TestCase() { delete input1;delete input2;}
999 } TestCase;
1001 TestCase arrTestCase[] =
1003 {"!('Sun microsystems'<='Sun Microsystems')",sal_False,
1004 new OString(kTestStr3), new OString(kTestStr1)},
1005 {"'Sun Microsystems'<='Sun microsystems'",sal_True,
1006 new OString(kTestStr1), new OString(kTestStr3)},
1007 {"'Sun Microsystems'<='Sun Microsystems Java Technology'",sal_True,
1008 new OString(kTestStr1),
1009 new OString(kTestStr2)},
1010 {"!('Sun Microsystems Java Technology'<='Sun Microsystems')",sal_False,
1011 new OString(kTestStr2),
1012 new OString(kTestStr1)},
1013 {"!('Sun Microsystems'<='Sun Microsystems'", sal_True,
1014 new OString(kTestStr1), new OString(kTestStr1)},
1015 {"'Sun Microsystems'<=''",sal_False,new OString(kTestStr1),
1016 new OString()},
1017 {"''<='Sun Microsystems Java Technology'",sal_True,new OString(),
1018 new OString(kTestStr2)},
1019 {"!(''<='')",sal_True,new OString(), new OString()}
1022 sal_Bool res = sal_True;
1023 sal_uInt32 i;
1025 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1027 sal_Bool cmpRes = (*arrTestCase[i].input1 <= *arrTestCase[i].input2);
1028 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
1030 c_rtl_tres_state
1032 hRtlTestResult,
1033 lastRes,
1034 arrTestCase[i].comments,
1035 createName( pMeth, "operator <=", i )
1038 res &= lastRes;
1042 c_rtl_tres_state_end(hRtlTestResult, "op_le");
1043 // return ( res );
1047 //------------------------------------------------------------------------
1048 // testing the operator =
1049 //------------------------------------------------------------------------
1050 static sal_Bool test_rtl_OString_op_eq_001( hTestResult hRtlTestResult )
1052 sal_Char methName[MAXBUFLENGTH];
1053 sal_Char* pMeth = methName;
1055 typedef struct TestCase
1057 sal_Char* comments;
1058 sal_Bool expVal;
1059 OString* input1;
1060 OString* input2;
1061 ~TestCase() { delete input1;delete input2;}
1062 } TestCase;
1064 TestCase arrTestCase[] =
1066 {"'' = str1, str1 == str2",sal_True,new OString(kTestStr1),
1067 new OString()},
1068 {"str1 = str2, str1 == str2",sal_True,new OString(kTestStr1),
1069 new OString(kTestStr6)},
1070 {"str2 = '', str1 == str2",sal_True,new OString(),
1071 new OString(kTestStr2)},
1072 {"'' = '', str1 == str2",sal_True,new OString(),
1073 new OString()}
1076 sal_Bool res = sal_True;
1077 sal_uInt32 i;
1079 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1081 *(arrTestCase[i].input1) = *(arrTestCase[i].input2);
1083 sal_Bool cmpRes =
1084 (*(arrTestCase[i].input1) == *(arrTestCase[i].input2));
1085 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
1087 c_rtl_tres_state
1089 hRtlTestResult,
1090 lastRes,
1091 arrTestCase[i].comments,
1092 createName( pMeth, "operator =", i )
1095 res &= lastRes;
1098 return ( res );
1101 static sal_Bool test_rtl_OString_op_eq_002(
1102 hTestResult hRtlTestResult )
1104 ::rtl::OString aStr;
1105 aStr = OString(kTestStr1);
1107 return
1109 c_rtl_tres_state
1111 hRtlTestResult,
1112 aStr == kTestStr1,
1113 "str = OString(\"%s\"), str == \"%s\"",
1114 "operator ="
1119 static sal_Bool test_rtl_OString_op_eq_003(
1120 hTestResult hRtlTestResult )
1122 sal_Bool bTCState = false;
1124 ::rtl::OString aStr1(kTestStr1);
1125 ::rtl::OString aStr2;
1126 ::rtl::OString aStr3;
1128 aStr3 = aStr2 = aStr1;
1130 bTCState = ( aStr1 == aStr2 )
1131 && ( aStr1 == aStr3 )
1132 && ( aStr2 == aStr3 );
1134 c_rtl_tres_state
1136 hRtlTestResult,
1137 bTCState,
1138 "str3=str2=str1,(str1 == str2)&&(str1 == str3)&&(str2 == str3)",
1139 "operator ="
1142 return bTCState;
1145 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_eq(
1146 hTestResult hRtlTestResult )
1148 c_rtl_tres_state_start(hRtlTestResult, "op_eq");
1149 sal_Bool res = test_rtl_OString_op_eq_001( hRtlTestResult );
1150 res &= test_rtl_OString_op_eq_002( hRtlTestResult );
1151 res &= test_rtl_OString_op_eq_003( hRtlTestResult );
1152 c_rtl_tres_state_end(hRtlTestResult, "op_eq");
1154 // return ( res );
1157 //------------------------------------------------------------------------
1158 // testing the operator +
1159 //------------------------------------------------------------------------
1160 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_plus(
1161 hTestResult hRtlTestResult )
1163 sal_Char methName[MAXBUFLENGTH];
1164 sal_Char* pMeth = methName;
1166 c_rtl_tres_state_start(hRtlTestResult, "op_plus");
1167 typedef struct TestCase
1169 sal_Char* comments;
1170 OString* expVal;
1171 OString* input1;
1172 OString* input2;
1173 ~TestCase() { delete input1;delete input2; delete expVal;}
1174 } TestCase;
1176 TestCase arrTestCase[] =
1178 {"str1 = str7 + str8",new OString(kTestStr1),
1179 new OString(kTestStr7), new OString(kTestStr8)},
1180 {"str1 = str1 + '' ",new OString(kTestStr1),
1181 new OString(kTestStr1), new OString("")},
1182 {"str1 = '' + str1", new OString(kTestStr1),
1183 new OString(""), new OString(kTestStr1)},
1184 {" '' = '' + '' ", new OString(""),new OString(""),
1185 new OString("")},
1186 {"str1 = str1 + def.constr", new OString(kTestStr1),
1187 new OString(kTestStr1), new OString()},
1188 {" str1 = def.constr + str1 ",new OString(kTestStr1),
1189 new OString(), new OString(kTestStr1)},
1190 {" def.constr= def.constr + def.constr", new OString(),
1191 new OString(), new OString()}
1194 sal_Bool res = sal_True;
1195 sal_uInt32 i;
1196 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1198 OString str = (*arrTestCase[i].input1) + (*arrTestCase[i].input2);
1199 sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1201 c_rtl_tres_state
1203 hRtlTestResult,
1204 lastRes,
1205 arrTestCase[i].comments,
1206 createName( pMeth, "operator +", i )
1209 res &= lastRes;
1213 c_rtl_tres_state_end(hRtlTestResult, "op_plus");
1214 // return ( res );
1217 //------------------------------------------------------------------------
1218 // testing the operator +=
1219 //------------------------------------------------------------------------
1220 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_peq(
1221 hTestResult hRtlTestResult )
1223 sal_Char methName[MAXBUFLENGTH];
1224 sal_Char* pMeth = methName;
1226 c_rtl_tres_state_start(hRtlTestResult, "op_peq");
1227 typedef struct TestCase
1229 sal_Char* comments;
1230 OString* expVal;
1231 OString* input1;
1232 OString* input2;
1233 ~TestCase() { delete input1;delete input2; delete expVal;}
1234 } TestCase;
1236 TestCase arrTestCase[] =
1238 {"str1 == (str7 += str8)",new OString(kTestStr1),
1239 new OString(kTestStr7), new OString(kTestStr8)},
1240 {"str1 == (str1 += '')",new OString(kTestStr1),
1241 new OString(kTestStr1), new OString("")},
1242 {"str1 == ('' += str1)", new OString(kTestStr1),
1243 new OString(""), new OString(kTestStr1)},
1244 {" '' == ('' += '')", new OString(""),
1245 new OString(""), new OString("")},
1246 {"str1 == (str1 += def.constr)", new OString(kTestStr1),
1247 new OString(kTestStr1), new OString()},
1248 {" str1 == (def.constr += str1)",new OString(kTestStr1),
1249 new OString(), new OString(kTestStr1)},
1250 {" def.constr== (def.constr += def.constr)",
1251 new OString(),new OString(), new OString()}
1254 sal_Bool res = sal_True;
1255 sal_uInt32 i;
1256 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1257 { OString str;
1258 str += (*arrTestCase[i].input1); str += (*arrTestCase[i].input2);
1259 sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1261 c_rtl_tres_state
1263 hRtlTestResult,
1264 lastRes,
1265 arrTestCase[i].comments,
1266 createName( pMeth, "operator +", i )
1269 res &= lastRes;
1273 c_rtl_tres_state_end(hRtlTestResult, "op_peq");
1274 // return ( res );
1277 //------------------------------------------------------------------------
1278 // testing the operator const sal_Char * (cscs for short)
1279 //------------------------------------------------------------------------
1280 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_op_cscs(
1281 hTestResult hRtlTestResult )
1283 sal_Char methName[MAXBUFLENGTH];
1284 sal_Char* pMeth = methName;
1286 c_rtl_tres_state_start(hRtlTestResult, "op_cscs");
1287 typedef struct TestCase
1289 sal_Char* comments;
1290 const sal_Char* expVal;
1291 sal_Int32 cmpLen;
1292 OString* input1;
1293 ~TestCase() { delete input1;}
1294 } TestCase;
1296 TestCase arrTestCase[] =
1298 {"test normal string",kTestStr1,kTestStr1Len,new OString(kTestStr1)},
1299 {"test empty string","",1,new OString()}
1302 sal_Bool res = sal_True;
1303 sal_uInt32 i;
1304 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1306 const sal_Char* pstr = (*arrTestCase[i].input1);
1308 res &= c_rtl_tres_state
1310 hRtlTestResult,
1311 cmpstr((sal_Char*)pstr,(sal_Char*)arrTestCase[i].expVal,
1312 arrTestCase[i].cmpLen),
1313 arrTestCase[i].comments,
1314 createName( pMeth, "const sal_Char*", i )
1317 c_rtl_tres_state_end(hRtlTestResult, "op_cscs");
1318 // return ( res );
1322 //------------------------------------------------------------------------
1323 // testing the method getStr()
1324 //------------------------------------------------------------------------
1327 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_getStr(
1328 hTestResult hRtlTestResult )
1330 sal_Char methName[MAXBUFLENGTH];
1331 sal_Char* pMeth = methName;
1333 c_rtl_tres_state_start(hRtlTestResult, "getStr");
1334 typedef struct TestCase
1336 sal_Char* comments;
1337 const sal_Char* expVal;
1338 sal_Int32 cmpLen;
1339 OString* input1;
1340 ~TestCase() { delete input1;}
1341 } TestCase;
1343 TestCase arrTestCase[] =
1345 {"test normal string",kTestStr1,kTestStr1Len,new OString(kTestStr1)},
1346 {"test empty string","",0,new OString()}
1349 sal_Bool res = sal_True;
1350 sal_uInt32 i;
1351 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1353 const sal_Char* pstr = arrTestCase[i].input1->getStr();
1354 res &= c_rtl_tres_state
1356 hRtlTestResult,
1357 cmpstr(pstr, arrTestCase[i].expVal,
1358 arrTestCase[i].cmpLen),
1359 arrTestCase[i].comments,
1360 createName( pMeth, "getStr", i )
1363 c_rtl_tres_state_end(hRtlTestResult, "getStr");
1364 // return ( res );
1369 //------------------------------------------------------------------------
1370 // testing the method copy( sal_Int32 beginIndex )
1371 //------------------------------------------------------------------------
1372 static sal_Bool SAL_CALL test_rtl_OString_copy_001(
1373 hTestResult hRtlTestResult )
1375 sal_Char methName[MAXBUFLENGTH];
1376 sal_Char* pMeth = methName;
1378 typedef struct TestCase
1380 sal_Char* comments;
1381 const sal_Char* srcStr;
1382 const sal_Char* arrExpStr;
1383 // string for comparing with result
1384 sal_Int32 beginIndex;
1385 // beginIndex for the method copy
1386 sal_Int32 lengthForCmp;
1387 // number of symbols for comparing
1388 // (if value is equal to 0 then pointers to buffers must be equal)
1389 sal_Int32 expLength;
1390 //expected length of the result string
1391 } TestCase;
1393 TestCase arrTestCase[] =
1395 {"beginIndex == 0 ( whole string )", kTestStr2,kTestStr2,
1396 0, kTestStr2Len, kTestStr2Len},
1397 {"beginIndex == strlen-2 ( last two char )", kTestStr2,"gy",
1398 kTestStr2Len-2, 2, 2},
1399 {"beginIndex == strlen-1( last char )", kTestStr2, "y",
1400 kTestStr2Len-1, 1, 1}
1403 sal_Bool res = sal_True;
1404 sal_uInt32 i;
1406 for(i = 0; i <(sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1408 OString src(arrTestCase[i].srcStr);
1409 OString dst;
1410 // rtl_String* pDataSrc = src.pData;
1412 dst = src.copy(arrTestCase[i].beginIndex);
1414 // rtl_String* pDataDst = dst.pData;
1416 sal_Bool lastRes;
1418 lastRes= (dst== arrTestCase[i].arrExpStr);
1421 c_rtl_tres_state
1423 hRtlTestResult,
1424 lastRes,
1425 arrTestCase[i].comments,
1426 createName( pMeth,
1427 "copy_001(beginIndex)(check buffer and length)", i )
1430 res &= lastRes;
1434 return (res);
1438 //------------------------------------------------------------------------
1439 // testing the method copy( sal_Int32 beginIndex, sal_Int32 count )
1440 //------------------------------------------------------------------------
1441 static sal_Bool SAL_CALL test_rtl_OString_copy_002(
1442 hTestResult hRtlTestResult )
1444 sal_Char methName[MAXBUFLENGTH];
1445 sal_Char* pMeth = methName;
1447 typedef struct TestCase
1449 sal_Char* comments;
1450 const sal_Char* arrExpStr;
1451 sal_Int32 beginIndex;
1452 sal_Int32 count;
1453 sal_Int32 expLen;
1455 } TestCase;
1457 TestCase arrTestCase[] ={
1459 {"copy substring", kTestStr6, kTestStr11Len, kTestStr2Len - kTestStr11Len,kTestStr6Len},
1460 /* LLA: it is a bug, beginIndex + count > kTestStr2.getLength() */
1461 /* {"copy normal substring with incorrect count",kTestStr6, kTestStr11Len, 31, 15}, */
1462 {"copy whole string", kTestStr2, 0, kTestStr2Len, kTestStr2Len},
1463 /* {"copy whole string with incorrect count larger than len and index 0", kTestStr2, 0, 40, 32}, */
1464 /* LLA: bug beginIndex + count > kTestStr2 {"copy last character", "y",kTestStr2Len - 1, 31,1}, */
1465 {"copy last character", "y",kTestStr2Len - 1, 1,1},
1466 /* LLA: bug, beginIndex > kTestStr2 {"beginindex larger than len","",60, 0,0}, */
1467 {"beginindex exact as large as it's length","",kTestStr2Len, 0,0}
1468 /* LLA: bug, negative count is not allowed. {"count is nagative int","",3, -1,0} */
1470 sal_Bool res = sal_True;
1472 sal_uInt32 i;
1473 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) {
1474 OString src(kTestStr2);
1475 OString dst;
1476 dst = src.copy(arrTestCase[i].beginIndex, arrTestCase[i].count);
1477 // rtl_String* pDataSrc = src.pData;
1478 // rtl_String* pDataDst = dst.pData;
1480 sal_Bool lastRes=sal_True;
1481 // checks buffer and length
1482 //t_print("this is copy__002 #%d\n", i);
1483 //t_print("dst buffer =%s\n", pDataDst->buffer);
1484 //t_print("expStr =%s\n", arrTestCase[i].arrExpStr);
1485 //t_print("dst length =%d\n", pDataDst->length);
1486 //t_print("count =%d\n", arrTestCase[i].count);
1487 //t_print("expLen =%d\n", arrTestCase[i].expLen);
1489 lastRes = (dst.equals(arrTestCase[i].arrExpStr)) ? sal_True : sal_False;
1491 c_rtl_tres_state
1493 hRtlTestResult,
1494 lastRes,
1495 arrTestCase[i].comments,
1496 createName( pMeth,
1497 "copy_002(beginIndex,count)(check buffer and length)", i)
1499 res &= lastRes;
1504 return (res);
1508 static sal_Bool SAL_CALL test_rtl_OString_copy_003(
1509 hTestResult hRtlTestResult )
1511 sal_Bool res = sal_True;
1512 char comment[] = "copy whole short string to long string";
1514 OString src(kTestStr1);
1515 // rtl_String* pDataSrc = src.pData;
1516 OString dst(kTestStr2);
1518 dst = src.copy(0);
1519 // rtl_String* pDataDst = dst.pData;
1520 //check buffer and length
1521 sal_Bool lastRes =(dst==src);
1522 c_rtl_tres_state
1524 hRtlTestResult,
1525 lastRes,
1526 comment,
1527 "copy_003(beginIndex)(check buffer and length)"
1529 res &= lastRes;
1531 return (res);
1535 static sal_Bool SAL_CALL test_rtl_OString_copy_004(
1536 hTestResult hRtlTestResult )
1538 sal_Bool res = sal_True;
1539 sal_Char comment[] = "copy whole long string to short string";
1541 OString src(kTestStr2);
1542 // rtl_String* pDataSrc = src.pData;
1543 OString dst(kTestStr1);
1545 dst = src.copy(0);
1546 // rtl_String* pDataDst = dst.pData;
1547 //check buffer and length
1548 sal_Bool lastRes =(dst==src);
1549 c_rtl_tres_state
1551 hRtlTestResult,
1552 lastRes,
1553 comment,
1554 "copy_004(beginIndex)(check buffer and length)"
1557 res &= lastRes;
1558 return (res);
1561 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_copy(
1562 hTestResult hRtlTestResult )
1564 c_rtl_tres_state_start(hRtlTestResult, "copy");
1565 sal_Bool res = test_rtl_OString_copy_001(hRtlTestResult);
1566 res &= test_rtl_OString_copy_002(hRtlTestResult);
1567 res &= test_rtl_OString_copy_003(hRtlTestResult);
1568 res &= test_rtl_OString_copy_004(hRtlTestResult);
1569 c_rtl_tres_state_end(hRtlTestResult, "copy");
1571 // return ( res );
1574 //------------------------------------------------------------------------
1575 // testing the method concat( const OString & aStr )
1576 //------------------------------------------------------------------------
1577 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_concat(
1578 hTestResult hRtlTestResult )
1580 sal_Char methName[MAXBUFLENGTH];
1581 sal_Char* pMeth =methName;
1583 c_rtl_tres_state_start(hRtlTestResult, "concat");
1584 typedef struct TestCase
1586 sal_Char* comments;
1587 OString* expVal;
1588 OString* input1;
1589 OString* input2;
1590 ~TestCase() { delete input1;delete input2; delete expVal;}
1591 } TestCase;
1593 TestCase arrTestCase[] =
1595 {"concatenates two strings",new OString(kTestStr1),
1596 new OString(kTestStr7),
1597 new OString(kTestStr8)},
1598 {"concatenates empty string",new OString(kTestStr1),
1599 new OString(kTestStr1),
1600 new OString("")},
1601 {"concatenates to empty string",new OString(kTestStr1),
1602 new OString(""),
1603 new OString(kTestStr1)},
1604 {"concatenates two empty strings",new OString(""),new OString(""),
1605 new OString("")},
1606 {"concatenates string constructed by default constructor",
1607 new OString(kTestStr1),
1608 new OString(kTestStr1), new OString()},
1609 {"concatenates to string constructed by default constructor",
1610 new OString(kTestStr1),
1611 new OString(), new OString(kTestStr1)},
1612 {"concatenates two strings constructed by default constructor",
1613 new OString(),
1614 new OString(), new OString()}
1617 sal_Bool res = sal_True;
1618 sal_uInt32 i;
1619 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1621 OString str =
1622 arrTestCase[i].input1->concat(*arrTestCase[i].input2);
1623 sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1625 c_rtl_tres_state
1627 hRtlTestResult,
1628 lastRes,
1629 arrTestCase[i].comments,
1630 createName( pMeth, "concat", i)
1633 res &= lastRes;
1637 c_rtl_tres_state_end(hRtlTestResult, "concat");
1638 // return ( res );
1642 //------------------------------------------------------------------------
1643 // testing the method toAsciiLowerCase()
1644 //-----------------------------------------------------------------------
1645 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toAsciiLowerCase(
1646 hTestResult hRtlTestResult )
1648 sal_Char methName[MAXBUFLENGTH];
1649 sal_Char* pMeth =methName;
1651 c_rtl_tres_state_start(hRtlTestResult, "toAsciiLowerCase");
1652 typedef struct TestCase
1654 sal_Char* comments;
1655 OString* expVal;
1656 OString* input1;
1657 ~TestCase() { delete input1; delete expVal;}
1658 } TestCase;
1660 TestCase arrTestCase[] =
1663 {"only uppercase",new OString(kTestStr5),new OString(kTestStr4)},
1664 {"different cases",new OString(kTestStr5),new OString(kTestStr1)},
1665 {"different cases",new OString(kTestStr5),new OString(kTestStr3)},
1666 {"only lowercase",new OString(kTestStr5),new OString(kTestStr5)},
1667 {"empty string",new OString(""),new OString("")},
1668 {"string constructed by default constructor",
1669 new OString(),new OString()}
1672 sal_Bool res = sal_True;
1673 sal_uInt32 i;
1675 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1677 OString str = arrTestCase[i].input1->toAsciiLowerCase();
1678 sal_Bool lastRes = (str ==* arrTestCase[i].expVal);
1680 c_rtl_tres_state
1682 hRtlTestResult,
1683 lastRes,
1684 arrTestCase[i].comments,
1685 createName( pMeth, "toAsciiLowerCase", i)
1688 res &= lastRes;
1691 c_rtl_tres_state_end(hRtlTestResult, "toAsciiLowerCase");
1692 // return ( res );
1695 //------------------------------------------------------------------------
1696 // testing the method toAsciiUpperCase()
1697 //------------------------------------------------------------------------
1698 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toAsciiUpperCase(
1699 hTestResult hRtlTestResult )
1701 sal_Char methName[MAXBUFLENGTH];
1702 sal_Char* pMeth =methName;
1704 c_rtl_tres_state_start(hRtlTestResult, "toAsciiUpperCase");
1705 typedef struct TestCase
1707 sal_Char* comments;
1708 OString* expVal;
1709 OString* input1;
1710 ~TestCase() { delete input1; delete expVal;}
1711 } TestCase;
1713 TestCase arrTestCase[] =
1715 {"only lowercase",new OString(kTestStr4),new OString(kTestStr5)},
1716 {"mixed cases",new OString(kTestStr4),new OString(kTestStr3)},
1717 {"miced cases",new OString(kTestStr4),new OString(kTestStr1)},
1718 {"only uppercase",new OString(kTestStr4),new OString(kTestStr4)},
1719 {"empty string",new OString(""),new OString("")},
1720 {"string constructed by default constructor",
1721 new OString(),new OString()}
1724 sal_Bool res = sal_True;
1725 sal_uInt32 i;
1727 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1729 OString str = arrTestCase[i].input1->toAsciiUpperCase();
1730 sal_Bool lastRes = (str == *arrTestCase[i].expVal);
1732 c_rtl_tres_state
1734 hRtlTestResult,
1735 lastRes,
1736 arrTestCase[i].comments,
1737 createName( pMeth, "toAsciiLowerCase", i)
1740 res &= lastRes;
1742 c_rtl_tres_state_end(hRtlTestResult, "toAsciiUpperCase");
1744 // return ( res );
1748 //------------------------------------------------------------------------
1749 // testing the method trim()
1750 //------------------------------------------------------------------------
1751 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_trim(
1752 hTestResult hRtlTestResult )
1754 sal_Char methName[MAXBUFLENGTH];
1755 sal_Char* pMeth =methName;
1757 c_rtl_tres_state_start(hRtlTestResult, "trim");
1758 typedef struct TestCase
1760 sal_Char* comments;
1761 OString* expVal;
1762 OString* input1;
1763 ~TestCase() { delete input1; delete expVal;}
1764 } TestCase;
1766 TestCase arrTestCase[] =
1768 {"removes space from the front",new OString(kTestStr1),
1769 new OString(kTestStr10)},
1770 {"removes space from the end",new OString(kTestStr1),
1771 new OString(kTestStr11)},
1772 {"removes space from the front and end",new OString(kTestStr1),
1773 new OString(kTestStr12)},
1774 {"removes several spaces from the end",new OString(kTestStr1),
1775 new OString(kTestStr13)},
1776 {"removes several spaces from the front",new OString(kTestStr1),
1777 new OString(kTestStr14)},
1778 {"removes several spaces from the front and one from the end",
1779 new OString(kTestStr1),
1780 new OString(kTestStr15)},
1781 {"removes one space from the front and several from the end",
1782 new OString(kTestStr1),
1783 new OString(kTestStr16)},
1784 {"removes several spaces from the front and end",
1785 new OString(kTestStr1),
1786 new OString(kTestStr17)},
1787 {"removes characters that have codes <= 32",new OString(kTestStr20),
1788 new OString("\1\3\5\7\11\13\15\17sun\21\23\25\27\31\33\40")},
1789 {"no spaces",new OString(kTestStr8),new OString(kTestStr8)}
1792 sal_Bool res = sal_True;
1793 sal_uInt32 i;
1795 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1797 OString strRes = arrTestCase[i].input1->trim();
1798 sal_Bool lastRes = (strRes == *arrTestCase[i].expVal);
1800 c_rtl_tres_state
1802 hRtlTestResult,
1803 lastRes,
1804 arrTestCase[i].comments,
1805 createName( pMeth, "trim", i)
1808 res &= lastRes;
1812 c_rtl_tres_state_end(hRtlTestResult, "trim");
1813 // return ( res );
1818 //------------------------------------------------------------------------
1819 // testing the method valueOf( sal_Bool b )
1820 //------------------------------------------------------------------------
1821 sal_Bool SAL_CALL test_rtl_OString_valueOf_sal_Bool(
1822 hTestResult hRtlTestResult )
1824 sal_Char methName[MAXBUFLENGTH];
1825 sal_Char* pMeth =methName;
1827 typedef struct TestCase
1829 sal_Char* comments;
1830 sal_Bool input1;
1831 OString* expVal;
1832 ~TestCase() {delete expVal;}
1833 } TestCase;
1835 TestCase arrTestCase[] =
1837 {"true",sal_True,new OString("true")},
1838 {"false",sal_False, new OString("false")}
1841 sal_Bool res = sal_True;
1842 sal_uInt32 i;
1844 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1846 ::rtl::OString aStr1;
1847 aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
1848 sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
1850 c_rtl_tres_state
1852 hRtlTestResult,
1853 lastRes,
1854 arrTestCase[i].comments,
1855 createName( pMeth, "valueof_bool", i)
1858 res &= lastRes;
1862 return ( res );
1865 sal_Bool SAL_CALL test_rtl_OString_valueOf_sal_Char(
1866 hTestResult hRtlTestResult )
1868 sal_Char methName[MAXBUFLENGTH];
1869 sal_Char* pMeth =methName;
1871 typedef struct TestCase
1873 sal_Char* comments;
1874 sal_Char input1;
1875 OString* expVal;
1876 ~TestCase() {delete expVal;}
1877 } TestCase;
1879 TestCase arrTestCase[] =
1881 {"A",'A',new OString("A")},
1882 {"a",'a', new OString("a")},
1883 {"0",'0', new OString("0")},
1884 {"-",'-', new OString("-")},
1885 {"_",'_', new OString("_")},
1886 {"|",'|', new OString("|")},
1887 {"?",'?', new OString("?")},
1888 {"?",'?', new OString("?")},
1889 {"\n",'\n', new OString("\n")},
1890 {"\'",'\'', new OString("\'")},
1891 {"\"",'\"', new OString("\"")}
1895 sal_Bool res = sal_True;
1896 sal_uInt32 i;
1898 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1900 ::rtl::OString aStr1;
1901 aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
1902 sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
1904 c_rtl_tres_state
1906 hRtlTestResult,
1907 lastRes,
1908 arrTestCase[i].comments,
1909 createName( pMeth, "valueof_char", i)
1912 res &= lastRes;
1916 return ( res );
1920 * Calls the method valueOf(T, radix) and compares
1921 * returned strings with strings that passed in the array resArray.
1923 * @param T, type of argument, passed to valueOf
1924 * @param resArray, array of result strings to compare to
1925 * @param n the number of elements in the array resArray (testcases)
1926 * @param pTestResult the instance of the class TestResult
1927 * @param inArray [optional], array of value that is passed as first argument
1928 * to valueOf
1930 * @return true, if all returned strings are equal to corresponding string in
1931 * resArray else, false.
1933 template <class T>
1934 sal_Bool test_valueOf( const char** resArray, int n, sal_Int16 radix,
1935 hTestResult hRtlTestResult, const T *inArray )
1937 sal_Bool bRes = sal_True;
1939 sal_Char methName[MAXBUFLENGTH];
1940 sal_Char* pMeth = methName;
1941 sal_Int32 i;
1943 for (i = 0; i < n; i++)
1945 ::rtl::OString aStr1;
1946 ::rtl::OString aStr2( resArray[i] );
1948 if (inArray == 0)
1949 aStr1 = ::rtl::OString::valueOf((T)i, radix);
1950 else
1952 if ( inArray[i] < 0 )
1954 aStr2 = "-";
1955 aStr2 += resArray[i];
1957 aStr1 = ::rtl::OString::valueOf((T)inArray[i], radix);
1960 bRes &= c_rtl_tres_state
1962 hRtlTestResult,
1963 aStr2.compareTo(aStr1) == 0,
1964 (sal_Char*)resArray[i],
1965 createName( pMeth, "valueOf", i )
1969 return (bRes);
1973 #define test_valueOf_Int32 test_valueOf<sal_Int32>
1974 #define test_valueOf_Int64 test_valueOf<sal_Int64>
1975 // LLA: #define test_valueOf_float test_valueOf<float>
1976 // LLA: #define test_valueOf_double test_valueOf<double>
1978 //------------------------------------------------------------------------
1979 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=2 )
1980 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=8 )
1981 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=10 )
1982 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=16 )
1983 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=36 )
1984 //------------------------------------------------------------------------
1985 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32(
1986 hTestResult hRtlTestResult )
1988 sal_Bool bRes = sal_False;
1990 bRes = c_rtl_tres_state
1992 hRtlTestResult,
1993 test_valueOf_Int32((const char**)kBinaryNumsStr,
1994 kBinaryNumsCount, kRadixBinary, hRtlTestResult, 0 ),
1995 "kRadixBinary",
1996 "valueOf(sal_Int32, radix 2)"
2000 bRes &= c_rtl_tres_state
2002 hRtlTestResult,
2003 test_valueOf_Int32((const char**)kOctolNumsStr,
2004 kOctolNumsCount, kRadixOctol, hRtlTestResult, 0),
2005 "kRadixOctol",
2006 "valueOf(sal_Int32, radix 8)"
2009 bRes &= c_rtl_tres_state
2011 hRtlTestResult,
2012 test_valueOf_Int32((const char**)kDecimalNumsStr,
2013 kDecimalNumsCount, kRadixDecimal, hRtlTestResult, 0),
2014 "kRadixDecimal",
2015 "valueOf(sal_Int32, radix 10)"
2018 bRes &= c_rtl_tres_state
2020 hRtlTestResult,
2021 test_valueOf_Int32((const char**)kHexDecimalNumsStr,
2022 kHexDecimalNumsCount, kRadixHexdecimal, hRtlTestResult, 0),
2023 "kRadixHexdecimal",
2024 "valueOf(sal_Int32, radix 16)"
2027 bRes &= c_rtl_tres_state
2029 hRtlTestResult,
2030 test_valueOf_Int32((const char**)kBase36NumsStr,
2031 kBase36NumsCount, kRadixBase36, hRtlTestResult, 0),
2032 "kRadixBase36",
2033 "valueOf(sal_Int32, radix 36)"
2037 return ( bRes );
2040 //------------------------------------------------------------------------
2041 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=2 )
2042 // where l = large constants
2043 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=8 )
2044 // where l = large constants
2045 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=10 )
2046 // where l = large constants
2047 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=16 )
2048 // where l = large constants
2049 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=36 )
2050 // where l = large constants
2051 //------------------------------------------------------------------------
2052 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_Bounderies(
2053 hTestResult hRtlTestResult )
2055 sal_Bool bRes = sal_False;
2057 bRes = c_rtl_tres_state
2059 hRtlTestResult,
2060 test_valueOf_Int32((const char**)kBinaryMaxNumsStr,
2061 kInt32MaxNumsCount, kRadixBinary, hRtlTestResult,
2062 kInt32MaxNums),
2063 "kRadixBinary",
2064 "valueOf(salInt32, radix 2) Bounderies"
2067 bRes &= c_rtl_tres_state
2069 hRtlTestResult,
2070 test_valueOf_Int32((const char**)kOctolMaxNumsStr,
2071 kInt32MaxNumsCount, kRadixOctol, hRtlTestResult,
2072 kInt32MaxNums),
2073 "kRadixOctol",
2074 "valueOf(salInt32, radix 8) Bounderies"
2077 bRes &= c_rtl_tres_state
2079 hRtlTestResult,
2080 test_valueOf_Int32((const char**)kDecimalMaxNumsStr,
2081 kInt32MaxNumsCount, kRadixDecimal,
2082 hRtlTestResult, kInt32MaxNums),
2083 "kRadixDecimal",
2084 "valueOf(salInt32, radix 10) Bounderies"
2087 bRes &= c_rtl_tres_state
2089 hRtlTestResult,
2090 test_valueOf_Int32((const char**)kHexDecimalMaxNumsStr,
2091 kInt32MaxNumsCount, kRadixHexdecimal,
2092 hRtlTestResult, kInt32MaxNums),
2093 "kRadixHexdecimal",
2094 "valueOf(salInt32, radix 16) Bounderies"
2097 bRes &= c_rtl_tres_state
2099 hRtlTestResult,
2100 test_valueOf_Int32((const char**)kBase36MaxNumsStr,
2101 kInt32MaxNumsCount, kRadixBase36,
2102 hRtlTestResult, kInt32MaxNums),
2103 "kRadixBase36",
2104 "valueOf(salInt32, radix 36) Bounderies"
2107 return ( bRes );
2110 //------------------------------------------------------------------------
2111 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=2 )
2112 // for negative value
2113 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=8 )
2114 // for negative value
2115 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=10 )
2116 // for negative value
2117 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=16 )
2118 // for negative value
2119 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=36 )
2120 // for negative value
2121 //------------------------------------------------------------------------
2122 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_Negative(
2123 hTestResult hRtlTestResult )
2125 sal_Bool bRes = sal_False;
2126 sal_Int32 inArr[kBase36NumsCount];
2127 sal_Int32 i;
2129 for (i = 0; i < kBase36NumsCount; i++ )
2130 inArr[i] = -i;
2132 bRes = c_rtl_tres_state
2134 hRtlTestResult,
2135 test_valueOf_Int32( kBinaryNumsStr, kBinaryNumsCount,
2136 kRadixBinary, hRtlTestResult, inArr ),
2137 "negative Int32, kRadixBinary",
2138 "valueOf( negative Int32, radix 2 )"
2141 bRes &= c_rtl_tres_state
2143 hRtlTestResult,
2144 test_valueOf_Int32( kOctolNumsStr, kOctolNumsCount,
2145 kRadixOctol, hRtlTestResult, inArr ),
2146 "negative Int32, kRadixOctol",
2147 "valueOf( negative Int32, radix 8 )"
2151 bRes &= c_rtl_tres_state
2153 hRtlTestResult,
2154 test_valueOf_Int32( kDecimalNumsStr, kDecimalNumsCount,
2155 kRadixDecimal, hRtlTestResult, inArr ),
2156 "negative Int32, kRadixDecimal",
2157 "valueOf( negative Int32, radix 10 )"
2160 bRes &= c_rtl_tres_state
2162 hRtlTestResult,
2163 test_valueOf_Int32( kHexDecimalNumsStr, kHexDecimalNumsCount,
2164 kRadixHexdecimal, hRtlTestResult, inArr ),
2165 "negative Int32, kRadixHexdecimal",
2166 "valueOf( negative Int32, radix 16 )"
2170 bRes &= c_rtl_tres_state
2172 hRtlTestResult,
2173 test_valueOf_Int32( kBase36NumsStr, kBase36NumsCount,
2174 kRadixBase36, hRtlTestResult, inArr ),
2175 "negative Int32, kRadixBase36",
2176 "valueOf( negative Int32, radix 36 )"
2179 return ( bRes );
2181 //------------------------------------------------------------------------
2182 // testing the method valueOf( sal_Int32 l, sal_Int32 radix ) where radix = -5
2183 //------------------------------------------------------------------------
2184 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_WrongRadix(
2185 hTestResult hRtlTestResult )
2187 sal_Bool bRes = sal_False;
2189 sal_Int32 intVal = 11;
2191 ::rtl::OString aStr1;
2192 ::rtl::OString aStr2("11");
2194 aStr1 = aStr1.valueOf( intVal, -5 );
2196 bRes = c_rtl_tres_state
2198 hRtlTestResult,
2199 aStr2.compareTo( aStr1 ) == 0,
2200 "if radix not valid then radix must be 10",
2201 "valueOf(sal_Int32, sal_Int32 radix): radix = -5"
2204 return (bRes);
2207 //------------------------------------------------------------------------
2208 // testing the method valueOf( sal_Int32 l, sal_Int32 radix )
2209 // where l = -2147483648 (smallest negative value)
2210 //------------------------------------------------------------------------
2211 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int32_SmallestNegativeValue(
2212 hTestResult hRtlTestResult)
2214 // Standard-conforming way to assign -2147483648 to n:
2215 sal_Int32 n = -1;
2216 for (int i = 1; i < 32; ++i)
2217 n *= 2;
2218 return c_rtl_tres_state
2220 hRtlTestResult,
2221 ::rtl::OString::valueOf(n) == "-2147483648",
2222 "-2147483648",
2223 "valueOf(sal_Int32 -2147483648)"
2227 //------------------------------------------------------------------------
2228 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=2 )
2229 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=8 )
2230 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=10 )
2231 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=16 )
2232 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=36 )
2233 //------------------------------------------------------------------------
2234 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64(
2235 hTestResult hRtlTestResult )
2237 sal_Bool bRes = sal_False;
2239 bRes = c_rtl_tres_state
2241 hRtlTestResult,
2242 test_valueOf_Int64((const char**)kBinaryNumsStr,
2243 kBinaryNumsCount, kRadixBinary, hRtlTestResult, 0),
2244 "kRadixBinary",
2245 "valueOf(sal_Int64, radix 2)_"
2248 bRes &= c_rtl_tres_state
2250 hRtlTestResult,
2251 test_valueOf_Int64((const char**)kOctolNumsStr,
2252 kOctolNumsCount, kRadixOctol, hRtlTestResult, 0),
2253 "kRadixOctol",
2254 "valueOf(sal_Int64, radix 8)_"
2257 bRes &= c_rtl_tres_state
2259 hRtlTestResult,
2260 test_valueOf_Int64((const char**)kDecimalNumsStr,
2261 kDecimalNumsCount, kRadixDecimal, hRtlTestResult, 0),
2262 "kRadixDecimal",
2263 "valueOf(sal_Int64, radix 10)_"
2265 bRes &= c_rtl_tres_state
2267 hRtlTestResult,
2268 test_valueOf_Int64((const char**)kHexDecimalNumsStr,
2269 kHexDecimalNumsCount, kRadixHexdecimal, hRtlTestResult, 0),
2270 "kRadixHexdecimal",
2271 "valueOf(sal_Int64, radix 16)_"
2274 bRes &= c_rtl_tres_state
2276 hRtlTestResult,
2277 test_valueOf_Int64((const char**)kBase36NumsStr,
2278 kBase36NumsCount, kRadixBase36, hRtlTestResult, 0),
2279 "kRadixBase36",
2280 "valueOf(sal_Int64, radix 36)_"
2283 return (bRes);
2286 //------------------------------------------------------------------------
2287 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=2 )
2288 // where l = large constants
2289 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=8 )
2290 // where l = large constants
2291 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=10 )
2292 // where l = large constants
2293 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=16 )
2294 // where l = large constants
2295 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=36 )
2296 // where l = large constants
2297 //------------------------------------------------------------------------
2298 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_Bounderies(
2299 hTestResult hRtlTestResult )
2301 sal_Bool bRes = sal_False;
2303 bRes = c_rtl_tres_state
2305 hRtlTestResult,
2306 test_valueOf_Int64((const char**)kBinaryMaxNumsStr,
2307 kInt64MaxNumsCount, kRadixBinary,
2308 hRtlTestResult, kInt64MaxNums),
2309 "kRadixBinary",
2310 "valueOf(salInt64, radix 2) Bounderies"
2313 bRes &= c_rtl_tres_state
2315 hRtlTestResult,
2316 test_valueOf_Int64((const char**)kOctolMaxNumsStr,
2317 kInt64MaxNumsCount, kRadixOctol,
2318 hRtlTestResult, kInt64MaxNums),
2319 "kRadixOctol",
2320 "valueOf(salInt64, radix 8) Bounderies"
2323 bRes &= c_rtl_tres_state
2325 hRtlTestResult,
2326 test_valueOf_Int64((const char**)kDecimalMaxNumsStr,
2327 kInt64MaxNumsCount, kRadixDecimal,
2328 hRtlTestResult, kInt64MaxNums),
2329 "kRadixDecimal",
2330 "valueOf(salInt64, radix 10) Bounderies"
2333 bRes &= c_rtl_tres_state
2335 hRtlTestResult,
2336 test_valueOf_Int64((const char**)kHexDecimalMaxNumsStr,
2337 kInt64MaxNumsCount, kRadixHexdecimal,
2338 hRtlTestResult, kInt64MaxNums),
2339 "kRadixHexdecimal",
2340 "valueOf(salInt64, radix 16) Bounderies"
2343 bRes &= c_rtl_tres_state
2345 hRtlTestResult,
2346 test_valueOf_Int64((const char**)kBase36MaxNumsStr,
2347 kInt64MaxNumsCount, kRadixBase36,
2348 hRtlTestResult, kInt64MaxNums),
2349 "kRadixBase36",
2350 "valueOf(salInt64, radix 36) Bounderies"
2353 return ( bRes );
2356 //------------------------------------------------------------------------
2357 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=2 )
2358 // for negative value
2359 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=8 )
2360 // for negative value
2361 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=10 )
2362 // for negative value
2363 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=16 )
2364 // for negative value
2365 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=36 )
2366 // for negative value
2367 //------------------------------------------------------------------------
2368 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_Negative(
2369 hTestResult hRtlTestResult )
2371 sal_Bool bRes = sal_False;
2373 sal_Int64 inArr[36];
2374 sal_Int32 i;
2376 for (i = 0; i < 36; i++) {
2377 inArr[i] = -i;
2381 bRes = c_rtl_tres_state
2383 hRtlTestResult,
2384 test_valueOf_Int64( kBinaryNumsStr, kBinaryNumsCount,
2385 kRadixBinary, hRtlTestResult, inArr ),
2386 "negative Int64, kRadixBinary",
2387 "valueOf( negative Int64, radix 2 )"
2390 bRes &= c_rtl_tres_state
2392 hRtlTestResult,
2393 test_valueOf_Int64( kOctolNumsStr, kOctolNumsCount,
2394 kRadixOctol, hRtlTestResult, inArr ),
2395 "negative Int64, kRadixOctol",
2396 "valueOf( negative Int64, radix 8 )"
2399 bRes &= c_rtl_tres_state
2401 hRtlTestResult,
2402 test_valueOf_Int64( kDecimalNumsStr, kDecimalNumsCount,
2403 kRadixDecimal, hRtlTestResult, inArr ),
2404 "negative Int64, kRadixDecimal",
2405 "valueOf( negative Int64, radix 10 )"
2408 bRes &= c_rtl_tres_state
2410 hRtlTestResult,
2411 test_valueOf_Int64( kHexDecimalNumsStr, kHexDecimalNumsCount,
2412 kRadixHexdecimal, hRtlTestResult, inArr ),
2413 "negative Int64, kRadixHexDecimal",
2414 "valueOf( negative Int64, radix 16 )"
2417 bRes &= c_rtl_tres_state
2419 hRtlTestResult,
2420 test_valueOf_Int64( kBase36NumsStr, kBase36NumsCount,
2421 kRadixBase36, hRtlTestResult, inArr),
2422 "negative Int64, kRadixBase36",
2423 "valueOf( negative Int64, radix 36 )"
2426 return (bRes);
2428 //------------------------------------------------------------------------
2429 // testing the method valueOf( sal_Int64 l, sal_Int32 radix )
2430 // where radix = -5
2431 //------------------------------------------------------------------------
2432 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_WrongRadix(
2433 hTestResult hRtlTestResult )
2435 sal_Bool bRes = sal_False;
2437 sal_Int64 intVal = 11;
2439 ::rtl::OString aStr1;
2440 ::rtl::OString aStr2("11");
2442 aStr1 = aStr1.valueOf( intVal, -5 );
2444 bRes = c_rtl_tres_state
2446 hRtlTestResult,
2447 aStr2.compareTo(aStr1) == 0,
2448 "if radix not valid then radix must be 10",
2449 "valueOf(sal_Int64, sal_Int32 radix): radix = -5"
2452 return (bRes);
2455 //------------------------------------------------------------------------
2456 // testing the method valueOf( sal_Int64 l, sal_Int32 radix )
2457 // where l = -9223372036854775808 (smallest negative value)
2458 //------------------------------------------------------------------------
2459 sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_SmallestNegativeValue(
2460 hTestResult hRtlTestResult)
2462 // Standard-conforming way to assign -9223372036854775808 to n:
2463 sal_Int64 n = -1;
2464 for (int i = 1; i < 64; ++i)
2465 n *= 2;
2466 return c_rtl_tres_state
2468 hRtlTestResult,
2469 ::rtl::OString::valueOf(n) == "-9223372036854775808",
2470 "-9223372036854775808",
2471 "valueOf(sal_Int64 -9223372036854775808)"
2475 //------------------------------------------------------------------------
2476 // testing the method valueOf( float f )
2477 //------------------------------------------------------------------------
2478 // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_float(
2479 // LLA: hTestResult hRtlTestResult )
2480 // LLA: {
2481 // LLA: sal_Char methName[MAXBUFLENGTH];
2482 // LLA: sal_Char* pMeth =methName;
2483 // LLA:
2484 // LLA: typedef struct TestCase
2485 // LLA: {
2486 // LLA: sal_Char* comments;
2487 // LLA: float input1;
2488 // LLA: OString* expVal;
2489 // LLA:
2490 // LLA: ~TestCase() {delete expVal;}
2491 // LLA: } TestCase;
2492 // LLA:
2493 // LLA: TestCase arrTestCase[] =
2494 // LLA: {
2495 // LLA: { "3.0", 3.0, new OString("3.0") },
2496 // LLA: { "3.5", 3.5f, new OString("3.5")},
2497 // LLA: { "3.0625", 3.0625f, new OString("3.0625")},
2498 // LLA: { "3.502525", 3.502525f, new OString("3.502525") },
2499 // LLA: { "3.141592", 3.141592f, new OString("3.141592") },
2500 // LLA: { "3.5025255", 3.5025255f, new OString("3.5025255") },
2501 // LLA: { "3.0039062", 3.00390625f, new OString("3.0039062") }
2502 // LLA: };
2503 // LLA:
2504 // LLA: sal_Bool res = sal_True;
2505 // LLA: sal_Int32 i;
2506 // LLA:
2507 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2508 // LLA: {
2509 // LLA: ::rtl::OString aStr1;
2510 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2511 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2512 // LLA:
2513 // LLA: c_rtl_tres_state
2514 // LLA: (
2515 // LLA: hRtlTestResult,
2516 // LLA: lastRes,
2517 // LLA: arrTestCase[i].comments,
2518 // LLA: createName( pMeth, "valueof_float", i)
2519 // LLA: );
2520 // LLA:
2521 // LLA: res &= lastRes;
2522 // LLA:
2523 // LLA: }
2524 // LLA:
2525 // LLA: return ( res );
2526 // LLA: }
2531 //------------------------------------------------------------------------
2532 // testing the method valueOf( float f ) for negative value
2533 //------------------------------------------------------------------------
2534 // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_Float_Negative(
2535 // LLA: hTestResult hRtlTestResult )
2536 // LLA: {
2537 // LLA: sal_Char methName[MAXBUFLENGTH];
2538 // LLA: sal_Char* pMeth =methName;
2539 // LLA:
2540 // LLA: typedef struct TestCase
2541 // LLA: {
2542 // LLA: sal_Char* comments;
2543 // LLA: float input1;
2544 // LLA: OString* expVal;
2545 // LLA:
2546 // LLA: ~TestCase() {delete expVal;}
2547 // LLA: } TestCase;
2548 // LLA:
2549 // LLA: TestCase arrTestCase[] =
2550 // LLA: {
2551 // LLA: { "-3.0", -3.0, new OString("-3.0") },
2552 // LLA: { "-3.5", -3.5f, new OString("-3.5")},
2553 // LLA: { "-3.0625", -3.0625f, new OString("-3.0625")},
2554 // LLA: { "-3.502525", -3.502525f, new OString("-3.502525") },
2555 // LLA: { "-3.141592", -3.141592f, new OString("-3.141592") },
2556 // LLA: { "-3.5025255", -3.5025255f, new OString("-3.5025255") },
2557 // LLA: { "-3.0039062", -3.00390625f, new OString("-3.0039062") }
2558 // LLA: };
2559 // LLA:
2560 // LLA: sal_Bool res = sal_True;
2561 // LLA: sal_Int32 i;
2562 // LLA:
2563 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2564 // LLA: {
2565 // LLA: ::rtl::OString aStr1;
2566 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2567 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2568 // LLA:
2569 // LLA: c_rtl_tres_state
2570 // LLA: (
2571 // LLA: hRtlTestResult,
2572 // LLA: lastRes,
2573 // LLA: arrTestCase[i].comments,
2574 // LLA: createName( pMeth, "valueof_negative float", i)
2575 // LLA: );
2576 // LLA:
2577 // LLA: res &= lastRes;
2578 // LLA:
2579 // LLA: }
2580 // LLA:
2581 // LLA: return ( res );
2582 // LLA: }
2584 //------------------------------------------------------------------------
2585 // testing the method valueOf( double f )
2586 //------------------------------------------------------------------------
2587 // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_double(
2588 // LLA: hTestResult hRtlTestResult )
2589 // LLA: {
2590 // LLA: sal_Char methName[MAXBUFLENGTH];
2591 // LLA: sal_Char* pMeth =methName;
2592 // LLA:
2593 // LLA: typedef struct TestCase
2594 // LLA: {
2595 // LLA: sal_Char* comments;
2596 // LLA: double input1;
2597 // LLA: OString* expVal;
2598 // LLA:
2599 // LLA: ~TestCase() {delete expVal;}
2600 // LLA: } TestCase;
2601 // LLA:
2602 // LLA: TestCase arrTestCase[] =
2603 // LLA: {
2604 // LLA: {"3.0", 3.0, new OString("3.0")},
2605 // LLA: {"3.5", 3.5, new OString("3.5")},
2606 // LLA: {"3.0625", 3.0625, new OString("3.0625")},
2607 // LLA: {"3.1415926535", 3.1415926535, new OString("3.1415926535")},
2608 // LLA: {"3.1415926535897931", 3.141592653589793,
2609 // LLA: new OString("3.1415926535897931")},
2610 // LLA: {"3.1415926535897931", 3.1415926535897932,
2611 // LLA: new OString("3.1415926535897931")},
2612 // LLA: {"3.1415926535897931", 3.14159265358979323,
2613 // LLA: new OString("3.1415926535897931")},
2614 // LLA: {"3.1415926535897931", 3.141592653589793238462643,
2615 // LLA: new OString("3.1415926535897931")}
2616 // LLA: };
2617 // LLA:
2618 // LLA: sal_Bool res = sal_True;
2619 // LLA: sal_Int32 i;
2620 // LLA:
2621 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2622 // LLA: {
2623 // LLA: ::rtl::OString aStr1;
2624 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2625 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2626 // LLA:
2627 // LLA: c_rtl_tres_state
2628 // LLA: (
2629 // LLA: hRtlTestResult,
2630 // LLA: lastRes,
2631 // LLA: arrTestCase[i].comments,
2632 // LLA: createName( pMeth, "valueof_double", i)
2633 // LLA: );
2634 // LLA:
2635 // LLA: res &= lastRes;
2636 // LLA:
2637 // LLA: }
2638 // LLA:
2639 // LLA: return ( res );
2640 // LLA: }
2643 //------------------------------------------------------------------------
2644 // testing the method valueOf( double f ) for negative value
2645 //------------------------------------------------------------------------
2646 // LLA: sal_Bool SAL_CALL test_rtl_OString_valueOf_Double_Negative(
2647 // LLA: hTestResult hRtlTestResult )
2648 // LLA: {
2649 // LLA: sal_Char methName[MAXBUFLENGTH];
2650 // LLA: sal_Char* pMeth =methName;
2651 // LLA:
2652 // LLA: typedef struct TestCase
2653 // LLA: {
2654 // LLA: sal_Char* comments;
2655 // LLA: double input1;
2656 // LLA: OString* expVal;
2657 // LLA:
2658 // LLA: ~TestCase() {delete expVal;}
2659 // LLA: } TestCase;
2660 // LLA:
2661 // LLA: TestCase arrTestCase[] =
2662 // LLA: {
2663 // LLA: {"-3.0", -3.0, new OString("-3.0")},
2664 // LLA: {"-3.5", -3.5, new OString("-3.5")},
2665 // LLA: {"-3.0625", -3.0625, new OString("-3.0625")},
2666 // LLA: {"-3.1415926535", -3.1415926535, new OString("-3.1415926535")},
2667 // LLA: {"-3.1415926535897931", -3.141592653589793,
2668 // LLA: new OString("-3.1415926535897931")},
2669 // LLA: {"-3.1415926535897931", -3.1415926535897932,
2670 // LLA: new OString("-3.1415926535897931")},
2671 // LLA: {"-3.1415926535897931", -3.14159265358979323,
2672 // LLA: new OString("-3.1415926535897931")},
2673 // LLA: {"-3.1415926535897931", -3.141592653589793238462643,
2674 // LLA: new OString("-3.1415926535897931")}
2675 // LLA: };
2676 // LLA:
2677 // LLA: sal_Bool res = sal_True;
2678 // LLA: sal_Int32 i;
2679 // LLA:
2680 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2681 // LLA: {
2682 // LLA: ::rtl::OString aStr1;
2683 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2684 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2685 // LLA:
2686 // LLA: c_rtl_tres_state
2687 // LLA: (
2688 // LLA: hRtlTestResult,
2689 // LLA: lastRes,
2690 // LLA: arrTestCase[i].comments,
2691 // LLA: createName( pMeth, "valueof_nagative double", i)
2692 // LLA: );
2693 // LLA:
2694 // LLA: res &= lastRes;
2695 // LLA:
2696 // LLA: }
2697 // LLA:
2698 // LLA: return ( res );
2699 // LLA: }
2701 //------------------------------------------------------------------------
2702 // testing the method valueOf()
2703 //------------------------------------------------------------------------
2704 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_valueOf(
2705 hTestResult hRtlTestResult )
2707 c_rtl_tres_state_start(hRtlTestResult, "valueOf");
2708 sal_Bool bTState = test_rtl_OString_valueOf_sal_Bool( hRtlTestResult );
2710 bTState &= test_rtl_OString_valueOf_sal_Char( hRtlTestResult );
2712 bTState &= test_rtl_OString_valueOf_Int32( hRtlTestResult );
2713 bTState &= test_rtl_OString_valueOf_Int32_Bounderies( hRtlTestResult );
2714 bTState &= test_rtl_OString_valueOf_Int32_Negative( hRtlTestResult );
2715 bTState &= test_rtl_OString_valueOf_Int32_WrongRadix( hRtlTestResult );
2716 bTState &= test_rtl_OString_valueOf_Int32_SmallestNegativeValue(
2717 hRtlTestResult );
2719 bTState &= test_rtl_OString_valueOf_Int64( hRtlTestResult );
2720 bTState &= test_rtl_OString_valueOf_Int64_Bounderies( hRtlTestResult );
2721 bTState &= test_rtl_OString_valueOf_Int64_Negative( hRtlTestResult );
2722 bTState &= test_rtl_OString_valueOf_Int64_WrongRadix( hRtlTestResult );
2723 bTState &= test_rtl_OString_valueOf_Int64_SmallestNegativeValue(
2724 hRtlTestResult );
2726 // LLA: the tests for valueOf(float) and valueOf(double) are moved to file
2727 // sal/qa/rtl/ostring/rtl_OString2.cxx
2729 // LLA: bTState &= test_rtl_OString_valueOf_float( hRtlTestResult );
2730 // LLA: bTState &= test_rtl_OString_valueOf_Float_Negative( hRtlTestResult );
2732 // LLA: bTState &= test_rtl_OString_valueOf_double( hRtlTestResult );
2733 // LLA: bTState &= test_rtl_OString_valueOf_Double_Negative( hRtlTestResult );
2735 c_rtl_tres_state_end(hRtlTestResult, "valueOf");
2736 // return ( bTState );
2740 //------------------------------------------------------------------------
2741 // testing the method toChar()
2742 //------------------------------------------------------------------------
2743 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toChar(
2744 hTestResult hRtlTestResult )
2746 sal_Char methName[MAXBUFLENGTH];
2747 sal_Char* pMeth = methName;
2749 c_rtl_tres_state_start(hRtlTestResult, "toChar");
2750 typedef struct TestCase
2752 sal_Char* comments;
2753 sal_Char expVal;
2754 OString* input1;
2755 ~TestCase() {delete input1;}
2756 } TestCase;
2759 TestCase arrTestCase[] =
2761 {"A", 'A', new OString("A")},
2762 {"a", 'a', new OString("a")},
2763 {"0", '0',new OString("0")},
2764 {"-", '-',new OString("-")},
2765 {"_", '_',new OString("_")},
2767 // TODO: may be UTF-8 values
2768 // {"�0„6", '�0„6',new OString("�0„6")},
2769 // { "�0„7", '�0„7',new OString("�0„7")},
2770 // {"�0‹0", '�0‹0',new OString("�0‹0")},
2771 // {"�0�6", '�0�6',new OString("�0�6")},
2772 {"\n", '\n',new OString("\n")},
2773 {"\'", '\'',new OString("\'")},
2774 {"\"", '\"',new OString("\"")},
2775 {"\0", '\0',new OString("\0")},
2776 {"", '\0',new OString("")},
2777 {"Sun Microsystems", 'S', new OString(kTestStr1)}
2781 // sal_Bool res = sal_True;
2782 sal_uInt32 i;
2784 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++ )
2786 sal_Char strRes = arrTestCase[i].input1->toChar();
2787 sal_Bool lastRes = ( strRes == arrTestCase[i].expVal );
2789 char com[MAXBUFLENGTH];
2790 com[0] = '\'';
2791 cpynstr(com + 1, (*arrTestCase[i].input1), MAXBUFLENGTH);
2792 int length = AStringLen( (*arrTestCase[i].input1) );
2793 com[length + 1] = '\'';
2794 com[length + 2] = 0;
2796 c_rtl_tres_state
2798 hRtlTestResult,
2799 lastRes,
2800 com,
2801 createName( pMeth, "toChar", i )
2806 c_rtl_tres_state_end(hRtlTestResult, "toChar");
2807 // return (res);
2811 //------------------------------------------------------------------------
2812 // testing the method toFloat()
2813 //------------------------------------------------------------------------
2814 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toFloat(
2815 hTestResult hRtlTestResult )
2817 sal_Char methName[MAXBUFLENGTH];
2818 sal_Char* pMeth = methName;
2820 c_rtl_tres_state_start(hRtlTestResult, "toFloat");
2821 typedef struct TestCase
2823 float expVal;
2824 OString* input1;
2825 float m_nPrecision;
2826 ~TestCase() {delete input1;}
2827 } TestCase;
2830 TestCase arrTestCase[] =
2832 {3.0f, new OString("3"), 3e-7f},
2833 {3.1f, new OString("3.1"), 3e-7f},
2834 {3.1415f, new OString("3.1415"), 3e-7f},
2835 {3.14159f, new OString("3.14159"), 3e-7f},
2836 {3.141592f, new OString("3.141592"), 3e-7f},
2837 {3.1415926f, new OString("3.1415926"), 3e-7f},
2838 {3.14159265f, new OString("3.14159265"), 3e-7f},
2839 {3.141592653589793238462643f,
2840 new OString("3.141592653589793238462643"), 3e-7f},
2841 {6.5822e-16f, new OString("6.5822e-16"), 6e-16f * 1e-7f},
2842 {9.1096e-31f, new OString("9.1096e-31"), 9e-31f * 1e-7f},
2843 {2.997925e8f, new OString("2.997925e8"), 3e8f * 1e-7f},
2844 {6.241e18f, new OString("6.241e18"), 6e18f * 1e-7f},
2845 {3.1f, new OString("03.1"), 3e-7f},
2846 {3.1f, new OString(" 3.1"), 3e-7f},
2847 {-3.1f, new OString("-3.1"), 3e-7f},
2848 {3.1f, new OString("+3.1"), 3e-7f},
2849 {0.0f, new OString("-0.0"), 1e-7f}
2853 // sal_Bool res = sal_True;
2854 sal_uInt32 i;
2856 t_print("sizeof(float)=%d, sizeof(double)=%d\n", sizeof(float), sizeof(double));
2858 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++ )
2860 float fA = arrTestCase[i].input1->toFloat();
2861 float fB = arrTestCase[i].expVal;
2862 float fPrec = arrTestCase[i].m_nPrecision;
2863 float fResult = (float) fabs(fA - fB);
2864 // t_print("float result: A:(%.9f) B:(%.9f) fabs(A-B):%E\n", fA, fB, fResult);
2865 t_print("float result: A:(%E) B:(%E) fabs(A-B):%E\n", fA, fB, (float) fResult);
2866 sal_Bool lastRes = ( fResult <= fPrec );
2868 char com[MAXBUFLENGTH];
2869 com[0] = '\'';
2870 cpynstr(com + 1, (*arrTestCase[i].input1), MAXBUFLENGTH);
2871 int length = AStringLen( (*arrTestCase[i].input1) );
2872 com[length + 1] = '\'';
2873 com[length + 2] = 0;
2875 c_rtl_tres_state
2877 hRtlTestResult,
2878 lastRes,
2879 com,
2880 createName( pMeth, "toFloat", i )
2885 c_rtl_tres_state_end(hRtlTestResult, "toFloat");
2886 // return (res);
2890 //------------------------------------------------------------------------
2891 // testing the method toDouble()
2892 //------------------------------------------------------------------------
2893 // LLA: extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toDouble(
2894 // LLA: hTestResult hRtlTestResult )
2895 // LLA: {
2896 // LLA: sal_Char methName[MAXBUFLENGTH];
2897 // LLA: sal_Char* pMeth = methName;
2898 // LLA:
2899 // LLA: c_rtl_tres_state_start(hRtlTestResult, "toDouble");
2900 // LLA: typedef struct TestCase
2901 // LLA: {
2902 // LLA: double expVal;
2903 // LLA: double expDiff;
2904 // LLA: OString* input1;
2905 // LLA: ~TestCase() {delete input1;}
2906 // LLA: } TestCase;
2907 // LLA:
2908 // LLA:
2909 // LLA: TestCase arrTestCase[] =
2910 // LLA: {
2911 // LLA: {3.0, 1e-35, new OString("3")},
2912 // LLA: {3.1, 1e-2, new OString("3.1")},
2913 // LLA: {3.1415, 1e-5, new OString("3.1415")},
2914 // LLA: {3.1415926535, 1e-11, new OString("3.1415926535")},
2915 // LLA: {3.141592653589793, 1e-15,
2916 // LLA: new OString("3.141592653589793")},
2917 // LLA: {3.1415926535897932, 1e-16,
2918 // LLA: new OString("3.1415926535897932")},
2919 // LLA: {3.14159265358979323, 1e-15,
2920 // LLA: new OString("3.14159265358979323")},
2921 // LLA: {3.141592653589793238462643, 1e-15,
2922 // LLA: new OString("3.141592653589793238462643")},
2923 // LLA: {6.5822e-16, 1e-20, new OString("6.5822e-16")},
2924 // LLA: {9.1096e-31, 1e-35, new OString("9.1096e-31")},
2925 // LLA: {2.997925e8, 10, new OString("2.997925e8")},
2926 // LLA: {6.241e18, 100, new OString("6.241e18")},
2927 // LLA: {1.7e-308, 1e-35, new OString("1.7e-308")},
2928 // LLA: {1.7e+308, 100, new OString("1.7e+308")},
2929 // LLA: {3.1, 1e-2, new OString("03.1")},
2930 // LLA: {3.1, 1e-2, new OString(" 3.1")},
2931 // LLA: {-3.1, 1e-2, new OString("-3.1")},
2932 // LLA: {3.1, 1e-2, new OString("+3.1")},
2933 // LLA: {0.0, 1e-2, new OString("-0.0")}
2934 // LLA: };
2935 // LLA:
2936 // LLA: sal_Bool res = sal_True;
2937 // LLA: sal_Int32 i;
2938 // LLA:
2939 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++ )
2940 // LLA: {
2941 // LLA: double dRes = arrTestCase[i].input1->toDouble();
2942 // LLA: double dErg = dRes - arrTestCase[i].expVal ;
2943 // LLA: double dComp = fabs( dErg );
2944 // LLA: sal_Bool lastRes = ( dComp <= arrTestCase[i].expDiff );
2945 // LLA:
2946 // LLA: char com[MAXBUFLENGTH];
2947 // LLA: com[0] = '\'';
2948 // LLA: cpynstr(com + 1, (*arrTestCase[i].input1), MAXBUFLENGTH);
2949 // LLA: int length = AStringLen( (*arrTestCase[i].input1) );
2950 // LLA: com[length + 1] = '\'';
2951 // LLA: com[length + 2] = 0;
2952 // LLA:
2953 // LLA: c_rtl_tres_state
2954 // LLA: (
2955 // LLA: hRtlTestResult,
2956 // LLA: lastRes,
2957 // LLA: com,
2958 // LLA: createName( pMeth, "toDouble", i )
2959 // LLA: );
2960 // LLA:
2961 // LLA: }
2962 // LLA:
2963 // LLA: c_rtl_tres_state_end(hRtlTestResult, "toDouble");
2964 // LLA: // return (res);
2965 // LLA: }
2967 //------------------------------------------------------------------------
2968 // testing the method toBoolean()
2969 //------------------------------------------------------------------------
2971 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toBoolean(
2972 hTestResult hRtlTestResult)
2974 sal_Char methName[MAXBUFLENGTH];
2975 sal_Char* pMeth = methName;
2977 c_rtl_tres_state_start(hRtlTestResult, "toBoolean");
2978 typedef struct TestCase
2980 sal_Char* comments;
2981 sal_Bool expVal;
2982 OString* input;
2984 } TestCase;
2986 TestCase arrTestCase[]={
2988 {"expected true", sal_True, new OString("True")},
2989 {"expected false", sal_False, new OString("False")},
2990 {"expected true", sal_True, new OString("1")}
2994 sal_Bool res = sal_True;
2995 sal_uInt32 i;
2997 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2999 sal_Bool bRes = arrTestCase[i].input->toBoolean();
3000 sal_Bool lastRes = (bRes == arrTestCase[i].expVal);
3001 c_rtl_tres_state
3003 hRtlTestResult,
3004 lastRes,
3005 arrTestCase[i].comments,
3006 createName( pMeth, "toBoolean", i )
3009 res &= lastRes;
3011 c_rtl_tres_state_end(hRtlTestResult, "toBoolean");
3012 // return ( res );
3017 //------------------------------------------------------------------------
3018 // testing the method toInt32( sal_Int16 radix = 2,8,10,16,36 )
3019 //------------------------------------------------------------------------
3020 sal_Bool test_toInt32( int num, const sal_Char** in,
3021 const sal_Int32 *expVal,sal_Int16 radix, hTestResult hRtlTestResult )
3023 sal_Bool res = sal_True;
3024 sal_Char methName[MAXBUFLENGTH];
3025 sal_Char* pMeth = methName;
3026 sal_Int32 i;
3028 for( i = 0; i < num; i++ )
3030 OString str(in[i]);
3031 sal_Int32 intRes = str.toInt32(radix);
3032 sal_Bool lastRes = (intRes == expVal[i]);
3034 char buf[MAXBUFLENGTH];
3035 buf[0] = '\'';
3036 cpynstr( buf + 1, in[i], MAXBUFLENGTH );
3037 int length = AStringLen( in[i] );
3038 buf[length + 1] = '\'';
3039 buf[length + 2] = 0;
3041 c_rtl_tres_state
3043 hRtlTestResult,
3044 lastRes,
3045 buf,
3046 createName( pMeth,"toInt32", i )
3049 res &= lastRes;
3052 return( res );
3055 sal_Bool SAL_CALL test_rtl_OString_toInt32_wrongRadix(
3056 hTestResult hRtlTestResult )
3058 ::rtl::OString str("0");
3060 sal_Int32 iRes = str.toInt32(-1);
3062 return
3064 c_rtl_tres_state
3066 hRtlTestResult,
3067 iRes == 0,
3068 "wrong radix -1",
3069 "toInt32( 0, wrong radix -1 )"
3074 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toInt32(
3075 hTestResult hRtlTestResult )
3077 sal_Int32 expValues[kBase36NumsCount];
3078 sal_Int32 i;
3080 c_rtl_tres_state_start(hRtlTestResult, "toInt32");
3081 for ( i = 0; i < kBase36NumsCount; i++ )
3082 expValues[i] = i;
3084 sal_Bool res = c_rtl_tres_state
3086 hRtlTestResult,
3087 test_toInt32( kBinaryNumsCount, kBinaryNumsStr,
3088 expValues, kRadixBinary, hRtlTestResult ),
3089 "kBinaryNumsStr",
3090 "toInt32( radix 2 )"
3092 res &= c_rtl_tres_state
3094 hRtlTestResult,
3095 test_toInt32( kInt32MaxNumsCount, kBinaryMaxNumsStr,
3096 kInt32MaxNums, kRadixBinary, hRtlTestResult ),
3097 "kBinaryMaxNumsStr",
3098 "toInt32_Boundaries( radix 2 )"
3101 res &= c_rtl_tres_state
3103 hRtlTestResult,
3104 test_toInt32( kOctolNumsCount, kOctolNumsStr,
3105 expValues, kRadixOctol, hRtlTestResult ),
3106 "kOctolNumsStr",
3107 "toInt32( radix 8 )"
3110 res &= c_rtl_tres_state
3112 hRtlTestResult,
3113 test_toInt32( kInt32MaxNumsCount, kOctolMaxNumsStr,
3114 (sal_Int32*)kInt32MaxNums, kRadixOctol, hRtlTestResult ),
3115 "kOctolMaxNumsStr",
3116 "toInt32_Boundaries( radix 8 )"
3119 res &= c_rtl_tres_state
3121 hRtlTestResult,
3122 test_toInt32( kDecimalNumsCount, kDecimalNumsStr, expValues,
3123 kRadixDecimal, hRtlTestResult ),
3124 "kDecimalNumsStr",
3125 "toInt32( radix 10 )"
3128 res &= c_rtl_tres_state
3130 hRtlTestResult,
3131 test_toInt32( kInt32MaxNumsCount, kDecimalMaxNumsStr,
3132 (sal_Int32*)kInt32MaxNums, kRadixDecimal, hRtlTestResult ),
3133 "kDecimalMaxNumsStr",
3134 "toInt32_Boundaries( radix 10 )"
3137 res &= c_rtl_tres_state
3139 hRtlTestResult,
3140 test_toInt32( kHexDecimalNumsCount, kHexDecimalNumsStr, expValues,
3141 kRadixHexdecimal, hRtlTestResult ),
3142 "kHexDecimalNumsStr",
3143 "toInt32( radix 16 )"
3146 res &= c_rtl_tres_state
3148 hRtlTestResult,
3149 test_toInt32( kInt32MaxNumsCount, kHexDecimalMaxNumsStr,
3150 (sal_Int32*)kInt32MaxNums, kRadixHexdecimal, hRtlTestResult ),
3151 "kHexDecimalMaxNumsStr",
3152 "toInt32_Boundaries( radix 16 )"
3155 res &= c_rtl_tres_state
3157 hRtlTestResult,
3158 test_toInt32( kBase36NumsCount, kBase36NumsStr, expValues,
3159 kRadixBase36, hRtlTestResult ),
3160 "kBase36NumsStr",
3161 "toInt32( radix 36 )"
3164 res &= c_rtl_tres_state
3166 hRtlTestResult,
3167 test_toInt32( kInt32MaxNumsCount, kBase36MaxNumsStr,
3168 (sal_Int32*)kInt32MaxNums, kRadixBase36, hRtlTestResult ),
3169 "kBase36MaxNumsStr",
3170 "toInt32_Boundaries( radix 36 )"
3173 const sal_Int16 nSpecCases = 5;
3174 static const sal_Char *spString[nSpecCases] =
3176 "-1",
3177 "+1",
3178 " 1",
3179 " -1",
3180 "001"
3183 sal_Int32 expSpecVal[nSpecCases] =
3192 res &= c_rtl_tres_state
3194 hRtlTestResult,
3195 test_toInt32( nSpecCases, spString, expSpecVal,
3196 kRadixDecimal, hRtlTestResult ),
3197 "special cases",
3198 "toInt32( specialcases )"
3201 res &= test_rtl_OString_toInt32_wrongRadix( hRtlTestResult );
3203 c_rtl_tres_state_end(hRtlTestResult, "toInt32");
3204 // return ( res );
3207 //------------------------------------------------------------------------
3208 // testing the method toInt64( sal_Int16 radix = 2,8,10,16,36 )
3209 //------------------------------------------------------------------------
3210 sal_Bool test_toInt64( int num, const sal_Char** in,
3211 const sal_Int64 *expVal,sal_Int16 radix, hTestResult hRtlTestResult )
3213 sal_Bool res = sal_True;
3214 sal_Char methName[MAXBUFLENGTH];
3215 sal_Char* pMeth = methName;
3216 sal_Int32 i;
3218 for( i = 0; i < num; i++ )
3220 OString str( in[i] );
3221 sal_Int64 intRes = str.toInt64( radix );
3222 sal_Bool lastRes = ( intRes == expVal[i] );
3224 char buf[MAXBUFLENGTH];
3225 buf[0] = '\'';
3226 cpynstr( buf + 1, in[i], MAXBUFLENGTH );
3227 int length = AStringLen(in[i]);
3228 buf[length + 1] = '\'';
3229 buf[length + 2] = 0;
3231 c_rtl_tres_state
3233 hRtlTestResult,
3234 lastRes,
3235 buf,
3236 createName( pMeth, "toInt64", i )
3239 res &= lastRes;
3241 return (res);
3244 sal_Bool SAL_CALL test_rtl_OString_toInt64_wrongRadix(
3245 hTestResult hRtlTestResult )
3247 ::rtl::OString str("0");
3249 sal_Int64 iRes = str.toInt64(-1);
3251 return (
3253 c_rtl_tres_state
3254 ( hRtlTestResult,
3255 iRes == 0,
3256 "wrong radix -1",
3257 "toInt64( wrong radix -1)"
3262 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_toInt64(
3263 hTestResult hRtlTestResult )
3265 sal_Int64 expValues[kBase36NumsCount];
3266 sal_Int32 i;
3268 c_rtl_tres_state_start(hRtlTestResult, "toInt64");
3269 for (i = 0; i < kBase36NumsCount; expValues[i] = i, i++);
3271 sal_Bool res = c_rtl_tres_state
3273 hRtlTestResult,
3274 test_toInt64( kBinaryNumsCount, kBinaryNumsStr, expValues,
3275 kRadixBinary, hRtlTestResult ),
3276 "kBinaryNumsStr",
3277 "toInt64( radix 2 )"
3280 res &= c_rtl_tres_state
3282 hRtlTestResult,
3283 test_toInt64( kInt32MaxNumsCount, kBinaryMaxNumsStr,
3284 (sal_Int64*)kInt64MaxNums, kRadixBinary, hRtlTestResult ),
3285 "kBinaryMaxNumsStr",
3286 "toInt64_Boundaries( radix 2 )"
3289 res &= c_rtl_tres_state
3291 hRtlTestResult,
3292 test_toInt64( kOctolNumsCount, kOctolNumsStr, expValues,
3293 kRadixOctol, hRtlTestResult ),
3294 "kOctolNumsStr",
3295 "toInt64( radix 8 )"
3298 res &= c_rtl_tres_state
3300 hRtlTestResult,
3301 test_toInt64( kInt32MaxNumsCount, kOctolMaxNumsStr,
3302 (sal_Int64*)kInt64MaxNums, kRadixOctol, hRtlTestResult ),
3303 "kOctolMaxNumsStr",
3304 "toInt64_Boundaries( radix 8 )"
3307 res &= c_rtl_tres_state
3309 hRtlTestResult,
3310 test_toInt64( kDecimalNumsCount, kDecimalNumsStr, expValues,
3311 kRadixDecimal, hRtlTestResult ),
3312 "kDecimalNumsStr",
3313 "toInt64( radix 10 )"
3316 res &= c_rtl_tres_state
3318 hRtlTestResult,
3319 test_toInt64( kInt32MaxNumsCount, kDecimalMaxNumsStr,
3320 (sal_Int64*)kInt64MaxNums, kRadixDecimal, hRtlTestResult ),
3321 "kDecimalMaxNumsStr",
3322 "toInt64_Boundaries( radix 10 )"
3325 res &= c_rtl_tres_state
3327 hRtlTestResult,
3328 test_toInt64( kHexDecimalNumsCount, kHexDecimalNumsStr, expValues,
3329 kRadixHexdecimal, hRtlTestResult ),
3330 "kHexDecimalNumsStr",
3331 "toInt64( radix 16 )"
3334 res &= c_rtl_tres_state
3336 hRtlTestResult,
3337 test_toInt64( kInt32MaxNumsCount, kHexDecimalMaxNumsStr,
3338 (sal_Int64*)kInt64MaxNums, kRadixHexdecimal, hRtlTestResult ),
3339 "kHexDecimalMaxNumsStr",
3340 "toInt64_Boundaries( radix 16 )"
3343 res &= c_rtl_tres_state
3345 hRtlTestResult,
3346 test_toInt64( kBase36NumsCount, kBase36NumsStr, expValues,
3347 kRadixBase36, hRtlTestResult ),
3348 "kBase36NumsStr",
3349 "toInt64( radix 36 )"
3352 res &= c_rtl_tres_state
3354 hRtlTestResult,
3355 test_toInt64( kInt32MaxNumsCount, kBase36MaxNumsStr,
3356 (sal_Int64*)kInt64MaxNums, kRadixBase36, hRtlTestResult ),
3357 "kBase36MaxNumsStr",
3358 "toInt64_Boundaries( radix 36 )"
3363 const sal_Int16 nSpecCases = 5;
3364 static const sal_Char *spString[nSpecCases] =
3366 "-1",
3367 "+1",
3368 " 1",
3369 " -1",
3370 "001"
3373 sal_Int64 expSpecVal[nSpecCases] =
3382 res &= c_rtl_tres_state
3384 hRtlTestResult,
3385 test_toInt64( nSpecCases, spString, expSpecVal,
3386 kRadixDecimal, hRtlTestResult ),
3387 "special cases",
3388 "toInt64( specialcases )"
3391 res &= test_rtl_OString_toInt64_wrongRadix( hRtlTestResult );
3393 c_rtl_tres_state_end(hRtlTestResult, "toInt64");
3394 // return (res);
3397 //------------------------------------------------------------------------
3398 // testing the method replace( sal_Char oldChar, sal_Char newChar )
3399 //------------------------------------------------------------------------
3400 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_replace(
3401 hTestResult hRtlTestResult)
3403 sal_Char methName[MAXBUFLENGTH];
3404 sal_Char* pMeth = methName;
3406 c_rtl_tres_state_start(hRtlTestResult, "replace");
3407 typedef struct TestCase
3409 sal_Char* comments;
3410 OString* expVal;
3411 OString* input;
3412 sal_Char oldChar;
3413 sal_Char newChar;
3415 ~TestCase() { delete input; delete expVal;}
3416 } TestCase;
3418 TestCase arrTestCase[]={
3420 {"string differs", new OString(kTestStr18),
3421 new OString(kTestStr4),'S','s'},
3422 {"string differs", new OString(kTestStr19),
3423 new OString(kTestStr17),(sal_Char)' ',(sal_Char)'-'},
3424 {"same string, no replace ", new OString(kTestStr22),
3425 new OString(kTestStr22),'*','8'}
3429 sal_Bool res = sal_True;
3430 sal_uInt32 i;
3432 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3434 ::rtl::OString aStr1;
3435 aStr1= arrTestCase[i].input->replace(arrTestCase[i].oldChar,
3436 arrTestCase[i].newChar);
3438 res &= c_rtl_tres_state
3440 hRtlTestResult,
3441 (arrTestCase[i].expVal->compareTo(aStr1) == 0),
3442 arrTestCase[i].comments,
3443 createName( pMeth, "replace", i )
3447 c_rtl_tres_state_end(hRtlTestResult, "replace");
3448 // return ( res );
3453 //------------------------------------------------------------------------
3454 // testing the method replaceAt( sal_Int32 index, sal_Int32 count,
3455 // const OString& newStr )
3456 //------------------------------------------------------------------------
3457 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_replaceAt(
3458 hTestResult hRtlTestResult)
3460 sal_Char methName[MAXBUFLENGTH];
3461 sal_Char* pMeth = methName;
3463 c_rtl_tres_state_start(hRtlTestResult, "replaceAt");
3464 typedef struct TestCase
3466 sal_Char* comments;
3467 OString* expVal;
3468 OString* input;
3469 OString* newStr;
3470 sal_Int32 index;
3471 sal_Int32 count;
3473 ~TestCase() { delete input; delete expVal; delete newStr;}
3474 } TestCase;
3476 TestCase arrTestCase[]=
3479 { "string differs", new OString(kTestStr2), new OString(kTestStr22),
3480 new OString(kTestStr2), 0, kTestStr22Len },
3482 { "larger index", new OString(kTestStr1), new OString(kTestStr7),
3483 new OString(kTestStr8), 64, kTestStr8Len },
3485 { "larger count", new OString(kTestStr2), new OString(kTestStr22),
3486 new OString(kTestStr2),0, 64 },
3488 { "navigate index", new OString(kTestStr2), new OString(kTestStr22),
3489 new OString(kTestStr2), -64, 64 },
3491 { "null string", new OString(""),
3492 new OString(kTestStr14),new OString(""), 0, kTestStr14Len }
3495 sal_Bool res = sal_True;
3496 sal_uInt32 i;
3498 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3500 ::rtl::OString aStr1;
3501 aStr1= arrTestCase[i].input->replaceAt( arrTestCase[i].index,
3502 arrTestCase[i].count, *arrTestCase[i].newStr );
3504 sal_Bool lastRes = ( arrTestCase[i].expVal->compareTo(aStr1) == 0 );
3506 c_rtl_tres_state
3508 hRtlTestResult,
3509 lastRes,
3510 arrTestCase[i].comments,
3511 createName( pMeth, "replaceAt", i )
3514 res &= lastRes;
3516 c_rtl_tres_state_end(hRtlTestResult, "replaceAt");
3517 // return ( res );
3520 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString( hTestResult hRtlTestResult )
3523 c_rtl_tres_state_start(hRtlTestResult, "rtl_OString" );
3525 test_rtl_OString_ctors( hRtlTestResult );
3526 test_rtl_OString_getLength( hRtlTestResult );
3527 test_rtl_OString_equals( hRtlTestResult );
3528 test_rtl_OString_equalsIgnoreAsciiCase( hRtlTestResult );
3529 test_rtl_OString_compareTo( hRtlTestResult );
3530 test_rtl_OString_op_cmp( hRtlTestResult );
3531 test_rtl_OString_op_neq( hRtlTestResult );
3532 test_rtl_OString_op_g( hRtlTestResult );
3533 test_rtl_OString_op_l( hRtlTestResult );
3534 test_rtl_OString_op_ge( hRtlTestResult );
3535 test_rtl_OString_op_le( hRtlTestResult );
3536 test_rtl_OString_op_eq( hRtlTestResult );
3537 test_rtl_OString_op_plus( hRtlTestResult );
3538 test_rtl_OString_op_peq( hRtlTestResult );
3539 test_rtl_OString_op_cscs( hRtlTestResult );
3540 test_rtl_OString_getStr( hRtlTestResult );
3541 test_rtl_OString_copy( hRtlTestResult );
3542 test_rtl_OString_concat( hRtlTestResult );
3543 test_rtl_OString_toAsciiLowerCase( hRtlTestResult );
3544 test_rtl_OString_toAsciiUpperCase( hRtlTestResult );
3545 test_rtl_OString_trim( hRtlTestResult );
3546 test_rtl_OString_valueOf( hRtlTestResult );
3547 test_rtl_OString_toChar( hRtlTestResult );
3548 test_rtl_OString_toFloat( hRtlTestResult );
3549 // LLA: test_rtl_OString_toDouble( hRtlTestResult );
3550 test_rtl_OString_toBoolean( hRtlTestResult );
3551 test_rtl_OString_toInt32( hRtlTestResult );
3552 test_rtl_OString_toInt64( hRtlTestResult );
3553 test_rtl_OString_replace( hRtlTestResult );
3554 test_rtl_OString_replaceAt( hRtlTestResult );
3556 c_rtl_tres_state_end(hRtlTestResult, "rtl_OString");
3560 // -----------------------------------------------------------------------------
3561 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
3563 if (_pFunc)
3565 (_pFunc)(&test_rtl_OString, "");
3567 //# (_pFunc)(&test_rtl_OString_ctors, "");
3568 //# (_pFunc)(&test_rtl_OString_getLength, "");
3569 //# (_pFunc)(&test_rtl_OString_equals, "");
3570 //# (_pFunc)(&test_rtl_OString_equalsIgnoreAsciiCase, "");
3571 //# (_pFunc)(&test_rtl_OString_compareTo, "");
3572 //# (_pFunc)(&test_rtl_OString_op_cmp, "");
3573 //# (_pFunc)(&test_rtl_OString_op_neq, "");
3574 //# (_pFunc)(&test_rtl_OString_op_g, "");
3575 //# (_pFunc)(&test_rtl_OString_op_l, "");
3576 //# (_pFunc)(&test_rtl_OString_op_ge, "");
3577 //# (_pFunc)(&test_rtl_OString_op_le, "");
3578 //# (_pFunc)(&test_rtl_OString_op_eq, "");
3579 //# (_pFunc)(&test_rtl_OString_op_plus, "");
3580 //# (_pFunc)(&test_rtl_OString_op_peq, "");
3581 //# (_pFunc)(&test_rtl_OString_op_cscs, "");
3582 //# (_pFunc)(&test_rtl_OString_getStr, "");
3583 //# (_pFunc)(&test_rtl_OString_copy, "");
3584 //# (_pFunc)(&test_rtl_OString_concat, "");
3585 //# (_pFunc)(&test_rtl_OString_toAsciiLowerCase, "");
3586 //# (_pFunc)(&test_rtl_OString_toAsciiUpperCase, "");
3587 //# (_pFunc)(&test_rtl_OString_trim, "");
3588 //# (_pFunc)(&test_rtl_OString_valueOf, "");
3589 //# (_pFunc)(&test_rtl_OString_toChar, "");
3590 //# (_pFunc)(&test_rtl_OString_toFloat, "");
3591 //# (_pFunc)(&test_rtl_OString_toDouble, "");
3592 //# (_pFunc)(&test_rtl_OString_toBoolean, "");
3593 //# (_pFunc)(&test_rtl_OString_toInt32, "");
3594 //# (_pFunc)(&test_rtl_OString_toInt64, "");
3595 //# (_pFunc)(&test_rtl_OString_replace, "");
3596 //# (_pFunc)(&test_rtl_OString_replaceAt, "");
3601 D:\local\644\SRX644\sal\qa\rtl_OString.cxx(3559) : error C2664:
3602 'unsigned char (void (__cdecl *)(void *),const char *)'
3603 : cannot convert parameter 1 from
3604 'unsigned char (__cdecl *)(void *)' to 'void (__cdecl *)(void *)'
3606 This conversion requires a reinterpret_cast, a C-style cast or function-
3607 style cast