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