update dev300-m58
[ooovba.git] / sal / qa / rtl_strings / rtl_OUString.cxx
blob1bbda974aeeadb7dc621ef9ca603ac46944f2535
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_OUString.cxx,v $
10 * $Revision: 1.12 $
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 <sal/types.h>
35 //# #ifndef _RTL_TRES_H_
36 //# #include <rtl/tres.h>
37 //# #endif
38 #include <testshl/tresstatewrapper.hxx>
39 #include "stringhelper.hxx"
40 #include <rtl/string.hxx>
41 #include <rtl/ustring.h>
42 #include <rtl/ustring.hxx>
44 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
46 #include <osl/thread.h>
47 #include <rtl_String_Const.h>
48 #include <rtl_String_Utils.hxx>
52 using namespace rtl;
54 //------------------------------------------------------------------------
55 // test classes
56 //------------------------------------------------------------------------
57 const int MAXBUFLENGTH = 255;
58 //------------------------------------------------------------------------
59 // helper functions
60 //------------------------------------------------------------------------
61 static void unused()
63 // NEVER CALL SUCH FUNCTION!!!
64 (void)input1StrLastDefault;
65 (void)input1StrLastNormal;
66 unused();
69 //------------------------------------------------------------------------
70 // testing constructors
71 //------------------------------------------------------------------------
72 static sal_Bool test_rtl_OUString_ctor_001( hTestResult hRtlTestResult )
75 ::rtl::OUString aUStr;
76 rtl_uString * pData = aUStr.pData;
78 return
80 c_rtl_tres_state
82 hRtlTestResult,
83 pData->length == 0 &&
84 ! *pData->buffer,
85 "New OUString containing no characters",
86 "ctor_001"
91 //------------------------------------------------------------------------
93 static sal_Bool SAL_CALL test_rtl_OUString_ctor_002(
94 hTestResult hRtlTestResult )
96 ::rtl::OUString aUStr( kTestStr1,
97 kTestStr1Len,
98 kEncodingRTLTextUSASCII,
99 kConvertFlagsOStringToOUString
102 return
104 c_rtl_tres_state
106 hRtlTestResult,
107 aUStr == aUStr1,
108 "OUString from an ascii string",
109 "ctor_002"
113 //------------------------------------------------------------------------
115 static sal_Bool SAL_CALL test_rtl_OUString_ctor_003(
116 hTestResult hRtlTestResult )
118 rtl_uString *rtlUStr =NULL ;
119 rtl_uString_newFromAscii( &rtlUStr, kTestStr1 );
120 ::rtl::OUString aUStr( rtlUStr );
122 return
124 c_rtl_tres_state
126 hRtlTestResult,
127 aUStr == aUStr1,
128 "New OUString from a rtl_uString",
129 "ctor_003"
134 //------------------------------------------------------------------------
136 static sal_Bool SAL_CALL test_rtl_OUString_ctor_004(
137 hTestResult hRtlTestResult)
139 ::rtl::OUString aUStr( aUStr1 );
141 return
143 c_rtl_tres_state
145 hRtlTestResult,
146 aUStr == aUStr1,
147 "New OUString from unicode string",
148 "ctor_004"
152 //------------------------------------------------------------------------
154 static sal_Bool test_rtl_OUString_ctor_005( hTestResult hRtlTestResult )
156 ::rtl::OUString aUStr( aUStr2, kTestStr1Len );
158 return
160 c_rtl_tres_state
162 hRtlTestResult,
163 aUStr == aUStr1,
164 "New OUString from the first n characters of unicode string",
165 "ctor_004"
172 //------------------------------------------------------------------------
174 static sal_Bool test_rtl_OUString_ctor_006( hTestResult hRtlTestResult )
176 ::rtl::OUString aUStrtmp( aUStr1 );
177 ::rtl::OUString aUStr( aUStrtmp );
179 return
181 c_rtl_tres_state
183 hRtlTestResult,
184 aUStr==aUStrtmp,
185 "New OUString from another OUString",
186 "ctor_006"
191 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_ctors(
192 hTestResult hRtlTestResult )
194 c_rtl_tres_state_start( hRtlTestResult, "ctors");
195 sal_Bool DCState = test_ini_uString();
196 (void)DCState;
197 sal_Bool bTSState = test_rtl_OUString_ctor_001( hRtlTestResult );
198 bTSState &= test_rtl_OUString_ctor_002( hRtlTestResult);
199 bTSState &= test_rtl_OUString_ctor_003( hRtlTestResult);
200 bTSState &= test_rtl_OUString_ctor_004( hRtlTestResult);
201 bTSState &= test_rtl_OUString_ctor_005( hRtlTestResult);
202 bTSState &= test_rtl_OUString_ctor_006( hRtlTestResult);
203 c_rtl_tres_state_end( hRtlTestResult, "ctors");
204 // return( bTSState );
209 //------------------------------------------------------------------------
210 // testing the method getLength
211 //------------------------------------------------------------------------
213 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_getLength(
214 hTestResult hRtlTestResult)
216 c_rtl_tres_state_start( hRtlTestResult, "getLength");
217 sal_Char methName[MAXBUFLENGTH];
218 sal_Char* pMeth = methName;
220 typedef struct TestCase
222 sal_Char* comments;
223 sal_Int32 expVal;
224 OUString* input;
225 ~TestCase() { delete input;}
226 } TestCase;
228 TestCase arrTestCase[]={
230 {"length of ascii string", kTestStr1Len,
231 new OUString( kTestStr1,
232 kTestStr1Len,
233 kEncodingRTLTextUSASCII,
234 kConvertFlagsOStringToOUString)},
235 {"length of ascci string of size 1", 1,
236 new OUString( "1",
238 kEncodingRTLTextUSASCII,
239 kConvertFlagsOStringToOUString)},
240 {"length of empty string (default constructor)", 0, new OUString()},
241 {"length of empty string (empty ascii string arg)",0,
242 new OUString( "",
244 kEncodingRTLTextUSASCII,
245 kConvertFlagsOStringToOUString)},
246 {"length of empty string (string arg = '\\0')", 0,
247 new OUString( "\0",
249 kEncodingRTLTextUSASCII,
250 kConvertFlagsOStringToOUString)}
254 sal_Bool res = sal_True;
255 sal_uInt32 i;
257 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
259 sal_Int32 length = arrTestCase[i].input->getLength();
260 sal_Bool lastRes = (length == arrTestCase[i].expVal);
261 c_rtl_tres_state
263 hRtlTestResult,
264 lastRes,
265 arrTestCase[i].comments,
266 createName( pMeth, "getLength", i )
269 res &= lastRes;
271 c_rtl_tres_state_end( hRtlTestResult, "getLength");
272 // return ( res );
275 //------------------------------------------------------------------------
276 // testing the method equals( const OString & aStr )
277 //------------------------------------------------------------------------
278 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_equals(
279 hTestResult hRtlTestResult )
281 c_rtl_tres_state_start( hRtlTestResult, "equals");
282 sal_Char methName[MAXBUFLENGTH];
283 sal_Char* pMeth = methName;
285 typedef struct TestCase
287 sal_Char* comments;
288 sal_Bool expVal;
289 OUString* input1;
290 OUString* input2;
291 ~TestCase() { delete input1;delete input2;}
292 } TestCase;
294 TestCase arrTestCase[]={
296 {"same size", sal_True, new OUString(aUStr1), new OUString(aUStr1)},
297 {"different size", sal_False, new OUString(aUStr1),
298 new OUString(aUStr2)
300 {"same size, no case match", sal_False, new OUString(aUStr1),
301 new OUString(aUStr3)
303 {"two empty strings(def. constructor)", sal_True, new OUString(),
304 new OUString()
306 {"empty(def.constructor) and non empty", sal_False, new OUString(),
307 new OUString(aUStr2)
309 {"non empty and empty(def. constructor)", sal_False,
310 new OUString(aUStr1),
311 new OUString()
313 {"two empty strings(string arg = '\\0')", sal_True,
314 new OUString( "",
316 kEncodingRTLTextUSASCII,
317 kConvertFlagsOStringToOUString),
318 new OUString( "",
320 kEncodingRTLTextUSASCII,
321 kConvertFlagsOStringToOUString)
323 {"empty(string arg = '\\0') and non empty", sal_False,
324 new OUString( "",
326 kEncodingRTLTextUSASCII,
327 kConvertFlagsOStringToOUString),
328 new OUString(aUStr2)
330 {"non empty and empty(string arg = '\\0')", sal_False,
331 new OUString(aUStr1),
332 new OUString( "",
334 kEncodingRTLTextUSASCII,
335 kConvertFlagsOStringToOUString)
339 sal_Bool res = sal_True;
340 sal_uInt32 i;
342 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
344 sal_Bool lastRes =
345 ( arrTestCase[i].input1->equals(*(arrTestCase[i].input2)) ==
346 arrTestCase[i].expVal );
348 c_rtl_tres_state
350 hRtlTestResult,
351 lastRes,
352 arrTestCase[i].comments,
353 createName( pMeth, "equals", i )
356 res &= lastRes;
358 c_rtl_tres_state_end( hRtlTestResult, "equals");
359 // return (res);
362 //------------------------------------------------------------------------
363 // testing the method equalsIgnoreAsciiCase( const OString & aStr )
364 //------------------------------------------------------------------------
366 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_equalsIgnoreAsciiCase(
367 hTestResult hRtlTestResult )
369 c_rtl_tres_state_start( hRtlTestResult, "equalsIgnoreAsciiCase");
370 sal_Char methName[MAXBUFLENGTH];
371 sal_Char* pMeth = methName;
373 typedef struct TestCase
375 sal_Char* comments;
376 sal_Bool expVal;
377 OUString* input1;
378 OUString* input2;
379 ~TestCase() { delete input1;delete input2;}
380 } TestCase;
382 TestCase arrTestCase[]={
383 {"same strings but different cases",sal_True,new OUString(aUStr4),
384 new OUString(aUStr5)
386 {"same strings",sal_True,new OUString(aUStr4),
387 new OUString(aUStr4)},
388 {"with equal beginning",sal_False,new OUString(aUStr2),
389 new OUString(aUStr4)
391 {"empty(def.constructor) and non empty",sal_False,new OUString(),
392 new OUString(aUStr5)
394 {"non empty and empty(def.constructor)",sal_False,
395 new OUString(aUStr4),
396 new OUString()
398 {"two empty strings(def.constructor)",sal_True,new OUString(),
399 new OUString()
401 {"different strings with equal length",sal_False,
402 new OUString(aUStr10),
403 new OUString(aUStr11)
407 sal_Bool res = sal_True;
408 sal_uInt32 i;
410 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
412 sal_Bool lastRes =
413 (arrTestCase[i].input1->equalsIgnoreAsciiCase(*arrTestCase[i].input2) ==
414 arrTestCase[i].expVal);
416 c_rtl_tres_state
418 hRtlTestResult,
419 lastRes,
420 arrTestCase[i].comments,
421 createName( pMeth, "equalsIgnoreAsciiCase", i )
424 res &= lastRes;
426 c_rtl_tres_state_end( hRtlTestResult, "equalsIgnoreAsciiCase");
427 // return (res);
431 static sal_Bool SAL_CALL test_rtl_OUString_compareTo_001(
432 hTestResult hRtlTestResult )
434 sal_Char methName[MAXBUFLENGTH];
435 sal_Char* pMeth = methName;
437 typedef struct TestCase
439 sal_Char* comments;
440 sal_Int32 expVal;
441 OUString* input1;
442 OUString* input2;
443 ~TestCase() { delete input1;delete input2;}
444 } TestCase;
446 TestCase arrTestCase[]={
448 {"simple compare, str1 to str5",-1,new OUString(aUStr1),
449 new OUString(aUStr5)
451 {"simple compare, str2 to str5",-1,new OUString(aUStr2),
452 new OUString(aUStr5)
454 {"simple compare, str1 to str9",-1,new OUString(aUStr1),
455 new OUString(aUStr9)
457 {"simple compare, str1 to str2",-1,new OUString(aUStr1),
458 new OUString(aUStr2)
460 {"simple compare, str4 to str5",-1,new OUString(aUStr4),
461 new OUString(aUStr5)
463 {"simple compare, str1 to str3",-1,new OUString(aUStr1),
464 new OUString(aUStr3)
466 {"simple compare, str5 to str1",+1,new OUString(aUStr5),
467 new OUString(aUStr1)
469 {"simple compare, str2 to str1",+1,new OUString(aUStr2),
470 new OUString(aUStr1)
472 {"simple compare, str9 to str5",+1,new OUString(aUStr9),
473 new OUString(aUStr5)
475 {"simple compare, str5 to str4",+1,new OUString(aUStr5),
476 new OUString(aUStr4)
478 {"simple compare, str1 to str1",0,new OUString(aUStr1),
479 new OUString(aUStr1)
481 {"simple compare, nullString to nullString",0,new OUString(),
482 new OUString()
484 {"simple compare, nullString to str2",-1,new OUString(),
485 new OUString(aUStr2)
487 {"simple compare, str1 to nullString",+1,new OUString(aUStr1),
488 new OUString()
492 sal_Bool res = sal_True;
493 sal_uInt32 i;
495 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
497 sal_Int32 cmpRes = arrTestCase[i].input1->compareTo
498 (*arrTestCase[i].input2);
499 cmpRes = ( cmpRes == 0 ) ? 0 : ( cmpRes > 0 ) ? +1 : -1 ;
500 sal_Bool lastRes = ( cmpRes == arrTestCase[i].expVal);
503 c_rtl_tres_state
505 hRtlTestResult,
506 lastRes,
507 arrTestCase[i].comments,
508 createName( pMeth, "compareTo_001(const OString&)", i )
511 res &= lastRes;
514 return (res);
518 //------------------------------------------------------------------------
519 // testing the method compareTo( const OString & rObj, sal_Int32 length )
520 //------------------------------------------------------------------------
521 static sal_Bool SAL_CALL test_rtl_OUString_compareTo_002(
522 hTestResult hRtlTestResult )
524 sal_Char methName[MAXBUFLENGTH];
525 sal_Char* pMeth = methName;
527 typedef struct TestCase
529 sal_Char* comments;
530 sal_Int32 expVal;
531 sal_Int32 maxLength;
532 OUString* input1;
533 OUString* input2;
534 ~TestCase() { delete input1;delete input2;}
535 } TestCase;
537 TestCase arrTestCase[] =
539 {"compare with maxlength, str1 to str9, 16",-1,16,
540 new OUString(aUStr1), new OUString(aUStr9)},
541 {"compare with maxlength, str2 to str9, 32",-1,32,
542 new OUString(aUStr2), new OUString(aUStr9)},
543 {"compare with maxlength, str9 to str4, 16",+1,16,
544 new OUString(aUStr9), new OUString(aUStr4)},
545 {"compare with maxlength, str9 to str22, 32",+1,32,
546 new OUString(aUStr9), new OUString(aUStr22)},
547 {"compare with maxlength, str9 to str5, 16",0,16,
548 new OUString(aUStr9), new OUString(aUStr5)},
549 {"compare with maxlength, str9 to str9, 32",0,32,
550 new OUString(aUStr9), new OUString(aUStr9)},
551 {"compare with maxlength, str1 to str2, 32",-1,32,
552 new OUString(aUStr1), new OUString(aUStr2)},
553 {"compare with maxlength, str1 to str2, 32",-1,32,
554 new OUString(aUStr1), new OUString(aUStr2)},
555 {"compare with maxlength, str1 to str2", 0,-1,
556 new OUString(aUStr1), new OUString(aUStr2)}
559 sal_Bool res = sal_True;
560 sal_uInt32 i;
562 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
564 sal_Int32 cmpRes = arrTestCase[i].input1->compareTo
565 (*arrTestCase[i].input2, arrTestCase[i].maxLength);
566 cmpRes = (cmpRes == 0) ? 0 : (cmpRes > 0) ? +1 : -1 ;
567 sal_Bool lastRes = (cmpRes == arrTestCase[i].expVal);
569 c_rtl_tres_state
571 hRtlTestResult,
572 lastRes,
573 arrTestCase[i].comments,
574 createName( pMeth, "compareTo_002(const OString&, sal_Int32)", i )
577 res &= lastRes;
580 return (res);
583 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_compareTo(
584 hTestResult hRtlTestResult )
586 c_rtl_tres_state_start( hRtlTestResult, "compareTo");
587 sal_Bool res = test_rtl_OUString_compareTo_001(hRtlTestResult);
588 res &= test_rtl_OUString_compareTo_002(hRtlTestResult);
589 c_rtl_tres_state_end( hRtlTestResult, "compareTo");
590 // return (res);
593 //------------------------------------------------------------------------
594 // testing the method match( const OUString & str, sal_Int32 fromIndex = 0 )
595 //------------------------------------------------------------------------
596 static sal_Bool SAL_CALL test_rtl_OUString_match_001(
597 hTestResult hRtlTestResult)
600 sal_Char methName[MAXBUFLENGTH];
601 sal_Char* pMeth = methName;
603 typedef struct TestCase
605 sal_Char* comments;
606 sal_Bool expVal;
607 OUString* input1;
608 OUString* input2;
609 ~TestCase() { delete input1;delete input2;}
610 } TestCase;
612 TestCase arrTestCase[]={
614 {"aUStr2 and aUStr1", sal_True, new OUString(aUStr2),
615 new OUString(aUStr1)},
616 {"aUStr1 and aUStr2", sal_False, new OUString(aUStr1),
617 new OUString(aUStr2)},
618 {"aUStr5 and aUStr6", sal_False, new OUString(aUStr5),
619 new OUString(aUStr6)},
620 {"null and aUStr1", sal_False, new OUString( "",
622 kEncodingRTLTextUSASCII,
623 kConvertFlagsOStringToOUString),
624 new OUString(aUStr1)}
628 sal_Bool res = sal_True;
629 sal_uInt32 i;
631 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
633 sal_Bool lastRes = ( arrTestCase[i].input1->match(
634 *(arrTestCase[i].input2)) == arrTestCase[i].expVal );
636 c_rtl_tres_state
638 hRtlTestResult,
639 lastRes,
640 arrTestCase[i].comments,
641 createName( pMeth, "match(const OUString & str)", i )
644 res &= lastRes;
646 return (res);
649 static sal_Bool SAL_CALL test_rtl_OUString_match_002(
650 hTestResult hRtlTestResult )
653 sal_Char methName[MAXBUFLENGTH];
654 sal_Char* pMeth = methName;
656 typedef struct TestCase
658 sal_Char* comments;
659 sal_Bool expVal;
660 sal_Int32 fromIndex;
661 OUString* input1;
662 OUString* input2;
663 ~TestCase() { delete input1;delete input2;}
664 } TestCase;
666 TestCase arrTestCase[]={
668 {"aUStr2 from 17 and aUStr6", sal_True, 17,
669 new OUString(aUStr2),new OUString(aUStr6)},
670 {"aUStr2 from 5 and aUStr6", sal_False, 5,
671 new OUString(aUStr2),new OUString(aUStr6)},
672 {"aUStr2 from 0 and aUStr1", sal_True, 0,
673 new OUString(aUStr2),new OUString(aUStr1)},
674 {"aUStr1 from 16 and null", sal_True, 16,
675 new OUString(aUStr1),
676 new OUString( "",
678 kEncodingRTLTextUSASCII,
679 kConvertFlagsOStringToOUString
682 {"aUStr1 from 5 and null", sal_True, 5,
683 new OUString(aUStr1),
684 new OUString( "",
686 kEncodingRTLTextUSASCII,
687 kConvertFlagsOStringToOUString
690 {"aUStr2 from -1 and aUStr1", sal_False, -1,
691 new OUString(aUStr2),new OUString(aUStr1)},
692 {"aUStr5 from 2 and aUStr4", sal_False, 2,
693 new OUString(aUStr5),new OUString(aUStr4)},
694 {"aUStr2 from 18 and aUStr1", sal_False, 18,
695 new OUString(aUStr2),new OUString(aUStr1)}
698 sal_Bool res = sal_True;
699 sal_uInt32 i;
701 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
703 sal_Bool lastRes = ( arrTestCase[i].input1->match
704 (*(arrTestCase[i].input2),arrTestCase[i].fromIndex) ==
705 arrTestCase[i].expVal );
707 c_rtl_tres_state
709 hRtlTestResult,
710 lastRes,
711 arrTestCase[i].comments,
712 createName( pMeth,
713 "match(const OUString & str,sal_Int32 fromIndex = 0)", i )
717 res &= lastRes;
719 return (res);
722 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_match(
723 hTestResult hRtlTestResult )
725 c_rtl_tres_state_start( hRtlTestResult, "match");
726 sal_Bool res = test_rtl_OUString_match_001(hRtlTestResult);
727 res &= test_rtl_OUString_match_002(hRtlTestResult);
728 c_rtl_tres_state_end( hRtlTestResult, "match");
729 // return (res);
732 //------------------------------------------------------------------------
733 // testing the operator +=
734 //------------------------------------------------------------------------
735 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_op_eq(
736 hTestResult hRtlTestResult)
738 c_rtl_tres_state_start( hRtlTestResult, "eq");
739 sal_Char methName[MAXBUFLENGTH];
740 sal_Char* pMeth = methName;
742 typedef struct TestCase
744 sal_Char* comments;
745 OUString* input1;
746 OUString* input2;
747 ~TestCase() { delete input1; delete input2;}
748 } TestCase;
750 TestCase arrTestCase[]={
751 {"null and Ustr1", new OUString, new OUString(aUStr1)},
752 {"Ustr2 and Ustr1", new OUString(aUStr2),
753 new OUString(aUStr1)},
754 {""" and Ustr1 from bit charactor buffer",
755 new OUString(aUStr1),
756 new OUString( "",
758 kEncodingRTLTextUSASCII,
759 kConvertFlagsOStringToOUString
761 {"Ustr1 and Ustr2 from value and length",
762 new OUString( aUStr2, kTestStr2Len ),
763 new OUString(aUStr1)}
767 sal_Bool res = sal_True;
768 sal_uInt32 i;
770 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
772 *(arrTestCase[i].input1) = *(arrTestCase[i].input2);
773 sal_Bool lastRes = (*(arrTestCase[i].input1) ==
774 *(arrTestCase[i].input2));
775 c_rtl_tres_state
777 hRtlTestResult,
778 lastRes,
779 arrTestCase[i].comments,
780 createName( pMeth, "op_eq", i )
783 res &= lastRes;
785 c_rtl_tres_state_end( hRtlTestResult, "eq");
786 // return ( res );
789 //------------------------------------------------------------------------
790 // testing the operator +=
791 //------------------------------------------------------------------------
792 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_op_peq(
793 hTestResult hRtlTestResult)
795 c_rtl_tres_state_start( hRtlTestResult, "peq");
796 sal_Char methName[MAXBUFLENGTH];
797 sal_Char* pMeth = methName;
799 typedef struct TestCase
801 sal_Char* comments;
802 OUString* expVal;
803 OUString* input1;
804 OUString* input2;
805 ~TestCase() { delete input1; delete input2;}
806 } TestCase;
808 TestCase arrTestCase[]={
809 {" ' '= ''+='' ", new OUString( "",
811 kEncodingRTLTextUSASCII,
812 kConvertFlagsOStringToOUString
814 new OUString( "",
816 kEncodingRTLTextUSASCII,
817 kConvertFlagsOStringToOUString
819 new OUString( "",
821 kEncodingRTLTextUSASCII,
822 kConvertFlagsOStringToOUString
824 {"Ustr1= null += Ustr1", new OUString(aUStr1),
825 new OUString(), new OUString(aUStr1)},
826 {"Ustr1= '' += Ustr1", new OUString(aUStr1),
827 /*new OUString( "",
829 kEncodingRTLTextUSASCII,
830 kConvertFlagsOStringToOUString
832 new OUString(),
833 new OUString(aUStr1)},
834 {"Ustr1PlusUStr6 = Ustr1 += Ustr6",
835 new OUString(aUStr1PlusUStr6), new OUString(aUStr1),
836 new OUString(aUStr6)},
840 sal_Bool res = sal_True;
841 sal_uInt32 i;
843 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
845 *(arrTestCase[i].input1) += *(arrTestCase[i].input2);
846 sal_Bool lastRes = (*(arrTestCase[i].expVal) ==
847 *(arrTestCase[i].input1));
848 c_rtl_tres_state
850 hRtlTestResult,
851 lastRes,
852 arrTestCase[i].comments,
853 createName( pMeth, "op_peq", i )
856 res &= lastRes;
858 c_rtl_tres_state_end( hRtlTestResult, "peq");
859 // return ( res );
862 //------------------------------------------------------------------------
863 // testing the operator const sal_Unicode * (csuc for short)
864 //------------------------------------------------------------------------
865 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_csuc(
866 hTestResult hRtlTestResult)
868 c_rtl_tres_state_start( hRtlTestResult, "csuc");
869 sal_Char methName[MAXBUFLENGTH];
870 sal_Char* pMeth = methName;
872 const sal_Unicode tmpUC=0x0;
873 rtl_uString* tmpUstring = NULL;
874 const sal_Char *tmpStr=kTestStr1;
875 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
876 // sal_Int32 cmpLen = 0;
878 rtl_string2UString( &tmpUstring, tmpStr, tmpLen,
879 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
880 OSL_ASSERT(tmpUstring != NULL);
883 typedef struct TestCase
885 sal_Char* comments;
886 const sal_Unicode* expVal;
887 sal_Int32 cmpLen;
888 OUString* input1;
889 ~TestCase() { delete input1;}
890 } TestCase;
892 TestCase arrTestCase[] =
894 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
895 new OUString(aUStr1)},
896 {"test empty ustring",&tmpUC, 1, new OUString()}
899 sal_Bool res = sal_True;
900 sal_uInt32 i;
901 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
903 const sal_Unicode* pstr = *arrTestCase[i].input1;
905 res &= c_rtl_tres_state
907 hRtlTestResult,
908 cmpstr((sal_Char*)pstr,
909 (sal_Char*)arrTestCase[i].expVal,
910 arrTestCase[i].cmpLen),
911 arrTestCase[i].comments,
912 createName( pMeth, "const sal_Unicode*", i )
915 c_rtl_tres_state_end( hRtlTestResult, "csuc");
916 // return ( res );
919 //------------------------------------------------------------------------
920 // testing the method const sal_Unicode * getStr()
921 //------------------------------------------------------------------------
922 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_getStr(
923 hTestResult hRtlTestResult)
925 c_rtl_tres_state_start( hRtlTestResult, "getStr");
926 sal_Char methName[MAXBUFLENGTH];
927 sal_Char* pMeth = methName;
929 const sal_Unicode tmpUC=0x0;
930 rtl_uString* tmpUstring = NULL;
931 const sal_Char *tmpStr=kTestStr1;
932 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
933 // sal_Int32 cmpLen = 0;
935 rtl_string2UString( &tmpUstring, tmpStr, tmpLen,
936 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
937 OSL_ASSERT(tmpUstring != NULL);
940 typedef struct TestCase
942 sal_Char* comments;
943 const sal_Unicode* expVal;
944 sal_Int32 cmpLen;
945 OUString* input1;
946 ~TestCase() { delete input1;}
947 } TestCase;
949 TestCase arrTestCase[] =
951 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
952 new OUString(aUStr1)},
953 {"test empty ustring",&tmpUC, 1, new OUString()}
956 sal_Bool res = sal_True;
957 sal_uInt32 i;
958 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
960 const sal_Unicode* pstr = arrTestCase[i].input1->getStr();
962 res &= c_rtl_tres_state
964 hRtlTestResult,
965 cmpstr((sal_Char*)pstr,
966 (sal_Char*)arrTestCase[i].expVal,
967 arrTestCase[i].cmpLen),
968 arrTestCase[i].comments,
969 createName( pMeth, "getStr", i )
972 c_rtl_tres_state_end( hRtlTestResult, "getStr");
973 // return ( res );
977 //------------------------------------------------------------------------
978 // testing the method sal_Int32 reverseCompareTo( const OUString & str )
979 //-------------------------------------------------------------------------
980 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_reverseCompareTo(
981 hTestResult hRtlTestResult )
983 c_rtl_tres_state_start( hRtlTestResult, "reverseCompareTo");
984 sal_Char methName[MAXBUFLENGTH];
985 sal_Char* pMeth = methName;
987 typedef struct TestCase
989 sal_Char* comments;
990 sal_Int32 expVal;
991 OUString* input1;
992 OUString* input2;
993 ~TestCase() { delete input1;delete input2;}
994 } TestCase;
996 TestCase arrTestCase[]={
998 {"simple compare, str1 to str5",-1,new OUString(aUStr1),
999 new OUString(aUStr5)
1001 {"simple compare, str2 to str5",1,new OUString(aUStr2),
1002 new OUString(aUStr5)
1004 {"simple compare, str1 to str9",-1,new OUString(aUStr1),
1005 new OUString(aUStr9)
1007 {"simple compare, str4 to str5",-1,new OUString(aUStr4),
1008 new OUString(aUStr5)
1010 {"simple compare, str5 to str1",+1,new OUString(aUStr5),
1011 new OUString(aUStr1)
1013 {"simple compare, str2 to str1",+1,new OUString(aUStr2),
1014 new OUString(aUStr1)
1016 {"simple compare, str1 to str1",0,new OUString(aUStr1),
1017 new OUString(aUStr1)
1019 {"simple compare, nullString to nullString",0,new OUString(),
1020 new OUString()
1022 {"simple compare, nullString to str2",-1,new OUString(),
1023 new OUString(aUStr2)
1025 {"simple compare, str1 to nullString",+1,new OUString(aUStr1),
1026 new OUString()
1030 sal_Bool res = sal_True;
1031 sal_uInt32 i;
1033 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1035 sal_Int32 cmpRes = arrTestCase[i].input1->reverseCompareTo
1036 (*arrTestCase[i].input2);
1037 cmpRes = ( cmpRes == 0 ) ? 0 : ( cmpRes > 0 ) ? +1 : -1 ;
1038 sal_Bool lastRes = ( cmpRes == arrTestCase[i].expVal);
1041 c_rtl_tres_state
1043 hRtlTestResult,
1044 lastRes,
1045 arrTestCase[i].comments,
1046 createName( pMeth, "compareTo(const OString&)", i )
1049 res &= lastRes;
1051 c_rtl_tres_state_end( hRtlTestResult, "reverseCompareTo");
1052 // return (res);
1055 //------------------------------------------------------------------------
1056 // testing the method sal_Bool equalsAscii( const sal_Char* asciiStr )
1057 //------------------------------------------------------------------------
1058 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_equalsAscii(
1059 hTestResult hRtlTestResult)
1061 c_rtl_tres_state_start( hRtlTestResult, "equalsAscii");
1062 sal_Char methName[MAXBUFLENGTH];
1063 sal_Char* pMeth = methName;
1065 const sal_Char *tmpAstr1="Sun Microsystems\0";
1066 const sal_Char *tmpAstr2="\0";
1070 typedef struct TestCase
1072 sal_Char* comments;
1073 sal_Bool expVal;
1074 OUString* input1;
1075 const sal_Char* input2;
1076 ~TestCase() { delete input1;}
1077 } TestCase;
1079 TestCase arrTestCase[]={
1080 {"str1 with str1 ", sal_True, new OUString( kTestStr1,
1081 kTestStr1Len,
1082 kEncodingRTLTextUSASCII,
1083 kConvertFlagsOStringToOUString
1084 ), tmpAstr1},
1085 {"str2 with str1 ", sal_False,new OUString( kTestStr2,
1086 kTestStr2Len,
1087 kEncodingRTLTextUSASCII,
1088 kConvertFlagsOStringToOUString
1089 ), tmpAstr1},
1090 {"null with str1 ", sal_False, new OUString(), tmpAstr1},
1091 {"null with '' ", sal_True, new OUString(), tmpAstr2},
1092 {"'' with ''", sal_True, new OUString( "",
1094 kEncodingRTLTextUSASCII,
1095 kConvertFlagsOStringToOUString
1097 tmpAstr2}
1102 sal_Bool res = sal_True;
1103 sal_uInt32 i;
1105 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1108 sal_Bool lastRes = (arrTestCase[i].expVal ==
1109 arrTestCase[i].input1->equalsAscii(arrTestCase[i].input2));
1110 c_rtl_tres_state
1112 hRtlTestResult,
1113 lastRes,
1114 arrTestCase[i].comments,
1115 createName( pMeth, "equalsAscii", i )
1118 res &= lastRes;
1120 c_rtl_tres_state_end( hRtlTestResult, "equalsAscii");
1121 // return ( res );
1126 //------------------------------------------------------------------------
1127 // testing the method sal_Bool equalsAsciiL(
1128 // const sal_Char* asciiStr, sal_Int32 asciiStrLength )
1129 //------------------------------------------------------------------------
1130 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_equalsAsciiL(
1131 hTestResult hRtlTestResult)
1133 c_rtl_tres_state_start( hRtlTestResult, "equalsAsciiL");
1134 sal_Char methName[MAXBUFLENGTH];
1135 sal_Char* pMeth = methName;
1137 const sal_Char *tmpAstr1="Sun Microsystems\0";
1138 const sal_Char *tmpAstr2="\0";
1139 const sal_Char *tmpAstr3="Sun Microsystems Java Technology\0";
1143 typedef struct TestCase
1145 sal_Char* comments;
1146 sal_Bool expVal;
1147 OUString* input1;
1148 const sal_Char* input2;
1149 sal_Int32 cmpLen;
1150 ~TestCase() { delete input1;}
1151 } TestCase;
1153 TestCase arrTestCase[]={
1154 {"str1 with str1,str1Len ", sal_True, new OUString( kTestStr1,
1155 kTestStr1Len,
1156 kEncodingRTLTextUSASCII,
1157 kConvertFlagsOStringToOUString
1158 ), tmpAstr1, kTestStr1Len},
1159 {"str2 with str1,str1Len", sal_False,new OUString( kTestStr2,
1160 kTestStr2Len,
1161 kEncodingRTLTextUSASCII,
1162 kConvertFlagsOStringToOUString
1163 ), tmpAstr1, kTestStr1Len},
1164 {"str1 with str2,str1Len", sal_True,new OUString( kTestStr1,
1165 kTestStr1Len,
1166 kEncodingRTLTextUSASCII,
1167 kConvertFlagsOStringToOUString
1168 ), tmpAstr3, kTestStr1Len},
1169 {"null with str1,1 ", sal_False, new OUString(), tmpAstr1, 1},
1170 {"null with '',1 ", sal_False, new OUString(), tmpAstr2, 1},
1171 {"'' with '', 1", sal_False, new OUString( "",
1173 kEncodingRTLTextUSASCII,
1174 kConvertFlagsOStringToOUString
1176 tmpAstr2, 1}
1181 sal_Bool res = sal_True;
1182 sal_uInt32 i;
1184 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1187 sal_Bool lastRes = (arrTestCase[i].expVal ==
1188 arrTestCase[i].input1->equalsAsciiL(arrTestCase[i].input2,
1189 arrTestCase[i].cmpLen)
1191 c_rtl_tres_state
1193 hRtlTestResult,
1194 lastRes,
1195 arrTestCase[i].comments,
1196 createName( pMeth, "equalsAsciiL", i )
1199 res &= lastRes;
1201 c_rtl_tres_state_end( hRtlTestResult, "equalsAsciiL");
1202 // return ( res );
1205 //------------------------------------------------------------------------
1206 // testing the method sal_Int32 compareToAscii( const sal_Char* asciiStr )
1207 //------------------------------------------------------------------------
1208 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_compareToAscii(
1209 hTestResult hRtlTestResult)
1211 c_rtl_tres_state_start( hRtlTestResult, "compareToAscii");
1212 sal_Char methName[MAXBUFLENGTH];
1213 sal_Char* pMeth = methName;
1215 const sal_Char *tmpAstr1="Sun Microsystems\0";
1216 const sal_Char *tmpAstr2="\0";
1217 const sal_Char *tmpAstr3="sun microsystems java technology\0";
1218 const sal_Char *tmpAstr4="Sun Microsystems Java Technology\0";
1221 typedef struct TestCase
1223 sal_Char* comments;
1224 sal_Int32 expVal;
1225 OUString* input1;
1226 const sal_Char* input2;
1227 ~TestCase() { delete input1;}
1228 } TestCase;
1230 TestCase arrTestCase[]={
1231 {"str1 with str1 ", 0, new OUString( kTestStr1,
1232 kTestStr1Len,
1233 kEncodingRTLTextUSASCII,
1234 kConvertFlagsOStringToOUString
1235 ), tmpAstr1},
1236 {"str1 with '' ", 83, new OUString( kTestStr1,
1237 kTestStr1Len,
1238 kEncodingRTLTextUSASCII,
1239 kConvertFlagsOStringToOUString
1240 ), tmpAstr2},
1241 {"null with str1 ", -83 , new OUString(), tmpAstr1},
1242 {"null with '' ", 0, new OUString(), tmpAstr2},
1243 {"str1 with str9", -32, new OUString( kTestStr1,
1244 kTestStr1Len,
1245 kEncodingRTLTextUSASCII,
1246 kConvertFlagsOStringToOUString
1248 tmpAstr3},
1249 {"str1 with str2", -32, new OUString( kTestStr1,
1250 kTestStr1Len,
1251 kEncodingRTLTextUSASCII,
1252 kConvertFlagsOStringToOUString
1254 tmpAstr4}
1259 sal_Bool res = sal_True;
1260 sal_uInt32 i;
1262 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1264 sal_Bool lastRes = (arrTestCase[i].expVal ==
1265 arrTestCase[i].input1->compareToAscii(arrTestCase[i].input2));
1267 c_rtl_tres_state
1269 hRtlTestResult,
1270 lastRes,
1271 arrTestCase[i].comments,
1272 createName( pMeth, "equalsAscii", i )
1275 res &= lastRes;
1277 c_rtl_tres_state_end( hRtlTestResult, "compareToAscii");
1278 // return ( res );
1282 //------------------------------------------------------------------------
1283 // testing the method valueOf( sal_Bool b )
1284 //------------------------------------------------------------------------
1285 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_valueOf_sal_Bool(
1286 hTestResult hRtlTestResult )
1288 c_rtl_tres_state_start( hRtlTestResult, "Bool");
1289 sal_Char methName[MAXBUFLENGTH];
1290 sal_Char* pMeth = methName;
1292 typedef struct TestCase
1294 sal_Char* comments;
1295 OUString* expVal;
1296 sal_Bool input1;
1298 ~TestCase() {delete expVal;}
1299 }TestCase;
1301 TestCase arrTestCase[]=
1303 {"input Bool 'true' and return OUString 'true'",
1304 new OUString("true",4,kEncodingRTLTextUSASCII,
1305 kConvertFlagsOStringToOUString),
1306 sal_True
1308 {"input Bool 'false' and return OUString 'false'",
1309 new OUString("false",5,kEncodingRTLTextUSASCII,
1310 kConvertFlagsOStringToOUString),
1311 sal_False
1315 sal_Bool res;
1316 sal_uInt32 i;
1318 for(i=0;i<(sizeof(arrTestCase))/(sizeof(TestCase));i++)
1320 sal_Bool lastRes=(*arrTestCase[i].expVal==
1321 OUString::valueOf(arrTestCase[i].input1)
1325 c_rtl_tres_state(hRtlTestResult,
1326 lastRes,
1327 arrTestCase[i].comments,
1328 createName( pMeth, "valueOf( sal_Bool b )", i )
1331 res &= lastRes;
1333 c_rtl_tres_state_end( hRtlTestResult, "Bool");
1334 // return(res);
1337 //------------------------------------------------------------------------
1338 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_valueOf_sal_Unicode(
1339 hTestResult hRtlTestResult )
1341 c_rtl_tres_state_start( hRtlTestResult, "Unicode");
1342 sal_Char methName[MAXBUFLENGTH];
1343 sal_Char* pMeth = methName;
1345 sal_Unicode tmpchar1=97;
1346 sal_Unicode tmpchar2=53;
1347 sal_Unicode tmpchar3=0;
1348 sal_Unicode tmpchar4=32;
1349 sal_Unicode tmpchar5=47;
1351 typedef struct TestCase
1353 sal_Char* comments;
1354 OUString* expVal;
1355 sal_Unicode input1;
1357 ~TestCase() {delete expVal;}
1358 }TestCase;
1360 TestCase arrTestCase[]=
1362 {"input Unicode 'a' and return OUString 'a'",
1363 new OUString(&tmpchar1,1),tmpchar1
1365 {"input Unicode '5' and return OUString '5'",
1366 new OUString(&tmpchar2,1), tmpchar2
1368 {"input Unicode 0 and return OUString 0",
1369 new OUString(&tmpchar3,1),tmpchar3
1371 {"input Unicode ' ' and return OUString ' '",
1372 new OUString(&tmpchar4,1),tmpchar4
1374 {"input Unicode '/' and return OUString ' '",
1375 new OUString(&tmpchar5,1),tmpchar5
1379 sal_Bool res=sal_True;
1380 sal_uInt32 i;
1382 for(i=0;i<(sizeof(arrTestCase))/(sizeof(TestCase));i++)
1384 sal_Bool lastRes=(*(arrTestCase[i].expVal)==
1385 OUString::valueOf(arrTestCase[i].input1));
1387 c_rtl_tres_state(hRtlTestResult,
1388 lastRes,
1389 arrTestCase[i].comments,
1390 createName( pMeth, "valueOf( sal_Unicode c )", i )
1393 res &= lastRes;
1395 c_rtl_tres_state_end( hRtlTestResult, "Unicode");
1396 // return(res);
1401 * Calls the method valueOf(T, radix) and compares
1402 * returned ustrings with ustrings that passed in the array resArray.
1404 * @param T, type of argument, passed to valueOf
1405 * @param resArray, array of result ustrings to compare to
1406 * @param n the number of elements in the array resArray (testcases)
1407 * @param pTestResult the instance of the class TestResult
1408 * @param inArray [optional], array of value that is passed as first argument
1409 * to valueOf
1411 * @return true, if all returned ustrings are equal to corresponding ustring in
1412 * resArray else, false.
1414 template <class T>
1415 sal_Bool test_valueOf( const char** resArray, int n, sal_Int16 radix,
1416 hTestResult hRtlTestResult, const T *inArray )
1418 sal_Bool bRes = sal_True;
1420 sal_Char methName[MAXBUFLENGTH];
1421 sal_Char* pMeth = methName;
1422 sal_Int32 i;
1423 // static sal_Unicode aUchar[50]={0x12};
1425 for (i = 0; i < n; i++)
1427 ::rtl::OUString aStr1;
1429 OSL_ENSURE( i < 50, "ERROR: leave aUchar bound");
1431 // AStringToUStringCopy(aUchar,resArray[i]);
1432 // ::rtl::OUString aStr2(aUchar);
1433 rtl::OUString aStr2;
1434 aStr2 = OUString::createFromAscii(resArray[i]);
1436 ::rtl::OUString aStr3( "-",1,kEncodingRTLTextUSASCII,
1437 kConvertFlagsOStringToOUString);
1439 if (inArray == 0)
1441 aStr1 = ::rtl::OUString::valueOf((T)i, radix);
1443 else
1445 if ( inArray[i] < 0 )
1447 sal_Unicode aStr4[100];
1448 OSL_ASSERT(strlen(resArray[i]) < 100);
1450 if(AStringToUStringCopy(aStr4,resArray[i]))
1452 aStr2 = aStr3;
1453 aStr2 += aStr4;
1457 aStr1 = ::rtl::OUString::valueOf((T)inArray[i], radix);
1460 bRes &= c_rtl_tres_state
1462 hRtlTestResult,
1463 aStr2.compareTo(aStr1) == 0,
1464 (sal_Char*)resArray[i],
1465 createName( pMeth, "valueOf", i )
1469 return (bRes);
1473 #define test_valueOf_Int32 test_valueOf<sal_Int32>
1474 #define test_valueOf_Int64 test_valueOf<sal_Int64>
1475 // LLA: #define test_valueOf_float test_valueOf<float>
1476 // LLA: #define test_valueOf_double test_valueOf<double>
1478 //------------------------------------------------------------------------
1479 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=2 )
1480 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=8 )
1481 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=10 )
1482 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=16 )
1483 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=36 )
1484 //------------------------------------------------------------------------
1485 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int32(
1486 hTestResult hRtlTestResult )
1488 sal_Bool bRes = sal_False;
1490 bRes = c_rtl_tres_state
1492 hRtlTestResult,
1493 test_valueOf_Int32((const char**)kBinaryNumsStr,
1494 kBinaryNumsCount, kRadixBinary, hRtlTestResult, 0 ),
1495 "kRadixBinary",
1496 "valueOf(sal_Int32, radix 2)"
1500 bRes &= c_rtl_tres_state
1502 hRtlTestResult,
1503 test_valueOf_Int32((const char**)kOctolNumsStr,
1504 kOctolNumsCount, kRadixOctol, hRtlTestResult, 0),
1505 "kRadixOctol",
1506 "valueOf(sal_Int32, radix 8)"
1509 bRes &= c_rtl_tres_state
1511 hRtlTestResult,
1512 test_valueOf_Int32((const char**)kDecimalNumsStr,
1513 kDecimalNumsCount, kRadixDecimal, hRtlTestResult, 0),
1514 "kRadixDecimal",
1515 "valueOf(sal_Int32, radix 10)"
1518 bRes &= c_rtl_tres_state
1520 hRtlTestResult,
1521 test_valueOf_Int32((const char**)kHexDecimalNumsStr,
1522 kHexDecimalNumsCount, kRadixHexdecimal, hRtlTestResult, 0),
1523 "kRadixHexdecimal",
1524 "valueOf(sal_Int32, radix 16)"
1527 bRes &= c_rtl_tres_state
1529 hRtlTestResult,
1530 test_valueOf_Int32((const char**)kBase36NumsStr,
1531 kBase36NumsCount, kRadixBase36, hRtlTestResult, 0),
1532 "kRadixBase36",
1533 "valueOf(sal_Int32, radix 36)"
1537 return ( bRes );
1540 //------------------------------------------------------------------------
1541 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=2 )
1542 // where l = large constants
1543 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=8 )
1544 // where l = large constants
1545 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=10 )
1546 // where l = large constants
1547 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=16 )
1548 // where l = large constants
1549 // testing the method valueOf( sal_Int32 l, sal_Int32 radix=36 )
1550 // where l = large constants
1551 //------------------------------------------------------------------------
1552 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int32_Bounderies(
1553 hTestResult hRtlTestResult )
1555 sal_Bool bRes = sal_False;
1557 bRes = c_rtl_tres_state
1559 hRtlTestResult,
1560 test_valueOf_Int32((const char**)kBinaryMaxNumsStr,
1561 kInt32MaxNumsCount, kRadixBinary,
1562 hRtlTestResult, kInt32MaxNums),
1563 "kRadixBinary",
1564 "valueOf(salInt32, radix 2) Bounderies"
1567 bRes &= c_rtl_tres_state
1569 hRtlTestResult,
1570 test_valueOf_Int32((const char**)kOctolMaxNumsStr,
1571 kInt32MaxNumsCount, kRadixOctol,
1572 hRtlTestResult, kInt32MaxNums),
1573 "kRadixOctol",
1574 "valueOf(salInt32, radix 8) Bounderies"
1577 bRes &= c_rtl_tres_state
1579 hRtlTestResult,
1580 test_valueOf_Int32((const char**)kDecimalMaxNumsStr,
1581 kInt32MaxNumsCount, kRadixDecimal,
1582 hRtlTestResult, kInt32MaxNums),
1583 "kRadixDecimal",
1584 "valueOf(salInt32, radix 10) Bounderies"
1587 bRes &= c_rtl_tres_state
1589 hRtlTestResult,
1590 test_valueOf_Int32((const char**)kHexDecimalMaxNumsStr,
1591 kInt32MaxNumsCount, kRadixHexdecimal,
1592 hRtlTestResult, kInt32MaxNums),
1593 "kRadixHexdecimal",
1594 "valueOf(salInt32, radix 16) Bounderies"
1597 bRes &= c_rtl_tres_state
1599 hRtlTestResult,
1600 test_valueOf_Int32((const char**)kBase36MaxNumsStr,
1601 kInt32MaxNumsCount, kRadixBase36,
1602 hRtlTestResult, kInt32MaxNums),
1603 "kRadixBase36",
1604 "valueOf(salInt32, radix 36) Bounderies"
1607 return ( bRes );
1610 //------------------------------------------------------------------------
1611 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=2 )
1612 // for negative value
1613 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=8 )
1614 // for negative value
1615 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=10 )
1616 // for negative value
1617 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=16 )
1618 // for negative value
1619 // testing the method valueOf( sal_Int32 i, sal_Int16 radix=36 )
1620 // for negative value
1621 //------------------------------------------------------------------------
1622 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int32_Negative(
1623 hTestResult hRtlTestResult )
1625 sal_Bool bRes = sal_False;
1626 sal_Int32 inArr[kBase36NumsCount];
1627 sal_Int32 i;
1629 for (i = 0; i < kBase36NumsCount; i++ )
1630 inArr[i] = -i;
1632 bRes = c_rtl_tres_state
1634 hRtlTestResult,
1635 test_valueOf_Int32( kBinaryNumsStr, kBinaryNumsCount,
1636 kRadixBinary, hRtlTestResult, inArr ),
1637 "negative Int32, kRadixBinary",
1638 "valueOf( negative Int32, radix 2 )"
1641 bRes &= c_rtl_tres_state
1643 hRtlTestResult,
1644 test_valueOf_Int32( kOctolNumsStr, kOctolNumsCount,
1645 kRadixOctol, hRtlTestResult, inArr ),
1646 "negative Int32, kRadixOctol",
1647 "valueOf( negative Int32, radix 8 )"
1651 bRes &= c_rtl_tres_state
1653 hRtlTestResult,
1654 test_valueOf_Int32( kDecimalNumsStr, kDecimalNumsCount,
1655 kRadixDecimal, hRtlTestResult, inArr ),
1656 "negative Int32, kRadixDecimal",
1657 "valueOf( negative Int32, radix 10 )"
1660 bRes &= c_rtl_tres_state
1662 hRtlTestResult,
1663 test_valueOf_Int32( kHexDecimalNumsStr, kHexDecimalNumsCount,
1664 kRadixHexdecimal, hRtlTestResult, inArr ),
1665 "negative Int32, kRadixHexdecimal",
1666 "valueOf( negative Int32, radix 16 )"
1670 bRes &= c_rtl_tres_state
1672 hRtlTestResult,
1673 test_valueOf_Int32( kBase36NumsStr, kBase36NumsCount,
1674 kRadixBase36, hRtlTestResult, inArr ),
1675 "negative Int32, kRadixBase36",
1676 "valueOf( negative Int32, radix 36 )"
1679 return ( bRes );
1681 //------------------------------------------------------------------------
1682 // testing the method valueOf( sal_Int32 l, sal_Int32 radix ) where radix = -5
1683 //------------------------------------------------------------------------
1684 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int32_WrongRadix(
1685 hTestResult hRtlTestResult )
1687 sal_Bool bRes = sal_False;
1689 sal_Int32 intVal = 11;
1691 ::rtl::OUString aStr1;
1692 ::rtl::OUString aStr2("11",2,kEncodingRTLTextUSASCII,
1693 kConvertFlagsOStringToOUString);
1695 aStr1 = aStr1.valueOf( intVal, -5 );
1697 bRes = c_rtl_tres_state
1699 hRtlTestResult,
1700 aStr2.compareTo( aStr1 ) == 0,
1701 "if radix not valid then radix must be 10",
1702 "valueOf(sal_Int32, sal_Int32 radix): radix = -5"
1705 return (bRes);
1709 //------------------------------------------------------------------------
1710 static sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int32_defaultParam(
1711 hTestResult hRtlTestResult )
1713 sal_Char methName[MAXBUFLENGTH];
1714 sal_Char* pMeth = methName;
1716 sal_Char* newUChar1="15";
1717 sal_Char* newUChar2="0";
1718 sal_Char* newUChar3="-15";
1719 sal_Char* newUChar4="2147483647";
1720 sal_Char* newUChar5="-2147483648";
1722 typedef struct TestCase
1724 sal_Char* comments;
1725 sal_Int32 input1;
1726 OUString* expVal;
1727 ~TestCase() {delete expVal;}
1728 }TestCase;
1730 TestCase arrTestCase[]=
1732 {"input Int32 15 and return OUString 15",15,
1733 new OUString(newUChar1,2,kEncodingRTLTextUSASCII,
1734 kConvertFlagsOStringToOUString)
1736 {"input Int32 0 and return OUString 0",0,
1737 new OUString(newUChar2,1,kEncodingRTLTextUSASCII,
1738 kConvertFlagsOStringToOUString)
1740 {"input Int32 -15 and return OUString -15",-15,
1741 new OUString(newUChar3,3,kEncodingRTLTextUSASCII,
1742 kConvertFlagsOStringToOUString)
1744 {"input Int32 2147483647 and return OUString 2147483647", SAL_MAX_INT32 /* 2147483647 */,
1745 new OUString(newUChar4,10,kEncodingRTLTextUSASCII,
1746 kConvertFlagsOStringToOUString)
1748 {"input Int32 -2147483648 and return OUString -2147483648",
1749 SAL_MIN_INT32 /* 2-2147483648 */,
1750 new OUString(newUChar5,11,kEncodingRTLTextUSASCII,
1751 kConvertFlagsOStringToOUString)
1755 sal_Bool res=sal_True;
1756 sal_uInt32 i;
1758 for(i=0;i<(sizeof(arrTestCase))/(sizeof(TestCase));i++)
1760 sal_Bool lastRes=(*(arrTestCase[i].expVal)==
1761 OUString::valueOf(arrTestCase[i].input1));
1763 c_rtl_tres_state(hRtlTestResult,
1764 lastRes,
1765 arrTestCase[i].comments,
1766 createName( pMeth,
1767 "valueOf( sal_Int32 i, sal_Int16 radix = 10 )", i )
1770 res &= lastRes;
1773 return(res);
1776 //------------------------------------------------------------------------
1777 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=2 )
1778 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=8 )
1779 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=10 )
1780 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=16 )
1781 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=36 )
1782 //------------------------------------------------------------------------
1783 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int64(
1784 hTestResult hRtlTestResult )
1786 sal_Bool bRes = sal_False;
1788 bRes = c_rtl_tres_state
1790 hRtlTestResult,
1791 test_valueOf_Int64((const char**)kBinaryNumsStr,
1792 kBinaryNumsCount, kRadixBinary, hRtlTestResult, 0),
1793 "kRadixBinary",
1794 "valueOf(sal_Int64, radix 2)_"
1797 bRes &= c_rtl_tres_state
1799 hRtlTestResult,
1800 test_valueOf_Int64((const char**)kOctolNumsStr,
1801 kOctolNumsCount, kRadixOctol, hRtlTestResult, 0),
1802 "kRadixOctol",
1803 "valueOf(sal_Int64, radix 8)_"
1806 bRes &= c_rtl_tres_state
1808 hRtlTestResult,
1809 test_valueOf_Int64((const char**)kDecimalNumsStr,
1810 kDecimalNumsCount, kRadixDecimal, hRtlTestResult, 0),
1811 "kRadixDecimal",
1812 "valueOf(sal_Int64, radix 10)_"
1814 bRes &= c_rtl_tres_state
1816 hRtlTestResult,
1817 test_valueOf_Int64((const char**)kHexDecimalNumsStr,
1818 kHexDecimalNumsCount, kRadixHexdecimal, hRtlTestResult, 0),
1819 "kRadixHexdecimal",
1820 "valueOf(sal_Int64, radix 16)_"
1823 bRes &= c_rtl_tres_state
1825 hRtlTestResult,
1826 test_valueOf_Int64((const char**)kBase36NumsStr,
1827 kBase36NumsCount, kRadixBase36, hRtlTestResult, 0),
1828 "kRadixBase36",
1829 "valueOf(sal_Int64, radix 36)_"
1832 return (bRes);
1835 //------------------------------------------------------------------------
1836 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=2 )
1837 // where l = large constants
1838 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=8 )
1839 // where l = large constants
1840 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=10 )
1841 // where l = large constants
1842 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=16 )
1843 // where l = large constants
1844 // testing the method valueOf( sal_Int64 l, sal_Int32 radix=36 )
1845 // where l = large constants
1846 //------------------------------------------------------------------------
1847 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int64_Bounderies(
1848 hTestResult hRtlTestResult )
1850 sal_Bool bRes = sal_False;
1852 bRes = c_rtl_tres_state
1854 hRtlTestResult,
1855 test_valueOf_Int64((const char**)kBinaryMaxNumsStr,
1856 kInt64MaxNumsCount, kRadixBinary,
1857 hRtlTestResult, kInt64MaxNums),
1858 "kRadixBinary",
1859 "valueOf(salInt64, radix 2) Bounderies"
1862 bRes &= c_rtl_tres_state
1864 hRtlTestResult,
1865 test_valueOf_Int64((const char**)kOctolMaxNumsStr,
1866 kInt64MaxNumsCount, kRadixOctol,
1867 hRtlTestResult, kInt64MaxNums),
1868 "kRadixOctol",
1869 "valueOf(salInt64, radix 8) Bounderies"
1872 bRes &= c_rtl_tres_state
1874 hRtlTestResult,
1875 test_valueOf_Int64((const char**)kDecimalMaxNumsStr,
1876 kInt64MaxNumsCount, kRadixDecimal,
1877 hRtlTestResult, kInt64MaxNums),
1878 "kRadixDecimal",
1879 "valueOf(salInt64, radix 10) Bounderies"
1882 bRes &= c_rtl_tres_state
1884 hRtlTestResult,
1885 test_valueOf_Int64((const char**)kHexDecimalMaxNumsStr,
1886 kInt64MaxNumsCount, kRadixHexdecimal,
1887 hRtlTestResult, kInt64MaxNums),
1888 "kRadixHexdecimal",
1889 "valueOf(salInt64, radix 16) Bounderies"
1892 bRes &= c_rtl_tres_state
1894 hRtlTestResult,
1895 test_valueOf_Int64((const char**)kBase36MaxNumsStr,
1896 kInt64MaxNumsCount, kRadixBase36,
1897 hRtlTestResult, kInt64MaxNums),
1898 "kRadixBase36",
1899 "valueOf(salInt64, radix 36) Bounderies"
1902 return ( bRes );
1905 //------------------------------------------------------------------------
1906 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=2 )
1907 // for negative value
1908 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=8 )
1909 // for negative value
1910 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=10 )
1911 // for negative value
1912 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=16 )
1913 // for negative value
1914 // testing the method valueOf( sal_Int64 l, sal_Int16 radix=36 )
1915 // for negative value
1916 //------------------------------------------------------------------------
1917 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int64_Negative(
1918 hTestResult hRtlTestResult )
1920 sal_Bool bRes = sal_False;
1922 sal_Int64 inArr[36];
1923 sal_Int32 i;
1925 for (i = 0; i < 36; i++) {
1926 inArr[i] = -i;
1930 bRes = c_rtl_tres_state
1932 hRtlTestResult,
1933 test_valueOf_Int64( kBinaryNumsStr, kBinaryNumsCount,
1934 kRadixBinary, hRtlTestResult, inArr ),
1935 "negative Int64, kRadixBinary",
1936 "valueOf( negative Int64, radix 2 )"
1939 bRes &= c_rtl_tres_state
1941 hRtlTestResult,
1942 test_valueOf_Int64( kOctolNumsStr, kOctolNumsCount,
1943 kRadixOctol, hRtlTestResult, inArr ),
1944 "negative Int64, kRadixOctol",
1945 "valueOf( negative Int64, radix 8 )"
1948 bRes &= c_rtl_tres_state
1950 hRtlTestResult,
1951 test_valueOf_Int64( kDecimalNumsStr, kDecimalNumsCount,
1952 kRadixDecimal, hRtlTestResult, inArr ),
1953 "negative Int64, kRadixDecimal",
1954 "valueOf( negative Int64, radix 10 )"
1957 bRes &= c_rtl_tres_state
1959 hRtlTestResult,
1960 test_valueOf_Int64( kHexDecimalNumsStr, kHexDecimalNumsCount,
1961 kRadixHexdecimal, hRtlTestResult, inArr ),
1962 "negative Int64, kRadixHexDecimal",
1963 "valueOf( negative Int64, radix 16 )"
1966 bRes &= c_rtl_tres_state
1968 hRtlTestResult,
1969 test_valueOf_Int64( kBase36NumsStr, kBase36NumsCount,
1970 kRadixBase36, hRtlTestResult, inArr),
1971 "negative Int64, kRadixBase36",
1972 "valueOf( negative Int64, radix 36 )"
1975 return (bRes);
1977 //------------------------------------------------------------------------
1978 // testing the method valueOf( sal_Int64 l, sal_Int32 radix )
1979 // where radix = -5
1980 //------------------------------------------------------------------------
1981 sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int64_WrongRadix(
1982 hTestResult hRtlTestResult )
1984 sal_Bool bRes = sal_False;
1986 sal_Int64 intVal = 11;
1988 ::rtl::OUString aStr1;
1989 ::rtl::OUString aStr2("11",2,kEncodingRTLTextUSASCII,
1990 kConvertFlagsOStringToOUString);
1992 aStr1 = aStr1.valueOf( intVal, -5 );
1994 bRes = c_rtl_tres_state
1996 hRtlTestResult,
1997 aStr2.compareTo(aStr1) == 0,
1998 "if radix not valid then radix must be 10",
1999 "valueOf(sal_Int64, sal_Int32 radix): radix = -5"
2002 return (bRes);
2005 //------------------------------------------------------------------------
2006 static sal_Bool SAL_CALL test_rtl_OUString_valueOf_Int64_defaultParam(
2007 hTestResult hRtlTestResult )
2009 sal_Char methName[MAXBUFLENGTH];
2010 sal_Char* pMeth = methName;
2012 sal_Char* newUChar1="15";
2013 sal_Char* newUChar2="0";
2014 sal_Char* newUChar3="-15";
2015 sal_Char* newUChar4= "9223372036854775807";
2016 sal_Char* newUChar5="-9223372036854775808";
2018 typedef struct TestCase
2020 sal_Char* comments;
2021 sal_Int64 input1;
2022 OUString* expVal;
2023 ~TestCase() {delete expVal;}
2024 }TestCase;
2026 TestCase arrTestCase[]=
2028 {"input Int64 15 and return OUString 15",15,
2029 new OUString(newUChar1,2,kEncodingRTLTextUSASCII,
2030 kConvertFlagsOStringToOUString)
2032 {"input Int64 0 and return OUString 0",0,
2033 new OUString(newUChar2,1,kEncodingRTLTextUSASCII,
2034 kConvertFlagsOStringToOUString)
2036 {"input Int64 -15 and return OUString -15",-15,
2037 new OUString(newUChar3,3,kEncodingRTLTextUSASCII,
2038 kConvertFlagsOStringToOUString)
2040 {"input Int64 9223372036854775807 and return 9223372036854775807",
2041 SAL_MAX_INT64 /* 9223372036854775807*/,
2042 new OUString(newUChar4,19,kEncodingRTLTextUSASCII,
2043 kConvertFlagsOStringToOUString)
2045 {"input Int64 -9223372036854775808 and return -9223372036854775808",
2046 SAL_MIN_INT64 /* 9223372036854775808*/,
2047 new OUString(newUChar5,20,kEncodingRTLTextUSASCII,
2048 kConvertFlagsOStringToOUString)
2052 sal_Bool res=sal_True;
2053 sal_uInt32 i;
2055 for(i=0;i<(sizeof(arrTestCase))/(sizeof(TestCase));i++)
2057 sal_Bool lastRes=(*(arrTestCase[i].expVal)==
2058 OUString::valueOf(arrTestCase[i].input1));
2060 c_rtl_tres_state(hRtlTestResult,
2061 lastRes,
2062 arrTestCase[i].comments,
2063 createName( pMeth,
2064 "valueOf( sal_Int64 i, sal_Int16 radix = 10 )", i )
2067 res &= lastRes;
2070 return(res);
2073 //------------------------------------------------------------------------
2074 // testing the method valueOf( float f )
2075 //------------------------------------------------------------------------
2076 // LLA: sal_Bool SAL_CALL test_rtl_OUString_valueOf_float(
2077 // LLA: hTestResult hRtlTestResult )
2078 // LLA: {
2079 // LLA: sal_Char methName[MAXBUFLENGTH];
2080 // LLA: sal_Char* pMeth =methName;
2081 // LLA:
2082 // LLA: typedef struct TestCase
2083 // LLA: {
2084 // LLA: sal_Char* comments;
2085 // LLA: float input1;
2086 // LLA: OUString* expVal;
2087 // LLA:
2088 // LLA: ~TestCase() {delete expVal;}
2089 // LLA: } TestCase;
2090 // LLA:
2091 // LLA: TestCase arrTestCase[] =
2092 // LLA: {
2093 // LLA: { "3.0", 3.0, new OUString("3.0",3,kEncodingRTLTextUSASCII,
2094 // LLA: kConvertFlagsOStringToOUString) },
2095 // LLA: { "3.5", 3.5f, new OUString("3.5",3,kEncodingRTLTextUSASCII,
2096 // LLA: kConvertFlagsOStringToOUString)},
2097 // LLA: { "3.0625", 3.0625f, new OUString("3.0625",6,kEncodingRTLTextUSASCII,
2098 // LLA: kConvertFlagsOStringToOUString)},
2099 // LLA: { "3.502525", 3.502525f, new OUString("3.502525",8,
2100 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) },
2101 // LLA: { "3.141592", 3.141592f, new OUString("3.141592",8,
2102 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) },
2103 // LLA: { "3.5025255", 3.5025255f, new OUString("3.5025255",9,
2104 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) },
2105 // LLA: { "3.0039062", 3.00390625f, new OUString("3.0039062",9,
2106 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) }
2107 // LLA: };
2108 // LLA:
2109 // LLA: sal_Bool res = sal_True;
2110 // LLA: sal_Int32 i;
2111 // LLA:
2112 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2113 // LLA: {
2114 // LLA: ::rtl::OUString aStr1;
2115 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2116 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2117 // LLA:
2118 // LLA: c_rtl_tres_state
2119 // LLA: (
2120 // LLA: hRtlTestResult,
2121 // LLA: lastRes,
2122 // LLA: arrTestCase[i].comments,
2123 // LLA: createName( pMeth, "valueof_float", i)
2124 // LLA: );
2125 // LLA:
2126 // LLA: res &= lastRes;
2127 // LLA:
2128 // LLA: }
2129 // LLA:
2130 // LLA: return ( res );
2131 // LLA: }
2133 //------------------------------------------------------------------------
2134 // testing the method valueOf( float f ) for negative value
2135 //------------------------------------------------------------------------
2136 // LLA: sal_Bool SAL_CALL test_rtl_OUString_valueOf_Float_Negative(
2137 // LLA: hTestResult hRtlTestResult )
2138 // LLA: {
2139 // LLA: sal_Char methName[MAXBUFLENGTH];
2140 // LLA: sal_Char* pMeth =methName;
2141 // LLA:
2142 // LLA: typedef struct TestCase
2143 // LLA: {
2144 // LLA: sal_Char* comments;
2145 // LLA: float input1;
2146 // LLA: OUString* expVal;
2147 // LLA:
2148 // LLA: ~TestCase() {delete expVal;}
2149 // LLA: } TestCase;
2150 // LLA:
2151 // LLA: TestCase arrTestCase[] =
2152 // LLA: {
2153 // LLA: { "-3.0", -3.0, new OUString("-3.0",4,kEncodingRTLTextUSASCII,
2154 // LLA: kConvertFlagsOStringToOUString) },
2155 // LLA: { "-3.5", -3.5f, new OUString("-3.5",4,kEncodingRTLTextUSASCII,
2156 // LLA: kConvertFlagsOStringToOUString)},
2157 // LLA: { "-3.0625", -3.0625f, new OUString("-3.0625",7,
2158 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)},
2159 // LLA: { "-3.502525", -3.502525f, new OUString("-3.502525",9,
2160 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) },
2161 // LLA: { "-3.141592", -3.141592f, new OUString("-3.141592",9,
2162 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) },
2163 // LLA: { "-3.5025255", -3.5025255f, new OUString("-3.5025255",10,
2164 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) },
2165 // LLA: { "-3.0039062", -3.00390625f, new OUString("-3.0039062",10,
2166 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString) }
2167 // LLA: };
2168 // LLA:
2169 // LLA: sal_Bool res = sal_True;
2170 // LLA: sal_Int32 i;
2171 // LLA:
2172 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2173 // LLA: {
2174 // LLA: ::rtl::OUString aStr1;
2175 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2176 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2177 // LLA:
2178 // LLA: c_rtl_tres_state
2179 // LLA: (
2180 // LLA: hRtlTestResult,
2181 // LLA: lastRes,
2182 // LLA: arrTestCase[i].comments,
2183 // LLA: createName( pMeth, "valueof_negative float", i)
2184 // LLA: );
2185 // LLA:
2186 // LLA: res &= lastRes;
2187 // LLA:
2188 // LLA: }
2189 // LLA:
2190 // LLA: return ( res );
2191 // LLA: }
2193 //------------------------------------------------------------------------
2194 // testing the method valueOf( double f )
2195 //------------------------------------------------------------------------
2196 // LLA: sal_Bool SAL_CALL test_rtl_OUString_valueOf_double(
2197 // LLA: hTestResult hRtlTestResult )
2198 // LLA: {
2199 // LLA: sal_Char methName[MAXBUFLENGTH];
2200 // LLA: sal_Char* pMeth =methName;
2201 // LLA:
2202 // LLA: typedef struct TestCase
2203 // LLA: {
2204 // LLA: sal_Char* comments;
2205 // LLA: double input1;
2206 // LLA: OUString* expVal;
2207 // LLA:
2208 // LLA: ~TestCase() {delete expVal;}
2209 // LLA: } TestCase;
2210 // LLA:
2211 // LLA: TestCase arrTestCase[] =
2212 // LLA: {
2213 // LLA: {"3.0", 3.0, new OUString("3.0",3,kEncodingRTLTextUSASCII,
2214 // LLA: kConvertFlagsOStringToOUString)},
2215 // LLA: {"3.5", 3.5, new OUString("3.5",3,kEncodingRTLTextUSASCII,
2216 // LLA: kConvertFlagsOStringToOUString)},
2217 // LLA: {"3.0625", 3.0625, new OUString("3.0625",6,kEncodingRTLTextUSASCII,
2218 // LLA: kConvertFlagsOStringToOUString)},
2219 // LLA: {"3.1415926535", 3.1415926535, new OUString("3.1415926535",12,
2220 // LLA: kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)},
2221 // LLA: {"3.1415926535897931", 3.141592653589793,
2222 // LLA: new OUString("3.1415926535897931",18,kEncodingRTLTextUSASCII,
2223 // LLA: kConvertFlagsOStringToOUString)},
2224 // LLA: {"3.1415926535897931", 3.1415926535897932,
2225 // LLA: new OUString("3.1415926535897931",18,kEncodingRTLTextUSASCII,
2226 // LLA: kConvertFlagsOStringToOUString)},
2227 // LLA: {"3.1415926535897931", 3.14159265358979323,
2228 // LLA: new OUString("3.1415926535897931",18,kEncodingRTLTextUSASCII,
2229 // LLA: kConvertFlagsOStringToOUString)},
2230 // LLA: {"3.1415926535897931", 3.141592653589793238462643,
2231 // LLA: new OUString("3.1415926535897931",18,kEncodingRTLTextUSASCII,
2232 // LLA: kConvertFlagsOStringToOUString)}
2233 // LLA: };
2234 // LLA:
2235 // LLA: sal_Bool res = sal_True;
2236 // LLA: sal_Int32 i;
2237 // LLA:
2238 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2239 // LLA: {
2240 // LLA: ::rtl::OUString aStr1;
2241 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2242 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2243 // LLA:
2244 // LLA: c_rtl_tres_state
2245 // LLA: (
2246 // LLA: hRtlTestResult,
2247 // LLA: lastRes,
2248 // LLA: arrTestCase[i].comments,
2249 // LLA: createName( pMeth, "valueof_double", i)
2250 // LLA: );
2251 // LLA:
2252 // LLA: res &= lastRes;
2253 // LLA:
2254 // LLA: }
2255 // LLA:
2256 // LLA: return ( res );
2257 // LLA: }
2260 //------------------------------------------------------------------------
2261 // testing the method valueOf( double f ) for negative value
2262 //------------------------------------------------------------------------
2263 // LLA: sal_Bool SAL_CALL test_rtl_OUString_valueOf_Double_Negative(
2264 // LLA: hTestResult hRtlTestResult )
2265 // LLA: {
2266 // LLA: sal_Char methName[MAXBUFLENGTH];
2267 // LLA: sal_Char* pMeth =methName;
2268 // LLA:
2269 // LLA: typedef struct TestCase
2270 // LLA: {
2271 // LLA: sal_Char* comments;
2272 // LLA: double input1;
2273 // LLA: OUString* expVal;
2274 // LLA:
2275 // LLA: ~TestCase() {delete expVal;}
2276 // LLA: } TestCase;
2277 // LLA:
2278 // LLA: TestCase arrTestCase[] =
2279 // LLA: {
2280 // LLA: {"-3.0", -3.0, new OUString("-3.0",4,kEncodingRTLTextUSASCII,
2281 // LLA: kConvertFlagsOStringToOUString)},
2282 // LLA: {"-3.5", -3.5, new OUString("-3.5",4,kEncodingRTLTextUSASCII,
2283 // LLA: kConvertFlagsOStringToOUString)},
2284 // LLA: {"-3.0625", -3.0625, new OUString("-3.0625",7,kEncodingRTLTextUSASCII,
2285 // LLA: kConvertFlagsOStringToOUString)},
2286 // LLA: {"-3.1415926535", -3.1415926535,
2287 // LLA: new OUString("-3.1415926535",13,kEncodingRTLTextUSASCII,
2288 // LLA: kConvertFlagsOStringToOUString)},
2289 // LLA: {"-3.1415926535897931", -3.141592653589793,
2290 // LLA: new OUString("-3.1415926535897931",19,kEncodingRTLTextUSASCII,
2291 // LLA: kConvertFlagsOStringToOUString)},
2292 // LLA: {"-3.1415926535897931", -3.1415926535897932,
2293 // LLA: new OUString("-3.1415926535897931",19,kEncodingRTLTextUSASCII,
2294 // LLA: kConvertFlagsOStringToOUString)},
2295 // LLA: {"-3.1415926535897931", -3.14159265358979323,
2296 // LLA: new OUString("-3.1415926535897931",19,kEncodingRTLTextUSASCII,
2297 // LLA: kConvertFlagsOStringToOUString)},
2298 // LLA: {"-3.1415926535897931", -3.141592653589793238462643,
2299 // LLA: new OUString("-3.1415926535897931",19,kEncodingRTLTextUSASCII,
2300 // LLA: kConvertFlagsOStringToOUString)}
2301 // LLA: };
2302 // LLA:
2303 // LLA: sal_Bool res = sal_True;
2304 // LLA: sal_Int32 i;
2305 // LLA:
2306 // LLA: for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2307 // LLA: {
2308 // LLA: ::rtl::OUString aStr1;
2309 // LLA: aStr1 = aStr1.valueOf( arrTestCase[i].input1 );
2310 // LLA: sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0);
2311 // LLA:
2312 // LLA: c_rtl_tres_state
2313 // LLA: (
2314 // LLA: hRtlTestResult,
2315 // LLA: lastRes,
2316 // LLA: arrTestCase[i].comments,
2317 // LLA: createName( pMeth, "valueof_nagative double", i)
2318 // LLA: );
2319 // LLA:
2320 // LLA: res &= lastRes;
2321 // LLA:
2322 // LLA: }
2323 // LLA:
2324 // LLA: return ( res );
2325 // LLA: }
2327 //------------------------------------------------------------------------
2328 // testing the method valueOf()
2329 //------------------------------------------------------------------------
2330 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_valueOf(
2331 hTestResult hRtlTestResult )
2333 c_rtl_tres_state_start( hRtlTestResult, "valueOf");
2334 sal_Bool bTState = test_rtl_OUString_valueOf_Int32( hRtlTestResult );
2335 bTState &= test_rtl_OUString_valueOf_Int32_Bounderies( hRtlTestResult );
2336 bTState &= test_rtl_OUString_valueOf_Int32_Negative( hRtlTestResult );
2337 bTState &= test_rtl_OUString_valueOf_Int32_WrongRadix( hRtlTestResult );
2338 bTState &= test_rtl_OUString_valueOf_Int32_defaultParam(
2339 hRtlTestResult );
2340 bTState &= test_rtl_OUString_valueOf_Int64( hRtlTestResult );
2341 bTState &= test_rtl_OUString_valueOf_Int64_Bounderies( hRtlTestResult );
2342 bTState &= test_rtl_OUString_valueOf_Int64_Negative( hRtlTestResult );
2343 bTState &= test_rtl_OUString_valueOf_Int64_WrongRadix( hRtlTestResult );
2344 bTState &= test_rtl_OUString_valueOf_Int64_defaultParam(
2345 hRtlTestResult );
2346 // LLA: bTState &= test_rtl_OUString_valueOf_float( hRtlTestResult );
2347 // LLA: bTState &= test_rtl_OUString_valueOf_Float_Negative( hRtlTestResult );
2349 // LLA: bTState &= test_rtl_OUString_valueOf_double( hRtlTestResult );
2350 // LLA: bTState &= test_rtl_OUString_valueOf_Double_Negative( hRtlTestResult );
2351 c_rtl_tres_state_end( hRtlTestResult, "valueOf");
2352 // return ( bTState );
2354 //------------------------------------------------------------------------
2355 // this is my testing code
2356 // testing the method createFromAscii( const sal_Char * value )
2357 //------------------------------------------------------------------------
2359 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_createFromAscii(
2360 hTestResult hRtlTestResult )
2362 c_rtl_tres_state_start( hRtlTestResult, "createFromAscii");
2363 sal_Char methName[MAXBUFLENGTH];
2364 sal_Char* pMeth = methName;
2367 typedef struct TestCase
2369 sal_Char* comments;
2370 const sal_Char* input1;
2371 OUString* expVal;
2372 ~TestCase() {delete expVal;}
2374 }TestCase;
2376 TestCase arrTestCase[]=
2379 { "create OUString from sal_Char" ,kTestStr1,
2380 new OUString(kTestStr1,kTestStr1Len,kEncodingRTLTextUSASCII,
2381 kConvertFlagsOStringToOUString)
2384 "create OUString from empty", "",
2385 new OUString()
2388 "create OUString from empty(string arg = '\\0')","",
2389 new OUString("",0,kEncodingRTLTextUSASCII,
2390 kConvertFlagsOStringToOUString)
2395 sal_Bool res;
2396 sal_uInt32 i;
2398 for(i=0;i<(sizeof(arrTestCase))/(sizeof(TestCase));i++)
2400 sal_Bool lastRes=(*(arrTestCase[i].expVal)==
2401 OUString::createFromAscii(arrTestCase[i].input1));
2405 c_rtl_tres_state(hRtlTestResult,
2406 lastRes,
2407 arrTestCase[i].comments,
2408 createName( pMeth, "createFromAscii", i )
2412 res&=lastRes;
2416 c_rtl_tres_state_end( hRtlTestResult, "createFromAscii");
2417 // return(res);
2419 //------------------------------------------------------------------------
2420 // testing the method index( )
2421 //------------------------------------------------------------------------
2422 template <class T>
2423 sal_Bool test_index( const T* input1, int num,const sal_Int32* input2,
2424 const sal_Int32* expVal,int base,rtlTestResult hRtlTestResult)
2426 sal_Bool res=sal_True;
2427 sal_Char methName[MAXBUFLENGTH];
2428 sal_Char *meth = '\0';
2429 sal_Char* pMeth=methName;
2430 sal_Int32 i;
2431 sal_Bool lastRes=sal_False;
2433 for(i=0;i<num;i++)
2435 OUString str(aUStr2);
2437 if(base==0)
2439 lastRes=(str.indexOf(input1[i])==expVal[i]);
2440 meth="indexOf_001";
2442 if(base==1)
2444 lastRes=(str.indexOf(input1[i],input2[i])==expVal[i]);
2445 meth="indexOf_002";
2447 // LLA: if(base==2)
2448 // LLA: {
2449 // LLA: lastRes=(str.lastIndexOf(input1[i])==expVal[i]);
2450 // LLA: meth="lastIndexOf_001(sal_Unicode)";
2451 // LLA: }
2452 // LLA: if(base==3)
2453 // LLA: {
2454 // LLA: /*
2455 // LLA: OUString s4(&input1[i]);
2456 // LLA: rtl::OString sStr;
2457 // LLA: sStr <<= str;
2458 // LLA: t_print("str = %s\n", sStr.getStr());
2459 // LLA: rtl::OString sInput1;
2460 // LLA: sInput1 <<= s4; // rtl::OUString((sal_Unicode*)input1[i]);
2461 // LLA: t_print("%d = lastIndexOf(\"%s\", %d) =? %d\n", str.lastIndexOf(input1[i], input2[i]), sInput1.getStr(), input2[i], expVal[i]);
2462 // LLA: */
2463 // LLA: lastRes=(str.lastIndexOf(input1[i],input2[i])==expVal[i]);
2464 // LLA: meth="lastIndexOf_002(sal_Unicode , sal_Int32 )";
2465 // LLA: }
2467 c_rtl_tres_state
2469 hRtlTestResult,
2470 lastRes,
2471 "index",
2472 createName( pMeth,meth, i )
2475 res &= lastRes;
2478 return( res );
2480 template <class T>
2481 sal_Bool test_indexStr( const T** input1, int num,const sal_Int32* input2,
2482 const sal_Int32* expVal,int base,rtlTestResult hRtlTestResult)
2484 sal_Bool res=sal_True;
2485 sal_Char methName[MAXBUFLENGTH];
2486 sal_Char *meth = '\0';
2487 sal_Char* pMeth=methName;
2488 sal_Int32 i;
2489 sal_Bool lastRes=sal_False;
2491 for(i=0;i<num;i++)
2493 OUString str(aUStr2);
2496 if(base==0)
2498 OUString s1(input1[i]);
2499 lastRes=(str.indexOf(s1)==expVal[i]);
2500 meth="indexOf_003";
2502 if(base==1)
2504 OUString s2(input1[i]);
2505 lastRes=(str.indexOf(s2,input2[i])==expVal[i]);
2506 meth="indexOf_004";
2508 // LLA: if(base==2)
2509 // LLA: {
2510 // LLA: OUString s3(input1[i]);
2511 // LLA: lastRes=(str.lastIndexOf(s3)==expVal[i]);
2512 // LLA: meth="lastIndexOf_003(const OUString)";
2513 // LLA: }
2514 // LLA: if(base==3)
2515 // LLA: {
2516 // LLA: OUString s4(input1[i]);
2517 // LLA:
2518 // LLA: rtl::OString sStr;
2519 // LLA: sStr <<= str;
2520 // LLA: t_print("str = \"%s\"\n", sStr.getStr());
2521 // LLA: rtl::OString sInput1;
2522 // LLA: sInput1 <<= s4; // rtl::OUString((sal_Unicode*)input1[i]);
2523 // LLA: t_print("%d = lastIndexOf(\"%s\", %d) =? %d\n", str.lastIndexOf(input1[i], input2[i]), sInput1.getStr(), input2[i], expVal[i]);
2524 // LLA:
2525 // LLA: lastRes=(str.lastIndexOf(s4,input2[i])==expVal[i]);
2526 // LLA: meth="lastIndexOf_004(const OUString,sal_Int32)";
2527 // LLA: }
2529 c_rtl_tres_state
2531 hRtlTestResult,
2532 lastRes,
2533 "index",
2534 createName( pMeth,meth, i )
2537 res &= lastRes;
2540 return( res );
2542 //------------------------------------------------------------------------
2543 // testing the method indexOf( )
2544 //------------------------------------------------------------------------
2545 sal_Bool SAL_CALL test_rtl_OUString_indexOf_001(
2546 hTestResult hRtlTestResult )
2548 sal_Bool bRes=sal_False;
2550 bRes=c_rtl_tres_state
2552 hRtlTestResult,
2553 test_index<sal_Unicode>((const sal_Unicode*)input1Default,
2554 nDefaultCount,input2Default,
2555 expValDefault,0,hRtlTestResult),
2556 "index",
2557 "indexDefault(sal_Unicode ch, sal_Int32 fromIndex = 0)"
2560 return ( bRes );
2562 //------------------------------------------------------------------------
2563 // testing the method indexOf( )
2564 //------------------------------------------------------------------------
2565 sal_Bool SAL_CALL test_rtl_OUString_indexOf_002(
2566 hTestResult hRtlTestResult )
2568 sal_Bool bRes=sal_False;
2570 bRes=c_rtl_tres_state
2572 hRtlTestResult,
2573 test_index<sal_Unicode>((const sal_Unicode*)input1Normal,
2574 nNormalCount,input2Normal,
2575 expValNormal,1,hRtlTestResult),
2576 "index",
2577 "indexNormal(sal_Unicode ch, sal_Int32 fromIndex)"
2580 return ( bRes );
2582 //------------------------------------------------------------------------
2583 // testing the method indexOf( OUString ch, sal_Int32 fromIndex = 0 )
2584 //------------------------------------------------------------------------
2585 sal_Bool SAL_CALL test_rtl_OUString_indexOf_003(
2586 hTestResult hRtlTestResult )
2588 sal_Bool bRes=sal_False;
2590 bRes=c_rtl_tres_state
2592 hRtlTestResult,
2593 test_indexStr<sal_Unicode>((const sal_Unicode**)input1StrDefault,
2594 nStrDefaultCount,input2StrDefault,
2595 expValStrDefault,0,hRtlTestResult),
2596 "index",
2597 "indexDefault(OUString ch, sal_Int32 fromIndex = 0)"
2600 return ( bRes );
2602 //------------------------------------------------------------------------
2603 // testing the method indexOf( OUString ch, sal_Int32 fromIndex )
2604 //------------------------------------------------------------------------
2605 sal_Bool SAL_CALL test_rtl_OUString_indexOf_004(
2606 hTestResult hRtlTestResult )
2608 sal_Bool bRes=sal_False;
2610 bRes=c_rtl_tres_state
2612 hRtlTestResult,
2613 test_indexStr<sal_Unicode>((const sal_Unicode**)input1StrNormal,
2614 nStrNormalCount,input2StrNormal,
2615 expValStrNormal,1,hRtlTestResult),
2616 "indexOf",
2617 "indexOf(OUString ch, sal_Int32 fromIndex)"
2620 return ( bRes );
2622 // LLA: //------------------------------------------------------------------------
2623 // LLA: // testing the method lastIndexOf( sal_Unicode ch )
2624 // LLA: //------------------------------------------------------------------------
2625 // LLA: sal_Bool SAL_CALL test_rtl_OUString_lastIndexOf_001(
2626 // LLA: hTestResult hRtlTestResult )
2627 // LLA: {
2628 // LLA: sal_Bool bRes=sal_False;
2629 // LLA:
2630 // LLA: bRes=c_rtl_tres_state
2631 // LLA: (
2632 // LLA: hRtlTestResult,
2633 // LLA: test_index<sal_Unicode>((const sal_Unicode*)input1lastDefault,
2634 // LLA: nlastDefaultCount,input2lastDefault,
2635 // LLA: expVallastDefault,2,hRtlTestResult),
2636 // LLA: "lastIndex",
2637 // LLA: "lastIndexDefault(sal_Unicode ch)"
2638 // LLA: );
2639 // LLA:
2640 // LLA: return ( bRes );
2641 // LLA: }
2642 // LLA: //------------------------------------------------------------------------
2643 // LLA: // testing the method lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex )
2644 // LLA: //------------------------------------------------------------------------
2645 // LLA: sal_Bool SAL_CALL test_rtl_OUString_lastIndexOf_002(
2646 // LLA: hTestResult hRtlTestResult )
2647 // LLA: {
2648 // LLA: sal_Bool bRes=sal_False;
2649 // LLA:
2650 // LLA: bRes=c_rtl_tres_state
2651 // LLA: (
2652 // LLA: hRtlTestResult,
2653 // LLA: test_index<sal_Unicode>((const sal_Unicode*)input1lastNormal,
2654 // LLA: nlastNormalCount,input2lastNormal,
2655 // LLA: expVallastNormal,3,hRtlTestResult),
2656 // LLA: "lastIndex",
2657 // LLA: "lastIndexNormal(sal_Unicode ch, sal_Int32 fromIndex)"
2658 // LLA: );
2659 // LLA:
2660 // LLA: return ( bRes );
2661 // LLA: }
2662 // LLA: //------------------------------------------------------------------------
2663 // LLA: // testing the method lastIndexOf( OUString ch )
2664 // LLA: //------------------------------------------------------------------------
2665 // LLA: sal_Bool SAL_CALL test_rtl_OUString_lastIndexOf_003(
2666 // LLA: hTestResult hRtlTestResult )
2667 // LLA: {
2668 // LLA: sal_Bool bRes=sal_False;
2669 // LLA:
2670 // LLA: bRes=c_rtl_tres_state
2671 // LLA: (
2672 // LLA: hRtlTestResult,
2673 // LLA: test_indexStr<sal_Unicode>((const sal_Unicode**)input1StrLastDefault,
2674 // LLA: nStrLastDefaultCount,input2StrLastDefault,
2675 // LLA: expValStrLastDefault,2,hRtlTestResult),
2676 // LLA: "lastIndexOf",
2677 // LLA: "lastIndexOf(OUString ch)"
2678 // LLA: );
2679 // LLA:
2680 // LLA: return ( bRes );
2681 // LLA: }
2682 // LLA: //------------------------------------------------------------------------
2683 // LLA: // testing the method lastIndexOf( OUString ch, sal_Int32 fromIndex )
2684 // LLA: //------------------------------------------------------------------------
2685 // LLA: sal_Bool SAL_CALL test_rtl_OUString_lastIndexOf_004(
2686 // LLA: hTestResult hRtlTestResult )
2687 // LLA: {
2688 // LLA: sal_Bool bRes=sal_False;
2689 // LLA:
2690 // LLA: for (int i=0;i<nStrLastNormalCount;i++)
2691 // LLA: {
2692 // LLA: rtl::OUString aStr = rtl::OUString(input1StrLastNormal[i]);
2693 // LLA: volatile int dummy = 0;
2694 // LLA: }
2695 // LLA:
2696 // LLA: bRes=c_rtl_tres_state
2697 // LLA: (
2698 // LLA: hRtlTestResult,
2699 // LLA: test_indexStr<sal_Unicode>((const sal_Unicode**)input1StrLastNormal,
2700 // LLA: nStrLastNormalCount,input2StrLastNormal,
2701 // LLA: expValStrLastNormal,3,hRtlTestResult),
2702 // LLA: "lastIndexOf",
2703 // LLA: "lastIndexOf(OUString ch, sal_Int32 fromIndex)"
2704 // LLA: );
2705 // LLA:
2706 // LLA: return ( bRes );
2707 // LLA: }
2708 //------------------------------------------------------------------------
2709 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_indexOf(
2710 hTestResult hRtlTestResult )
2712 c_rtl_tres_state_start( hRtlTestResult, "indexOf");
2713 sal_Bool res = test_rtl_OUString_indexOf_001(hRtlTestResult);
2714 res &= test_rtl_OUString_indexOf_002(hRtlTestResult);
2715 res &= test_rtl_OUString_indexOf_003(hRtlTestResult);
2716 res &= test_rtl_OUString_indexOf_004(hRtlTestResult);
2717 c_rtl_tres_state_end( hRtlTestResult, "indexOf");
2718 // return ( res );
2720 //------------------------------------------------------------------------
2721 // LLA: extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_lastIndexOf(
2722 // LLA: hTestResult hRtlTestResult )
2723 // LLA: {
2724 // LLA: c_rtl_tres_state_start( hRtlTestResult, "lastIndexOf");
2725 // LLA: sal_Bool res = test_rtl_OUString_lastIndexOf_001(hRtlTestResult);
2726 // LLA: res &= test_rtl_OUString_lastIndexOf_002(hRtlTestResult);
2727 // LLA: res &= test_rtl_OUString_lastIndexOf_003(hRtlTestResult);
2728 // LLA: res &= test_rtl_OUString_lastIndexOf_004(hRtlTestResult);
2729 // LLA: c_rtl_tres_state_end( hRtlTestResult, "lastIndexOf");
2730 // LLA: // return ( res );
2731 // LLA: }
2732 //------------------------------------------------------------------------
2733 // testing the method concat( const OString & aStr )
2734 //------------------------------------------------------------------------
2735 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_concat(
2736 hTestResult hRtlTestResult )
2738 c_rtl_tres_state_start( hRtlTestResult, "concat");
2739 sal_Char methName[MAXBUFLENGTH];
2740 sal_Char* pMeth =methName;
2742 typedef struct TestCase
2744 sal_Char* comments;
2745 OUString* expVal;
2746 OUString* input1;
2747 OUString* input2;
2748 ~TestCase() { delete input1;delete input2; delete expVal;}
2749 } TestCase;
2751 TestCase arrTestCase[] =
2753 {"concatenates two ustrings",new OUString(aUStr1),
2754 new OUString(aUStr7), new OUString(aUStr8)},
2755 {"concatenates empty ustring",new OUString(aUStr1),
2756 new OUString(aUStr1), new OUString("",0,
2757 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)},
2758 {"concatenates to empty ustring",new OUString(aUStr1),new OUString("",
2759 0,kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2760 new OUString(aUStr1)},
2761 {"concatenates two empty ustrings",new OUString("",0,
2762 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2763 new OUString("",0,
2764 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2765 new OUString("",0,
2766 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)},
2767 {"concatenates ustring constructed by default constructor",
2768 new OUString(aUStr1),new OUString(aUStr1), new OUString()},
2769 {"concatenates to ustring constructed by default constructor",
2770 new OUString(aUStr1),new OUString(), new OUString(aUStr1)},
2771 {"concatenates two ustrings constructed by default constructor",
2772 new OUString(),new OUString(), new OUString()}
2775 sal_Bool res = sal_True;
2776 sal_uInt32 i;
2777 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2779 OUString str = arrTestCase[i].input1->concat(*arrTestCase[i].input2);
2780 sal_Bool lastRes = (str == *arrTestCase[i].expVal);
2782 c_rtl_tres_state
2784 hRtlTestResult,
2785 lastRes,
2786 arrTestCase[i].comments,
2787 createName( pMeth, "concat", i)
2790 res &= lastRes;
2793 c_rtl_tres_state_end( hRtlTestResult, "concat");
2794 // return ( res );
2796 //------------------------------------------------------------------------
2797 // testing the method replaceAt( sal_Int32 index, sal_Int32 count,
2798 // const OUString& newStr )
2799 //------------------------------------------------------------------------
2800 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_replaceAt(
2801 rtlTestResult hRtlTestResult)
2803 c_rtl_tres_state_start( hRtlTestResult, "replaceAt");
2804 sal_Char methName[MAXBUFLENGTH];
2805 sal_Char* pMeth = methName;
2807 typedef struct TestCase
2809 sal_Char* comments;
2810 OUString* expVal;
2811 OUString* input;
2812 OUString* newStr;
2813 sal_Int32 index;
2814 sal_Int32 count;
2816 ~TestCase() { delete input; delete expVal; delete newStr;}
2817 } TestCase;
2819 TestCase arrTestCase[]=
2822 { "string differs", new OUString(aUStr2), new OUString(aUStr22),
2823 new OUString(aUStr2), 0, kTestStr22Len },
2825 { "larger index", new OUString(aUStr1), new OUString(aUStr7),
2826 new OUString(aUStr8), 64, kTestStr8Len },
2828 { "larger count", new OUString(aUStr2), new OUString(aUStr22),
2829 new OUString(aUStr2),0, 64 },
2831 { "navigate index", new OUString(aUStr2), new OUString(aUStr22),
2832 new OUString(aUStr2), -64, 64 },
2834 { "null ustring",
2835 new OUString("",0,
2836 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2837 new OUString(aUStr14),
2838 new OUString("",0,
2839 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2840 0, kTestStr14Len }
2843 sal_Bool res = sal_True;
2844 sal_uInt32 i;
2846 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2848 ::rtl::OUString aStr1;
2849 aStr1 = arrTestCase[i].input->replaceAt( arrTestCase[i].index,
2850 arrTestCase[i].count, *arrTestCase[i].newStr );
2852 sal_Bool lastRes = ( arrTestCase[i].expVal->compareTo(aStr1) == 0 );
2854 c_rtl_tres_state
2856 hRtlTestResult,
2857 lastRes,
2858 arrTestCase[i].comments,
2859 createName( pMeth, "replaceAt", i )
2862 res &= lastRes;
2865 c_rtl_tres_state_end( hRtlTestResult, "replaceAt");
2866 // return ( res );
2868 //------------------------------------------------------------------------
2869 // this is my testing code
2870 // testing the method replace( sal_Unicode oldChar, sal_Unicode newChar )
2871 //------------------------------------------------------------------------
2872 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_replace(
2873 hTestResult hRtlTestResult)
2875 c_rtl_tres_state_start( hRtlTestResult, "replace");
2876 sal_Char methName[MAXBUFLENGTH];
2877 sal_Char* pMeth = methName;
2879 typedef struct TestCase
2881 sal_Char* comments;
2882 OUString* expVal;
2883 OUString* input;
2884 sal_Unicode oldChar;
2885 sal_Unicode newChar;
2887 ~TestCase() { delete input; delete expVal;}
2888 } TestCase;
2890 TestCase arrTestCase[]=
2892 {"ustring differs", new OUString(aUStr18), new OUString(aUStr4),83,115},
2893 {"ustring differs", new OUString(aUStr19), new OUString(aUStr17),32,45},
2894 {"ustring must be empty", new OUString("",0,
2895 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2896 new OUString("",0,
2897 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),83,23},
2898 {"ustring must be empty", new OUString(),
2899 new OUString("",0,
2900 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),83,23},
2901 {"same ustring, no replace ", new OUString(aUStr22),
2902 new OUString(aUStr22),42,56}
2906 sal_Bool res = sal_True;
2907 sal_uInt32 i;
2909 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2911 ::rtl::OUString aStr1;
2912 aStr1= arrTestCase[i].input->replace(arrTestCase[i].oldChar,arrTestCase[i].newChar);
2913 res &= c_rtl_tres_state
2915 hRtlTestResult,
2916 (arrTestCase[i].expVal->compareTo(aStr1) == 0),
2917 arrTestCase[i].comments,
2918 createName( pMeth, "replace", i )
2922 c_rtl_tres_state_end( hRtlTestResult, "replace");
2923 // return ( res );
2925 //------------------------------------------------------------------------
2926 // testing the method toAsciiLowerCase()
2927 //-----------------------------------------------------------------------
2928 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toAsciiLowerCase(
2929 hTestResult hRtlTestResult )
2931 c_rtl_tres_state_start( hRtlTestResult, "toAsciiLowerCase");
2932 sal_Char methName[MAXBUFLENGTH];
2933 sal_Char* pMeth =methName;
2935 typedef struct TestCase
2937 sal_Char* comments;
2938 OUString* expVal;
2939 OUString* input1;
2940 ~TestCase() { delete input1; delete expVal;}
2941 } TestCase;
2943 TestCase arrTestCase[] =
2946 {"only uppercase",new OUString(aUStr5),new OUString(aUStr4)},
2947 {"different cases",new OUString(aUStr5),new OUString(aUStr1)},
2948 {"different cases",new OUString(aUStr5),new OUString(aUStr3)},
2949 {"only lowercase",new OUString(aUStr5),new OUString(aUStr5)},
2950 {"empty ustring",new OUString("",0,
2951 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2952 new OUString("",0,
2953 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)},
2954 {"ustring constructed by default constructor",new OUString(),
2955 new OUString()},
2956 {"have special Unicode",new OUString("\23\12\34sun\13\45",6,
2957 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
2958 new OUString("\23\12\34sun\13\45",6,
2959 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)}
2962 sal_Bool res = sal_True;
2963 sal_uInt32 i;
2964 sal_Bool lastRes=sal_False;
2966 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
2968 OUString str = arrTestCase[i].input1->toAsciiLowerCase();
2969 if(i<=5)
2971 lastRes = (str ==* arrTestCase[i].expVal);
2973 c_rtl_tres_state
2975 hRtlTestResult,
2976 lastRes,
2977 arrTestCase[i].comments,
2978 createName( pMeth, "toAsciiLowerCase", i)
2981 else
2983 c_rtl_tres_state
2985 hRtlTestResult,
2986 sal_True,
2987 arrTestCase[i].comments,
2988 createName( pMeth, "toAsciiLowerCase", i)
2991 res &= lastRes;
2993 c_rtl_tres_state_end( hRtlTestResult, "toAsciiLowerCase");
2994 // return ( res );
2996 //------------------------------------------------------------------------
2997 // testing the method toAsciiUpperCase()
2998 //------------------------------------------------------------------------
2999 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toAsciiUpperCase(
3000 hTestResult hRtlTestResult )
3002 c_rtl_tres_state_start( hRtlTestResult, "toAsciiUpperCase");
3003 sal_Char methName[MAXBUFLENGTH];
3004 sal_Char* pMeth =methName;
3006 typedef struct TestCase
3008 sal_Char* comments;
3009 OUString* expVal;
3010 OUString* input1;
3011 ~TestCase() { delete input1; delete expVal;}
3012 } TestCase;
3014 TestCase arrTestCase[] =
3016 {"only lowercase",new OUString(aUStr4),new OUString(aUStr5)},
3017 {"mixed cases",new OUString(aUStr4),new OUString(aUStr3)},
3018 {"mixed cases",new OUString(aUStr4),new OUString(aUStr1)},
3019 {"only uppercase",new OUString(aUStr4),new OUString(aUStr4)},
3020 {"empty ustring",new OUString("",0,
3021 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
3022 new OUString("",0,
3023 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)},
3024 {"ustring constructed by default constructor",new OUString(),
3025 new OUString()},
3026 {"have special Unicode",new OUString("\23\12\34SUN\13\45",6,
3027 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString),
3028 new OUString("\23\12\34sun\13\45",6,
3029 kEncodingRTLTextUSASCII,kConvertFlagsOStringToOUString)}
3032 sal_Bool res = sal_True;
3033 sal_uInt32 i;
3034 sal_Bool lastRes=sal_False;
3036 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3038 OUString str = arrTestCase[i].input1->toAsciiUpperCase();
3039 if(i<=5)
3041 lastRes = (str == *arrTestCase[i].expVal);
3043 c_rtl_tres_state
3045 hRtlTestResult,
3046 lastRes,
3047 arrTestCase[i].comments,
3048 createName( pMeth, "toAsciiUpperCase", i)
3051 else
3053 c_rtl_tres_state
3055 hRtlTestResult,
3056 sal_True,
3057 arrTestCase[i].comments,
3058 createName( pMeth, "toAsciiUpperCase", i)
3062 res &= lastRes;
3064 c_rtl_tres_state_end( hRtlTestResult, "toAsciiUpperCase");
3065 // return ( res );
3068 //------------------------------------------------------------------------
3069 // testing the method trim()
3070 //------------------------------------------------------------------------
3071 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_trim(
3072 hTestResult hRtlTestResult )
3074 c_rtl_tres_state_start( hRtlTestResult, "trim");
3075 sal_Char methName[MAXBUFLENGTH];
3076 sal_Char* pMeth =methName;
3078 typedef struct TestCase
3080 sal_Char* comments;
3081 OUString* expVal;
3082 OUString* input1;
3083 ~TestCase() { delete input1; delete expVal;}
3084 } TestCase;
3086 TestCase arrTestCase[] =
3088 {"removes space from the front",new OUString(aUStr1),
3089 new OUString(aUStr10)},
3090 {"removes space from the end",new OUString(aUStr1),
3091 new OUString(aUStr11)},
3092 {"removes space from the front and end",new OUString(aUStr1),
3093 new OUString(aUStr12)},
3094 {"removes several spaces from the end",new OUString(aUStr1),
3095 new OUString(aUStr13)},
3096 {"removes several spaces from the front",new OUString(aUStr1),
3097 new OUString(aUStr14)},
3098 {"removes several spaces from the front and one from the end",
3099 new OUString(aUStr1),
3100 new OUString(aUStr15)},
3101 {"removes one space from the front and several from the end",
3102 new OUString(aUStr1),
3103 new OUString(aUStr16)},
3104 {"removes several spaces from the front and end",
3105 new OUString(aUStr1),
3106 new OUString(aUStr17)},
3107 {"removes characters that have codes <= 32",new OUString(aUStr30),
3108 new OUString("\1\3\5\7\11\13\15\17sun\21\23\25\27\31\33\50",
3109 18,kEncodingRTLTextUSASCII,
3110 kConvertFlagsOStringToOUString)},
3111 {"removes characters that have codes <= 32",new OUString(aUStr28),
3112 new OUString("\50\3\5\7\11\13\15\17sun\21\23\25\27\31\33\1",
3113 18,kEncodingRTLTextUSASCII,
3114 kConvertFlagsOStringToOUString)},
3115 {"removes characters that have codes <= 32",new OUString(aUStr29),
3116 new OUString("\50\3\5\7\11\13\15\17sun\21\23\25\27\31\33\50",
3117 18,kEncodingRTLTextUSASCII,
3118 kConvertFlagsOStringToOUString)},
3119 {"removes characters that have codes <= 32",new OUString(aUStr20),
3120 new OUString("\1\3\5\7\11\13\15\17sun\21\23\25\27\31\23\20",
3121 18,kEncodingRTLTextUSASCII,
3122 kConvertFlagsOStringToOUString)},
3123 {"no spaces",new OUString(aUStr8),
3124 new OUString(aUStr8)}
3127 sal_Bool res = sal_True;
3128 sal_uInt32 i;
3130 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3132 OUString strRes = arrTestCase[i].input1->trim();
3133 sal_Bool lastRes = (strRes == *arrTestCase[i].expVal);
3135 c_rtl_tres_state
3137 hRtlTestResult,
3138 lastRes,
3139 arrTestCase[i].comments,
3140 createName( pMeth, "trim", i)
3143 res &= lastRes;
3146 c_rtl_tres_state_end( hRtlTestResult, "trim");
3147 // return ( res );
3149 //------------------------------------------------------------------------
3150 // testing the method toData()
3151 //------------------------------------------------------------------------
3153 template <class T>
3154 sal_Bool test_toData( const char** input, int num, sal_Int16 radix,
3155 const T* expVal,int base,
3156 const T* _fPrecision,
3157 rtlTestResult hRtlTestResult)
3159 (void)_fPrecision;
3160 sal_Bool res=sal_True;
3161 sal_Char methName[MAXBUFLENGTH];
3162 sal_Char *meth = '\0';
3163 sal_Char* pMeth=methName;
3164 sal_Int32 i;
3165 // static sal_Unicode aUchar[60]={0x00};
3166 T intRes;
3167 sal_Bool lastRes=sal_False;
3169 for(i=0;i<num;i++)
3171 OSL_ENSURE( i < 60, "ERROR: leave aUchar bound");
3173 // LLA: stored for the posterity
3174 // AStringToUStringCopy(aUchar,input[i]);
3175 // OUString str(aUchar);
3177 OUString str;
3178 str = OUString::createFromAscii(input[i]);
3181 if(base==0)
3183 intRes=static_cast<T>(str.toInt32());
3184 lastRes=(intRes==expVal[i]);
3185 meth="toInt32default";
3187 if(base==1)
3189 intRes=static_cast<T>(str.toInt32(radix));
3190 lastRes=(intRes==expVal[i]);
3191 meth="toInt32normal";
3193 if(base==2)
3195 intRes=static_cast<T>(str.toInt64());
3196 lastRes=(intRes==expVal[i]);
3197 meth="toInt64default";
3199 if(base==3)
3201 intRes=static_cast<T>(str.toInt64(radix));
3202 lastRes=(intRes==expVal[i]);
3203 meth="toInt64normal";
3205 // LLA: does no longer exist, moved to rtl/oustring
3206 // LLA: if(base==4)
3207 // LLA: {
3208 // LLA: intRes=str.toDouble();
3209 // LLA: lastRes=(fabs(intRes-expVal[i])<=1e-35);
3210 // LLA: meth="toDouble";
3211 // LLA: }
3213 // LLA: dt:20040802 create compile problems within wntmsci10
3214 // if(base==5)
3215 // {
3216 // intRes=str.toFloat();
3217 // T nPrec = _fPrecision[i];
3218 // lastRes=(fabs((T)(intRes-expVal[i])) <= nPrec /* 1e-35 */ );
3219 // meth="toFloat";
3220 // }
3221 if(base==6)
3223 intRes=str.toChar();
3224 lastRes=(intRes==expVal[i]);
3225 meth="toChar";
3228 char buf[MAXBUFLENGTH];
3229 buf[0] = '\'';
3230 cpynstr( buf + 1, input[i], MAXBUFLENGTH );
3231 int length = AStringLen( input[i] );
3232 buf[length + 1] = '\'';
3233 buf[length + 2] = 0;
3235 c_rtl_tres_state
3237 hRtlTestResult,
3238 lastRes,
3239 buf,
3240 createName( pMeth,meth, i )
3243 res &= lastRes;
3246 return( res );
3248 //------------------------------------------------------------------------
3249 // testing the method toDouble()
3250 //------------------------------------------------------------------------
3252 // LLA: extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toDouble(
3253 // LLA: hTestResult hRtlTestResult )
3254 // LLA: {
3255 // LLA: c_rtl_tres_state_start( hRtlTestResult, "toDouble");
3256 // LLA: sal_Bool bRes=sal_False;
3257 // LLA:
3258 // LLA: bRes=c_rtl_tres_state
3259 // LLA: (
3260 // LLA: hRtlTestResult,
3261 // LLA: test_toData<double>((const char**)inputDouble,nDoubleCount,10,
3262 // LLA: expValDouble,4,hRtlTestResult),
3263 // LLA: "toDouble",
3264 // LLA: "toDouble()"
3265 // LLA: );
3266 // LLA: c_rtl_tres_state_end( hRtlTestResult, "toDouble");
3267 // LLA: // return ( bRes );
3268 // LLA: }
3270 //------------------------------------------------------------------------
3271 // testing the method toFloat()
3272 //------------------------------------------------------------------------
3273 // LLA: dt:20040802 the test_toData() has compile problems.
3274 // LLA: extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toFloat(
3275 // LLA: hTestResult hRtlTestResult )
3276 // LLA: {
3277 // LLA: c_rtl_tres_state_start( hRtlTestResult, "toFloat");
3278 // LLA: sal_Bool bRes=sal_False;
3279 // LLA:
3280 // LLA: bRes=c_rtl_tres_state
3281 // LLA: (
3282 // LLA: hRtlTestResult,
3283 // LLA: test_toData<float>((const char**)inputFloat,
3284 // LLA: nFloatCount,
3285 // LLA: 10, /* radix */
3286 // LLA: expValFloat,
3287 // LLA: 5, /* float */
3288 // LLA: fPrecision,
3289 // LLA: hRtlTestResult),
3290 // LLA: "toFloat",
3291 // LLA: "toFloat()"
3292 // LLA: );
3293 // LLA:
3294 // LLA: c_rtl_tres_state_end( hRtlTestResult, "toFloat");
3295 // LLA: // return ( bRes );
3296 // LLA:
3297 // LLA: }
3298 //------------------------------------------------------------------------
3299 // testing the method toChar()
3300 //------------------------------------------------------------------------
3301 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toChar(
3302 hTestResult hRtlTestResult )
3304 c_rtl_tres_state_start( hRtlTestResult, "toChar");
3305 sal_Bool bRes=sal_False;
3307 bRes=c_rtl_tres_state
3309 hRtlTestResult,
3310 test_toData<sal_Unicode>((const char**)inputChar,nCharCount,
3311 10,expValChar,6,NULL,hRtlTestResult),
3312 "toChar",
3313 "toChar()"
3316 c_rtl_tres_state_end( hRtlTestResult, "toChar");
3317 // return ( bRes );
3320 //------------------------------------------------------------------------
3321 // testing the method toBoolean()
3322 //------------------------------------------------------------------------
3323 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toBoolean(
3324 hTestResult hRtlTestResult)
3326 c_rtl_tres_state_start( hRtlTestResult, "toBoolean");
3327 sal_Char methName[MAXBUFLENGTH];
3328 sal_Char* pMeth = methName;
3330 typedef struct TestCase
3332 sal_Char* comments;
3333 sal_Bool expVal;
3334 OUString* input;
3336 ~TestCase() {delete input;}
3337 }TestCase;
3339 TestCase arrTestCase[]={
3341 {"expected true", sal_True, new OUString("True",4,kEncodingRTLTextUSASCII,
3342 kConvertFlagsOStringToOUString)},
3343 {"expected false", sal_False, new OUString("False",5,
3344 kEncodingRTLTextUSASCII,
3345 kConvertFlagsOStringToOUString)},
3346 {"expected true", sal_True, new OUString("1",1,kEncodingRTLTextUSASCII,
3347 kConvertFlagsOStringToOUString)}
3350 sal_Bool res = sal_True;
3351 sal_uInt32 i;
3353 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
3355 sal_Bool bRes = arrTestCase[i].input->toBoolean();
3356 sal_Bool lastRes = (bRes == arrTestCase[i].expVal);
3357 c_rtl_tres_state
3359 hRtlTestResult,
3360 lastRes,
3361 arrTestCase[i].comments,
3362 createName( pMeth, "toBoolean", i )
3365 res &= lastRes;
3367 c_rtl_tres_state_end( hRtlTestResult, "toBoolean");
3368 // return ( res );
3370 //------------------------------------------------------------------------
3371 // testing the method toInt32()
3372 //------------------------------------------------------------------------
3374 sal_Bool SAL_CALL test_rtl_OUString_toInt32_normal(
3375 hTestResult hRtlTestResult )
3377 sal_Int32 expValues[kBase36NumsCount];
3378 sal_Int32 i;
3380 for ( i = 0; i < kBase36NumsCount; i++ )
3381 expValues[i] = i;
3383 sal_Bool res = c_rtl_tres_state
3385 hRtlTestResult,
3386 test_toData<sal_Int32>( kBinaryNumsStr,kBinaryNumsCount,
3387 kRadixBinary,expValues,1,NULL,hRtlTestResult ),
3388 "kBinaryNumsStr",
3389 "toInt32( radix 2 )"
3391 res &= c_rtl_tres_state
3393 hRtlTestResult,
3394 test_toData<sal_Int32>( kBinaryMaxNumsStr,kInt32MaxNumsCount,
3395 kRadixBinary,kInt32MaxNums,1,NULL,hRtlTestResult ),
3396 "kBinaryMaxNumsStr",
3397 "toInt32_Boundaries( radix 2 )"
3400 res &= c_rtl_tres_state
3402 hRtlTestResult,
3403 test_toData<sal_Int32>( kOctolNumsStr,kOctolNumsCount,
3404 kRadixOctol,expValues,1,NULL,hRtlTestResult ),
3405 "kOctolNumsStr",
3406 "toInt32( radix 8 )"
3409 res &= c_rtl_tres_state
3411 hRtlTestResult,
3412 test_toData<sal_Int32>( kOctolMaxNumsStr,kInt32MaxNumsCount,
3413 kRadixOctol,(sal_Int32*)kInt32MaxNums,1,NULL,hRtlTestResult ),
3414 "kOctolMaxNumsStr",
3415 "toInt32_Boundaries( radix 8 )"
3418 res &= c_rtl_tres_state
3420 hRtlTestResult,
3421 test_toData<sal_Int32>( kDecimalNumsStr,kDecimalNumsCount,
3422 kRadixDecimal,expValues,1,NULL,hRtlTestResult ),
3423 "kDecimalNumsStr",
3424 "toInt32( radix 10 )"
3427 res &= c_rtl_tres_state
3429 hRtlTestResult,
3430 test_toData<sal_Int32>( kDecimalMaxNumsStr,kInt32MaxNumsCount,
3431 kRadixDecimal,(sal_Int32*)kInt32MaxNums,1,NULL,hRtlTestResult ),
3432 "kDecimalMaxNumsStr",
3433 "toInt32_Boundaries( radix 10 )"
3436 res &= c_rtl_tres_state
3438 hRtlTestResult,
3439 test_toData<sal_Int32>( kHexDecimalNumsStr,kHexDecimalNumsCount,
3440 kRadixHexdecimal,expValues,1,NULL,hRtlTestResult ),
3441 "kHexDecimalNumsStr",
3442 "toInt32( radix 16 )"
3445 res &= c_rtl_tres_state
3447 hRtlTestResult,
3448 test_toData<sal_Int32>( kHexDecimalMaxNumsStr,kInt32MaxNumsCount,
3449 kRadixHexdecimal,(sal_Int32*)kInt32MaxNums,1,NULL,hRtlTestResult ),
3450 "kHexDecimalMaxNumsStr",
3451 "toInt32_Boundaries( radix 16 )"
3454 res &= c_rtl_tres_state
3456 hRtlTestResult,
3457 test_toData<sal_Int32>( kBase36NumsStr,kBase36NumsCount,
3458 kRadixBase36, expValues,1,NULL,hRtlTestResult ),
3459 "kBase36NumsStr",
3460 "toInt32( radix 36 )"
3463 res &= c_rtl_tres_state
3465 hRtlTestResult,
3466 test_toData<sal_Int32>( kBase36MaxNumsStr,kInt32MaxNumsCount,
3467 kRadixBase36,(sal_Int32*)kInt32MaxNums,1,NULL,hRtlTestResult ),
3468 "kBase36MaxNumsStr",
3469 "toInt32_Boundaries( radix 36 )"
3472 const sal_Int16 nSpecCases = 5;
3473 static const sal_Char *spString[nSpecCases] =
3475 "-1",
3476 "+1",
3477 " 1",
3478 " -1",
3479 "001"
3482 sal_Int32 expSpecVal[nSpecCases] =
3491 res &= c_rtl_tres_state
3493 hRtlTestResult,
3494 test_toData<sal_Int32>( spString,nSpecCases,
3495 kRadixDecimal,expSpecVal,1,NULL,hRtlTestResult ),
3496 "special cases",
3497 "toInt32( specialcases )"
3500 return ( res );
3502 sal_Bool SAL_CALL test_rtl_OUString_toInt32_wrongRadix(
3503 hTestResult hRtlTestResult )
3505 ::rtl::OUString str("0",1,kEncodingRTLTextUSASCII,
3506 kConvertFlagsOStringToOUString);
3508 sal_Int32 iRes =str.toInt32(-1);
3510 return
3512 c_rtl_tres_state
3514 hRtlTestResult,
3515 iRes == 0,
3516 "wrong radix -1",
3517 "toInt32( 0, wrong radix -1 )"
3521 sal_Bool SAL_CALL test_rtl_OUString_toInt32_defaultParam(
3522 hTestResult hRtlTestResult )
3524 sal_Int32 expValues[kBase36NumsCount];
3525 sal_Int32 i;
3527 for ( i = 0; i < kBase36NumsCount; i++ )
3528 expValues[i] = i;
3530 sal_Bool res = c_rtl_tres_state
3532 hRtlTestResult,
3533 test_toData<sal_Int32>( kDecimalNumsStr,kDecimalNumsCount,
3534 kRadixDecimal,expValues,0,NULL,hRtlTestResult ),
3535 "kBinaryNumsStr",
3536 "toInt32( radix 2 )"
3538 res &= c_rtl_tres_state
3540 hRtlTestResult,
3541 test_toData<sal_Int32>( kDecimalMaxNumsStr,kInt32MaxNumsCount,
3542 kRadixDecimal,(sal_Int32*)kInt32MaxNums,0,NULL,hRtlTestResult ),
3543 "kDecimalMaxNumsStr",
3544 "toInt32_Boundaries( radix 10 )"
3546 const sal_Int16 nSpecCases = 5;
3547 static const sal_Char *spString[nSpecCases] =
3549 "-1",
3550 "+1",
3551 " 1",
3552 " -1",
3553 "001"
3556 sal_Int32 expSpecVal[nSpecCases] =
3565 res &= c_rtl_tres_state
3567 hRtlTestResult,
3568 test_toData<sal_Int32>( spString,nSpecCases,
3569 kRadixDecimal,expSpecVal,0,NULL,hRtlTestResult ),
3570 "special cases",
3571 "toInt32( specialcases )"
3574 return ( res );
3577 //------------------------------------------------------------------------
3578 // testing the method toInt32()
3579 //------------------------------------------------------------------------
3580 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toInt32(
3581 hTestResult hRtlTestResult )
3583 c_rtl_tres_state_start( hRtlTestResult, "toInt32");
3584 sal_Bool bTState = test_rtl_OUString_toInt32_normal( hRtlTestResult );
3585 bTState &= test_rtl_OUString_toInt32_defaultParam( hRtlTestResult );
3586 bTState &= test_rtl_OUString_toInt32_wrongRadix( hRtlTestResult );
3587 c_rtl_tres_state_end( hRtlTestResult, "toInt32");
3588 // return ( bTState );
3590 //------------------------------------------------------------------------
3591 // testing the method toInt64( sal_Int16 radix = 2,8,10,16,36 )
3592 //------------------------------------------------------------------------
3594 sal_Bool SAL_CALL test_rtl_OUString_toInt64_normal(
3595 hTestResult hRtlTestResult )
3597 sal_Int64 expValues[kBase36NumsCount];
3598 sal_Int32 i;
3600 for (i = 0; i < kBase36NumsCount; expValues[i] = i, i++);
3602 sal_Bool res = c_rtl_tres_state
3604 hRtlTestResult,
3605 test_toData<sal_Int64>( kBinaryNumsStr,kBinaryNumsCount,
3606 kRadixBinary,expValues,3,NULL,hRtlTestResult ),
3607 "kBinaryNumsStr",
3608 "toInt64( radix 2 )"
3611 /* LLA: does not work within wntmsci8.pro
3612 res &= c_rtl_tres_state
3614 hRtlTestResult,
3615 test_toData<sal_Int64>( kBinaryMaxNumsStr,kInt64MaxNumsCount,
3616 kRadixBinary,kInt64MaxNums,3,hRtlTestResult ),
3617 "kBinaryMaxNumsStr",
3618 "toInt64_Boundaries( radix 2 )"
3622 res &= c_rtl_tres_state
3624 hRtlTestResult,
3625 test_toData<sal_Int64>( kOctolNumsStr,kOctolNumsCount,
3626 kRadixOctol,expValues,3,NULL,hRtlTestResult ),
3627 "kOctolNumsStr",
3628 "toInt64( radix 8 )"
3631 res &= c_rtl_tres_state
3633 hRtlTestResult,
3634 test_toData<sal_Int64>( kOctolMaxNumsStr,kInt64MaxNumsCount,
3635 kRadixOctol,(sal_Int64*)kInt64MaxNums,3,NULL,hRtlTestResult ),
3636 "kOctolMaxNumsStr",
3637 "toInt64_Boundaries( radix 8 )"
3640 res &= c_rtl_tres_state
3642 hRtlTestResult,
3643 test_toData<sal_Int64>( kDecimalNumsStr,kDecimalNumsCount,
3644 kRadixDecimal,expValues,3,NULL,hRtlTestResult ),
3645 "kDecimalNumsStr",
3646 "toInt64( radix 10 )"
3649 res &= c_rtl_tres_state
3651 hRtlTestResult,
3652 test_toData<sal_Int64>( kDecimalMaxNumsStr,kInt64MaxNumsCount,
3653 kRadixDecimal,(sal_Int64*)kInt64MaxNums,3,NULL,hRtlTestResult ),
3654 "kDecimalMaxNumsStr",
3655 "toInt64_Boundaries( radix 10 )"
3658 res &= c_rtl_tres_state
3660 hRtlTestResult,
3661 test_toData<sal_Int64>( kHexDecimalNumsStr,kHexDecimalNumsCount,
3662 kRadixHexdecimal,expValues,3,NULL,hRtlTestResult ),
3663 "kHexDecimalNumsStr",
3664 "toInt64( radix 16 )"
3667 res &= c_rtl_tres_state
3669 hRtlTestResult,
3670 test_toData<sal_Int64>( kHexDecimalMaxNumsStr,kInt64MaxNumsCount,
3671 kRadixHexdecimal,(sal_Int64*)kInt64MaxNums,3,NULL,hRtlTestResult ),
3672 "kHexDecimalMaxNumsStr",
3673 "toInt64_Boundaries( radix 16 )"
3676 res &= c_rtl_tres_state
3678 hRtlTestResult,
3679 test_toData<sal_Int64>( kBase36NumsStr,kBase36NumsCount,
3680 kRadixBase36, expValues,3,NULL,hRtlTestResult ),
3681 "kBase36NumsStr",
3682 "toInt64( radix 36 )"
3685 res &= c_rtl_tres_state
3687 hRtlTestResult,
3688 test_toData<sal_Int64>( kBase36MaxNumsStr,kInt64MaxNumsCount,
3689 kRadixBase36,(sal_Int64*)kInt64MaxNums,3,NULL,hRtlTestResult ),
3690 "kBase36MaxNumsStr",
3691 "toInt64_Boundaries( radix 36 )"
3696 const sal_Int16 nSpecCases = 5;
3697 static const sal_Char *spString[nSpecCases] =
3699 "-1",
3700 "+1",
3701 " 1",
3702 " -1",
3703 "001"
3706 sal_Int64 expSpecVal[nSpecCases] =
3715 res &= c_rtl_tres_state
3717 hRtlTestResult,
3718 test_toData<sal_Int64>( spString,nSpecCases,
3719 kRadixDecimal,expSpecVal,3,NULL,hRtlTestResult ),
3720 "special cases",
3721 "toInt64( specialcases )"
3724 return (res);
3727 sal_Bool SAL_CALL test_rtl_OUString_toInt64_wrongRadix(
3728 hTestResult hRtlTestResult )
3730 ::rtl::OUString str("0",1,kEncodingRTLTextUSASCII,
3731 kConvertFlagsOStringToOUString);
3733 sal_Int64 iRes = str.toInt64(-1);
3735 return (
3736 c_rtl_tres_state
3738 hRtlTestResult,
3739 iRes == 0,
3740 "wrong radix -1",
3741 "toInt64( wrong radix -1)"
3745 sal_Bool SAL_CALL test_rtl_OUString_toInt64_defaultParam(
3746 hTestResult hRtlTestResult )
3748 sal_Int64 expValues[kBase36NumsCount];
3749 sal_Int32 i;
3751 for ( i = 0; i < kBase36NumsCount; i++ )
3752 expValues[i] = i;
3754 sal_Bool res = c_rtl_tres_state
3756 hRtlTestResult,
3757 test_toData<sal_Int64>( kDecimalNumsStr,kDecimalNumsCount,
3758 kRadixDecimal,expValues,2,NULL,hRtlTestResult ),
3759 "kBinaryNumsStr",
3760 "toInt64( radix 10 )"
3762 res &= c_rtl_tres_state
3764 hRtlTestResult,
3765 test_toData<sal_Int64>( kDecimalMaxNumsStr,kInt64MaxNumsCount,
3766 kRadixDecimal,(sal_Int64*)kInt64MaxNums,2,NULL,hRtlTestResult ),
3767 "kDecimalMaxNumsStr",
3768 "toInt64_Boundaries( radix 10 )"
3770 const sal_Int16 nSpecCases = 5;
3771 static const sal_Char *spString[nSpecCases] =
3773 "-1",
3774 "+1",
3775 " 1",
3776 " -1",
3777 "001"
3780 sal_Int64 expSpecVal[nSpecCases] =
3789 res &= c_rtl_tres_state
3791 hRtlTestResult,
3792 test_toData<sal_Int64>( spString,nSpecCases,
3793 kRadixDecimal,expSpecVal,2,NULL,hRtlTestResult ),
3794 "special cases",
3795 "toInt64( specialcases )"
3798 return ( res );
3801 //------------------------------------------------------------------------
3802 // testing the method toInt64()
3803 //------------------------------------------------------------------------
3804 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_toInt64(
3805 hTestResult hRtlTestResult )
3807 c_rtl_tres_state_start( hRtlTestResult, "toInt64");
3808 sal_Bool bTState = test_rtl_OUString_toInt64_normal( hRtlTestResult );
3809 bTState &= test_rtl_OUString_toInt64_defaultParam (hRtlTestResult );
3810 bTState &= test_rtl_OUString_toInt64_wrongRadix( hRtlTestResult );
3811 c_rtl_tres_state_end( hRtlTestResult, "toInt64");
3812 // return ( bTState );
3814 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString( hTestResult hRtlTestResult )
3817 c_rtl_tres_state_start(hRtlTestResult, "rtl_OUString" );
3819 test_rtl_OUString_ctors( hRtlTestResult );
3820 test_rtl_OUString_getLength( hRtlTestResult );
3821 test_rtl_OUString_equals( hRtlTestResult );
3822 test_rtl_OUString_equalsIgnoreAsciiCase( hRtlTestResult );
3823 test_rtl_OUString_compareTo( hRtlTestResult );
3824 test_rtl_OUString_match( hRtlTestResult );
3825 test_rtl_OUString_op_eq( hRtlTestResult );
3826 test_rtl_OUString_op_peq( hRtlTestResult );
3827 test_rtl_OUString_csuc( hRtlTestResult );
3828 test_rtl_OUString_getStr( hRtlTestResult );
3829 test_rtl_OUString_reverseCompareTo( hRtlTestResult );
3830 test_rtl_OUString_equalsAscii( hRtlTestResult );
3831 test_rtl_OUString_equalsAsciiL( hRtlTestResult );
3832 test_rtl_OUString_compareToAscii( hRtlTestResult );
3833 test_rtl_OUString_valueOf_sal_Bool( hRtlTestResult );
3834 test_rtl_OUString_valueOf_sal_Unicode( hRtlTestResult );
3835 test_rtl_OUString_valueOf( hRtlTestResult );
3836 test_rtl_OUString_createFromAscii( hRtlTestResult );
3837 test_rtl_OUString_indexOf( hRtlTestResult );
3838 // LLA: removed, it is in a new test in rtl/oustring. test_rtl_OUString_lastIndexOf( hRtlTestResult );
3839 test_rtl_OUString_concat( hRtlTestResult );
3840 test_rtl_OUString_replaceAt( hRtlTestResult );
3841 test_rtl_OUString_replace( hRtlTestResult );
3842 test_rtl_OUString_toAsciiLowerCase( hRtlTestResult );
3843 test_rtl_OUString_toAsciiUpperCase( hRtlTestResult );
3844 test_rtl_OUString_trim( hRtlTestResult );
3845 // LLA: removed, it is in a new test in rtl/oustring. test_rtl_OUString_toDouble( hRtlTestResult );
3846 // LLA: removed, has compile problems. test_rtl_OUString_toFloat( hRtlTestResult );
3847 test_rtl_OUString_toChar( hRtlTestResult );
3848 test_rtl_OUString_toBoolean( hRtlTestResult );
3849 test_rtl_OUString_toInt32( hRtlTestResult );
3850 test_rtl_OUString_toInt64( hRtlTestResult );
3852 c_rtl_tres_state_end(hRtlTestResult, "rtl_OUString");
3854 // -----------------------------------------------------------------------------
3855 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
3857 if (_pFunc)
3859 (_pFunc)(&test_rtl_OUString, "");