1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sal.hxx" 30 31 #ifndef _SAL_TYPES_H_ 32 #include <sal/types.h> 33 #endif 34 35 // #ifndef _RTL_TRES_H_ 36 // #include <rtl/tres.h> 37 // #endif 38 #include <testshl/tresstatewrapper.hxx> 39 40 #ifndef _RTL_STRING_HXX_ 41 #include <rtl/string.hxx> 42 #endif 43 44 #ifndef _RTL_USTRING_H_ 45 #include <rtl/ustring.h> 46 #endif 47 48 #ifndef _RTL_USTRING_HXX_ 49 #include <rtl/ustring.hxx> 50 #endif 51 52 #ifndef _RTL_USTRBUF_H_ 53 #include <rtl/ustrbuf.h> 54 #endif 55 56 #ifndef _RTL_USTRBUF_HXX 57 #include <rtl/ustrbuf.hxx> 58 #endif 59 //------------------------------------------------------------------------ 60 //------------------------------------------------------------------------ 61 #ifndef _OSL_THREAD_H_ 62 #include <osl/thread.h> 63 #endif 64 65 #ifndef _RTL_STRING_CONST_H_ 66 #include <rtl_String_Const.h> 67 #endif 68 69 #ifndef _RTL_STRING_UTILS_HXX_ 70 #include <rtl_String_Utils.hxx> 71 #endif 72 73 #include "stdio.h" 74 using namespace rtl; 75 76 //------------------------------------------------------------------------ 77 // test classes 78 //------------------------------------------------------------------------ 79 const int MAXBUFLENGTH = 255; 80 //------------------------------------------------------------------------ 81 // helper functions 82 //------------------------------------------------------------------------ 83 static void unused() 84 { 85 (void)kBinaryNumsStr; 86 (void)kOctolNumsStr; 87 (void)kDecimalNumsStr; 88 (void)kHexDecimalNumsStr; 89 (void)kBase36NumsStr; 90 (void)inputChar; 91 (void)input1StrDefault; 92 (void)input1StrNormal; 93 (void)input1StrLastDefault; 94 (void)input1StrLastNormal; 95 unused(); 96 } 97 98 //------------------------------------------------------------------------ 99 // testing constructors 100 //------------------------------------------------------------------------ 101 static sal_Bool test_rtl_OUStringBuffer_ctor_001( hTestResult hRtlTestResult ) 102 { 103 104 ::rtl::OUStringBuffer aUStrBuf; 105 106 bool b1 = 107 aUStrBuf.getLength() == 0 && 108 ! *(aUStrBuf.getStr()) && aUStrBuf.getCapacity() == 16; 109 110 ::rtl::OUStringBuffer aUStrBuf2(0); 111 112 bool b2 = 113 aUStrBuf2.getLength() == 0 && 114 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: !!! */ 0; 115 116 return 117 ( 118 c_rtl_tres_state 119 ( 120 hRtlTestResult, 121 b1 && b2, 122 "New OUStringBuffer containing no characters", 123 "ctor_001" 124 ) 125 ); 126 } 127 128 //------------------------------------------------------------------------ 129 130 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_002( 131 hTestResult hRtlTestResult ) 132 { 133 ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 ); 134 ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp ); 135 sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr()); 136 return 137 ( 138 c_rtl_tres_state 139 ( 140 hRtlTestResult, 141 aUStrBuf.getLength()==aUStrBuftmp.getLength() && 142 aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() && res , 143 "New OUStringBuffer from another OUStringBuffer", 144 "ctor_002" 145 ) 146 ); 147 } 148 //------------------------------------------------------------------------ 149 150 /* static */ 151 sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_003( 152 hTestResult hRtlTestResult ) 153 { 154 ::rtl::OUStringBuffer aUStrBuf1(kTestStr2Len); 155 #ifdef WITH_CORE 156 ::rtl::OUStringBuffer aUStrBuf2(kSInt32Max); //will core dump 157 #else 158 ::rtl::OUStringBuffer aUStrBuf2(0); 159 #endif 160 ::rtl::OUStringBuffer aUStrBuf3(kNonSInt32Max); 161 162 163 bool b1 = 164 aUStrBuf1.getLength() == 0 && 165 ! *(aUStrBuf1.getStr()) && aUStrBuf1.getCapacity() == kTestStr2Len ; 166 167 bool b2 = 168 #ifdef WITH_CORE 169 aUStrBuf2.getLength() == 0 && 170 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == kSInt32Max ; 171 #else 172 aUStrBuf2.getLength() == 0 && 173 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: ??? 16 */ 0; 174 #endif 175 bool b3 = 176 aUStrBuf3.getLength() == 0 && 177 ! *(aUStrBuf3.getStr()) && aUStrBuf3.getCapacity() == kNonSInt32Max; 178 179 return 180 ( 181 c_rtl_tres_state 182 ( 183 hRtlTestResult, 184 b1 && b2 && b3, 185 "New OUStringBuffer containing no characters and contain assigned capacity", 186 "ctor_003( will core dump,because the kSInt32Max )" 187 ) 188 ); 189 190 } 191 192 //------------------------------------------------------------------------ 193 194 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_004( 195 hTestResult hRtlTestResult) 196 { 197 ::rtl::OUString aUStrtmp( aUStr1 ); 198 ::rtl::OUStringBuffer aUStrBuf( aUStrtmp ); 199 sal_Int32 leg = aUStrBuf.getLength(); 200 return 201 ( 202 c_rtl_tres_state 203 ( 204 hRtlTestResult, 205 aUStrBuf.getStr() == aUStrtmp && 206 leg == aUStrtmp.pData->length && 207 aUStrBuf.getCapacity() == leg+16 , 208 "New OUStringBuffer from OUstring", 209 "ctor_004" 210 ) 211 ); 212 } 213 214 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_005( 215 hTestResult hRtlTestResult) 216 { 217 ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 ); 218 ::rtl::OUString aUStrtmp = aUStrBuftmp.makeStringAndClear(); 219 ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp ); 220 sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr()); 221 sal_Int32 leg = aUStrBuf.getLength(); 222 return 223 ( 224 c_rtl_tres_state 225 ( 226 hRtlTestResult, 227 aUStrBuf.getLength()==aUStrBuftmp.getLength() && 228 aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() && 229 res && leg == 0, 230 "New OUStringBuffer from another OUStringBuffer after makeClearFromString", 231 "ctor_005" 232 ) 233 ); 234 } 235 236 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ctors( 237 hTestResult hRtlTestResult ) 238 { 239 c_rtl_tres_state_start( hRtlTestResult, "ctors"); 240 sal_Bool DCState = test_ini_uString(); 241 (void)DCState; 242 sal_Bool bTSState = test_rtl_OUStringBuffer_ctor_001( hRtlTestResult ); 243 bTSState &= test_rtl_OUStringBuffer_ctor_002( hRtlTestResult); 244 bTSState &= test_rtl_OUStringBuffer_ctor_003( hRtlTestResult); 245 bTSState &= test_rtl_OUStringBuffer_ctor_004( hRtlTestResult); 246 bTSState &= test_rtl_OUStringBuffer_ctor_005( hRtlTestResult); 247 248 c_rtl_tres_state_end( hRtlTestResult, "ctors"); 249 // return( bTSState ); 250 } 251 252 //------------------------------------------------------------------------ 253 // testing the method makeStringAndClear() 254 //------------------------------------------------------------------------ 255 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_makeStringAndClear( 256 hTestResult hRtlTestResult ) 257 { 258 c_rtl_tres_state_start( hRtlTestResult, "makeStringAndClear"); 259 sal_Char methName[MAXBUFLENGTH]; 260 sal_Char* pMeth = methName; 261 262 typedef struct TestCase 263 { 264 sal_Char* comments; 265 OUString* expVal; 266 OUStringBuffer* input1; 267 268 ~TestCase() { delete input1;} 269 } TestCase; 270 271 OUString arrOUS[6]={ 272 OUString( aUStr1 ), 273 OUString( aUStr14 ), 274 OUString( aUStr25 ), 275 OUString( aUStr27 ), 276 OUString( aUStr29 ), 277 OUString( "\0",0, 278 kEncodingRTLTextUSASCII, 279 kConvertFlagsOStringToOUString) 280 }; 281 282 TestCase arrTestCase[]={ 283 284 {"two empty strings(def. constructor)", new OUString(), 285 new OUStringBuffer()}, 286 {"two empty strings(with a argu)", new OUString(), 287 new OUStringBuffer(26)}, 288 {"normal string", new OUString(arrOUS[0]), 289 new OUStringBuffer(arrOUS[0])}, 290 {"string with space ", new OUString(arrOUS[1]), 291 new OUStringBuffer(arrOUS[1])}, 292 {"empty string", new OUString(arrOUS[2]), 293 new OUStringBuffer(arrOUS[2])}, 294 {"string with a character", new OUString(arrOUS[3]), 295 new OUStringBuffer(arrOUS[3])}, 296 {"string with special characters", new OUString(arrOUS[4]), 297 new OUStringBuffer(arrOUS[4])}, 298 {"string only with (\0)", new OUString(arrOUS[5]), 299 new OUStringBuffer(arrOUS[5])} 300 }; 301 302 sal_Bool res = sal_True; 303 sal_uInt32 i; 304 305 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 306 { 307 sal_Bool lastRes = 308 ( arrTestCase[i].input1->makeStringAndClear() == 309 *( arrTestCase[i].expVal )); 310 lastRes = lastRes && ( arrTestCase[i].input1->getCapacity() == 0 ); 311 lastRes = lastRes && ( *(arrTestCase[i].input1->getStr()) == '\0' ); 312 313 c_rtl_tres_state 314 ( 315 hRtlTestResult, 316 lastRes, 317 arrTestCase[i].comments, 318 createName( pMeth, "makeStringAndClear", i ) 319 ); 320 321 res &= lastRes; 322 } 323 c_rtl_tres_state_end( hRtlTestResult, "makeStringAndClear"); 324 // return (res); 325 } 326 //------------------------------------------------------------------------ 327 // testing the method getLength 328 //------------------------------------------------------------------------ 329 330 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getLength( 331 hTestResult hRtlTestResult) 332 { 333 c_rtl_tres_state_start( hRtlTestResult, "getLength"); 334 sal_Char methName[MAXBUFLENGTH]; 335 sal_Char* pMeth = methName; 336 337 OUString arrOUS[6]={OUString( aUStr1 ), 338 OUString( "1",1, 339 kEncodingRTLTextUSASCII, 340 kConvertFlagsOStringToOUString), 341 OUString(), 342 OUString( "",0, 343 kEncodingRTLTextUSASCII, 344 kConvertFlagsOStringToOUString), 345 OUString( "\0",0, 346 kEncodingRTLTextUSASCII, 347 kConvertFlagsOStringToOUString), 348 OUString( aUStr2 )}; 349 350 typedef struct TestCase 351 { 352 sal_Char* comments; 353 sal_Int32 expVal; 354 OUStringBuffer* input; 355 ~TestCase() { delete input;} 356 } TestCase; 357 358 TestCase arrTestCase[]={ 359 360 {"length of ascii string", kTestStr1Len, 361 new OUStringBuffer(arrOUS[0]) }, 362 {"length of ascci string of size 1", 1, 363 new OUStringBuffer(arrOUS[1])}, 364 {"length of empty string", 0, 365 new OUStringBuffer(arrOUS[2])}, 366 {"length of empty string (empty ascii string arg)",0, 367 new OUStringBuffer(arrOUS[3])}, 368 {"length of empty string (string arg = '\\0')", 0, 369 new OUStringBuffer(arrOUS[4])}, 370 {"length(>16) of ascii string", kTestStr2Len, 371 new OUStringBuffer(arrOUS[5]) }, 372 {"length of empty string (default constructor)", 0, 373 new OUStringBuffer()}, 374 {"length of empty string (with capacity)", 0, 375 new OUStringBuffer(26)} 376 }; 377 378 379 sal_Bool res = sal_True; 380 sal_uInt32 i; 381 382 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 383 { 384 sal_Int32 length = arrTestCase[i].input->getLength(); 385 sal_Bool lastRes = (length == arrTestCase[i].expVal); 386 c_rtl_tres_state 387 ( 388 hRtlTestResult, 389 lastRes, 390 arrTestCase[i].comments, 391 createName( pMeth, "getLength", i ) 392 393 ); 394 res &= lastRes; 395 } 396 c_rtl_tres_state_end( hRtlTestResult, "getLength"); 397 // return ( res ); 398 } 399 //------------------------------------------------------------------------ 400 // testing the method getCapacity() 401 //------------------------------------------------------------------------ 402 403 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getCapacity( 404 hTestResult hRtlTestResult) 405 { 406 c_rtl_tres_state_start( hRtlTestResult, "getCapacity"); 407 sal_Char methName[MAXBUFLENGTH]; 408 sal_Char* pMeth = methName; 409 410 OUString arrOUS[6]={OUString( aUStr1 ), 411 OUString( "1",1, 412 kEncodingRTLTextUSASCII, 413 kConvertFlagsOStringToOUString), 414 OUString(), 415 OUString( "",0, 416 kEncodingRTLTextUSASCII, 417 kConvertFlagsOStringToOUString), 418 OUString( "\0",0, 419 kEncodingRTLTextUSASCII, 420 kConvertFlagsOStringToOUString), 421 OUString( aUStr2 )}; 422 423 typedef struct TestCase 424 { 425 sal_Char* comments; 426 sal_Int32 expVal; 427 OUStringBuffer* input; 428 ~TestCase() { delete input;} 429 } TestCase; 430 431 TestCase arrTestCase[]={ 432 433 {"capacity of ascii string", kTestStr1Len+16, 434 new OUStringBuffer(arrOUS[0]) }, 435 {"capacity of ascci string of size 1", 1+16, 436 new OUStringBuffer(arrOUS[1]) }, 437 {"capacity of empty string", 0+16, 438 new OUStringBuffer(arrOUS[2]) }, 439 {"capacity of empty string (empty ascii string arg)",0+16, 440 new OUStringBuffer(arrOUS[3]) }, 441 {"capacity of empty string (string arg = '\\0')", 0+16, 442 new OUStringBuffer(arrOUS[4]) }, 443 {"capacity(>16) of ascii string", kTestStr2Len+16, 444 new OUStringBuffer(arrOUS[5]) }, 445 {"capacity of empty string (default constructor)", 16, 446 new OUStringBuffer() }, 447 #ifdef WITH_CORE 448 {"capacity of empty string (with capacity 2147483647)(code will core dump)", kSInt32Max, 449 new OUStringBuffer(kSInt32Max) },// will core dump 450 #endif 451 {"capacity of empty string (with capacity -2147483648)", kNonSInt32Max, 452 new OUStringBuffer(kNonSInt32Max) }, 453 {"capacity of empty string (with capacity 16)", 16, 454 new OUStringBuffer(16) }, 455 {"capacity of empty string (with capacity 6)", 6, 456 new OUStringBuffer(6) }, 457 {"capacity of empty string (with capacity 0)", 0, 458 new OUStringBuffer(0) }, 459 {"capacity of empty string (with capacity -2)", -2, 460 new OUStringBuffer(-2) } 461 }; 462 463 464 sal_Bool res = sal_True; 465 sal_uInt32 i; 466 467 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 468 { 469 sal_Int32 length = arrTestCase[i].input->getCapacity(); 470 sal_Bool lastRes = (length == arrTestCase[i].expVal); 471 c_rtl_tres_state 472 ( 473 hRtlTestResult, 474 lastRes, 475 arrTestCase[i].comments, 476 createName( pMeth, "getCapacity", i ) 477 478 ); 479 res &= lastRes; 480 } 481 c_rtl_tres_state_end( hRtlTestResult, "getCapacity"); 482 // return ( res ); 483 } 484 //------------------------------------------------------------------------ 485 // testing the method ensureCapacity(sal_Int32 minimumCapacity) 486 //------------------------------------------------------------------------ 487 488 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ensureCapacity( 489 hTestResult hRtlTestResult) 490 { 491 c_rtl_tres_state_start( hRtlTestResult, "ensureCapacity"); 492 sal_Char methName[MAXBUFLENGTH]; 493 sal_Char* pMeth = methName; 494 495 typedef struct TestCase 496 { 497 sal_Char* comments; 498 sal_Int32 expVal; 499 OUStringBuffer* input1; 500 sal_Int32 input2; 501 ~TestCase() { delete input1;} 502 } TestCase; 503 504 TestCase arrTestCase[]={ 505 506 {"capacity equal to 16, minimum is 5 ", 16, 507 new OUStringBuffer(), 5 }, 508 {"capacity equal to 16, minimum is -5", 16, 509 new OUStringBuffer(), -5}, 510 {"capacity equal to 16, minimum is 0", 16, 511 new OUStringBuffer(), 0}, 512 {"capacity equal to 16, minimum is 20", 20, //the testcase is based on comments 513 new OUStringBuffer(), 20}, 514 {"capacity equal to 16, minimum is 50", 50, 515 new OUStringBuffer(), 50}, 516 {"capacity equal to 6, minimum is 20", 20, 517 new OUStringBuffer(6), 20 }, 518 {"capacity equal to 6, minimum is 2", 6, 519 new OUStringBuffer(6), 2}, 520 {"capacity equal to 6, minimum is -6", 6, 521 new OUStringBuffer(6), -6}, 522 {"capacity equal to 6, minimum is -6", 10, //the testcase is based on comments 523 new OUStringBuffer(6), 10}, 524 {"capacity equal to 0, minimum is 6", 6, 525 new OUStringBuffer(0), 6}, 526 {"capacity equal to 0, minimum is 1", 2, //the testcase is based on comments 527 new OUStringBuffer(0), 1}, 528 /* 529 {"capacity equal to 0, minimum is -1", 0, 530 new OUStringBuffer(0), -1}, 531 */ 532 #ifdef WITH_CORE 533 {"capacity equal to 2147483647, minimum is 65535", kSInt32Max,//will core dump 534 new OUStringBuffer(kSInt32Max), 65535}, 535 {"capacity equal to 2147483647, minimum is 2147483647", kSInt32Max,//will core dump 536 new OUStringBuffer(kSInt32Max), kSInt32Max}, 537 {"capacity equal to 2147483647, minimum is -1", kSInt32Max,//will core dump 538 new OUStringBuffer(kSInt32Max), -1}, 539 {"capacity equal to 2147483647, minimum is 0", kSInt32Max,//will core dump 540 new OUStringBuffer(kSInt32Max), 0}, 541 {"capacity equal to 2147483647, minimum is -2147483648", kSInt32Max,//will core dump 542 new OUStringBuffer(kSInt32Max), kNonSInt32Max}, 543 #endif 544 {"capacity equal to -2147483648, minimum is 65535", 65535, 545 new OUStringBuffer(kNonSInt32Max), 65535}, 546 #ifdef WITH_CORE 547 {"capacity equal to -2147483648, minimum is 2147483647", 2147483647,//will core dump 548 new OUStringBuffer(kNonSInt32Max), 2147483647}, 549 #endif 550 {"capacity equal to -2147483648, minimum is -1", 2, 551 new OUStringBuffer(kNonSInt32Max), -1}, 552 {"capacity equal to -2147483648, minimum is 0", 2, 553 new OUStringBuffer(kNonSInt32Max), 0}, 554 {"capacity equal to -2147483648, minimum is -2147483648", kNonSInt32Max, 555 new OUStringBuffer(kNonSInt32Max), kNonSInt32Max} 556 }; 557 558 559 sal_Bool res = sal_True; 560 sal_uInt32 i; 561 562 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 563 { 564 arrTestCase[i].input1->ensureCapacity(arrTestCase[i].input2); 565 sal_Int32 length = arrTestCase[i].input1->getCapacity(); 566 sal_Bool lastRes = (length == arrTestCase[i].expVal); 567 568 c_rtl_tres_state 569 ( 570 hRtlTestResult, 571 lastRes, 572 arrTestCase[i].comments, 573 createName( pMeth, "ensureCapacity", i ) 574 575 ); 576 res &= lastRes; 577 } 578 c_rtl_tres_state_end( hRtlTestResult, "ensureCapacity"); 579 // return ( res ); 580 } 581 //------------------------------------------------------------------------ 582 // testing the method setLength(sal_Int32 newLength) 583 //------------------------------------------------------------------------ 584 585 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_setLength( 586 hTestResult hRtlTestResult) 587 { 588 c_rtl_tres_state_start( hRtlTestResult, "setLength"); 589 sal_Char methName[MAXBUFLENGTH]; 590 sal_Char* pMeth = methName; 591 592 OUString arrOUS[6]={OUString( aUStr1 ), 593 OUString( aUStr27), 594 OUString(), 595 OUString( "",0, 596 kEncodingRTLTextUSASCII, 597 kConvertFlagsOStringToOUString), 598 OUString( "\0",0, 599 kEncodingRTLTextUSASCII, 600 kConvertFlagsOStringToOUString), 601 OUString( aUStr2 )}; 602 603 typedef struct TestCase 604 { 605 sal_Char* comments; 606 sal_Int32 expVal1; 607 OUString* expVal2; 608 sal_Int32 expVal3; 609 OUStringBuffer* input1; 610 sal_Int32 input2; 611 ~TestCase() { delete input1; delete expVal2;} 612 } TestCase; 613 614 TestCase arrTestCase[]={ 615 616 {"newLength more than the capacity of OUStringBuffer(aUStr1)", 617 50, new OUString(aUStr1), 50, 618 new OUStringBuffer(arrOUS[0]), 50 }, 619 {"newLength more than the length of OUStringBuffer(aUStr1)", 620 kTestStr13Len, new OUString(aUStr1), 32, 621 new OUStringBuffer(arrOUS[0]), kTestStr13Len }, 622 {"newLength equal to the length of OUStringBuffer(aUStr1)", 623 kTestStr1Len, new OUString(aUStr1), 32, 624 new OUStringBuffer(arrOUS[0]), kTestStr1Len }, 625 {"newLength less than the length of OUStringBuffer(aUStr1)", 626 kTestStr7Len, new OUString(aUStr7), 32, 627 new OUStringBuffer(arrOUS[0]), kTestStr7Len}, 628 {"newLength equal to 0", 629 0, new OUString(), 32, 630 new OUStringBuffer(arrOUS[0]), 0}, 631 {"newLength more than the capacity of OUStringBuffer(1)", 632 25, new OUString(arrOUS[1]), 25, 633 new OUStringBuffer(arrOUS[1]), 25}, 634 {"newLength more than the length of OUStringBuffer(1)", 635 5, new OUString(arrOUS[1]), 17, 636 new OUStringBuffer(arrOUS[1]), 5}, 637 {"newLength equal to the length of OUStringBuffer(1)", 638 kTestStr27Len, new OUString(arrOUS[1]), 17, 639 new OUStringBuffer(arrOUS[1]), kTestStr27Len}, 640 {"newLength less than the length of OUStringBuffer(1)", 641 0, new OUString(), 17, 642 new OUStringBuffer(arrOUS[1]), 0}, 643 {"newLength more than the capacity of OUStringBuffer()", 644 20, new OUString(), 20, 645 new OUStringBuffer(arrOUS[2]), 20}, 646 {"newLength more than the length of OUStringBuffer()", 647 3, new OUString(), 16, 648 new OUStringBuffer(arrOUS[2]), 3}, 649 {"newLength less than the length of OUStringBuffer()", 650 0, new OUString(), 16, 651 new OUStringBuffer(arrOUS[2]), 0}, 652 {"newLength more than the capacity of OUStringBuffer("")", 653 20, new OUString(), 20, 654 new OUStringBuffer(arrOUS[3]), 20}, 655 {"newLength more than the length of OUStringBuffer("")", 656 5, new OUString(), 16, 657 new OUStringBuffer(arrOUS[3]), 5}, 658 {"newLength less than the length of OUStringBuffer("")", 659 0, new OUString(), 16, 660 new OUStringBuffer(arrOUS[3]), 0}, 661 {"newLength more than the length of OUStringBuffer(\0)", 662 20, new OUString(), 20, 663 new OUStringBuffer(arrOUS[4]), 20}, 664 {"newLength more than the length of OUStringBuffer(\0)", 665 5, new OUString(), 16, 666 new OUStringBuffer(arrOUS[4]), 5}, 667 {"newLength less than the length of OUStringBuffer(\0)", 668 0, new OUString(), 16, 669 new OUStringBuffer(arrOUS[4]), 0}, 670 {"newLength more than the capacity of OUStringBuffer(aUStr2)", 671 50, new OUString(aUStr2), 66, 672 new OUStringBuffer(arrOUS[5]), 50,}, 673 {"newLength more than the length of OUStringBuffer(aUStr2)", 674 40, new OUString(aUStr2), 48, 675 new OUStringBuffer(arrOUS[5]), 40,}, 676 {"newLength equal to the length of OUStringBuffer(aUStr2)", 677 kTestStr2Len, new OUString(aUStr2), 48, 678 new OUStringBuffer(arrOUS[5]), kTestStr2Len,}, 679 {"newLength less than the length of OUStringBuffer(aUStr2)", 680 kTestStr7Len, new OUString(aUStr7), 48, 681 new OUStringBuffer(arrOUS[5]), kTestStr7Len}, 682 {"newLength equal to 0", 683 0, new OUString(), 48, 684 new OUStringBuffer(arrOUS[5]), 0} 685 686 }; 687 688 689 sal_Bool res = sal_True; 690 sal_uInt32 i; 691 692 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 693 { 694 arrTestCase[i].input1->setLength(arrTestCase[i].input2); 695 sal_Bool lastRes = 696 ( arrTestCase[i].input1->getStr() == *(arrTestCase[i].expVal2) && 697 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal1 && 698 arrTestCase[i].input1->getCapacity() == arrTestCase[i].expVal3 ); 699 700 c_rtl_tres_state 701 ( 702 hRtlTestResult, 703 lastRes, 704 arrTestCase[i].comments, 705 createName( pMeth, "setLength", i ) 706 707 ); 708 res &= lastRes; 709 } 710 c_rtl_tres_state_end( hRtlTestResult, "setLength"); 711 // return ( res ); 712 } 713 //------------------------------------------------------------------------ 714 // testing the method charAt( sal_Int32 index ) 715 //------------------------------------------------------------------------ 716 717 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_charAt( 718 hTestResult hRtlTestResult) 719 { 720 c_rtl_tres_state_start( hRtlTestResult, "charAt"); 721 sal_Char methName[MAXBUFLENGTH]; 722 sal_Char* pMeth = methName; 723 724 OUString arrOUS[4]={OUString( aUStr1 ), // "Sun Microsystems"; 725 OUString( aUStr27), // "s"; 726 OUString( aUStr28), // "\50\3\5\7\11\13\15\17sun"; 727 OUString( )}; 728 729 typedef struct TestCase 730 { 731 sal_Char* comments; 732 sal_Unicode expVal; 733 OUStringBuffer* input1; 734 sal_Int32 input2; 735 ~TestCase() { delete input1;} 736 } TestCase; 737 738 TestCase arrTestCase[]={ 739 740 {"return the first character of OUStringBuffer(aUStr1)", 741 83, new OUStringBuffer(arrOUS[0]), 0 }, 742 {"return the middle character of OUStringBuffer(aUStr1)", 743 32, new OUStringBuffer(arrOUS[0]), 3 }, 744 {"return the last character of OUStringBuffer(aUStr1)", 745 115, new OUStringBuffer(arrOUS[0]), 15 }, 746 {"return the only character of OUStringBuffer(aUStr27)", 747 115, new OUStringBuffer(arrOUS[1]), 0}, 748 {"return the first of OUStringBuffer(aUStr28) with special character", 749 40, new OUStringBuffer(arrOUS[2]), 0}, 750 /* 751 {"return the mid of OUStringBuffer(aUStr28) with special character", 752 11, new OUStringBuffer(arrOUS[2]), 5}, 753 */ 754 /* 755 {"invalid character of OUStringBuffer()", 756 0, new OUStringBuffer(arrOUS[3]), 0}, 757 */ 758 /* 759 {"invalid character of OUStringBuffer()", 760 0, new OUStringBuffer(arrOUS[3]), -2} 761 */ 762 763 }; 764 765 766 sal_Bool res = sal_True; 767 sal_uInt32 i; 768 769 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 770 { 771 sal_Bool lastRes = 772 ( arrTestCase[i].input1->charAt(arrTestCase[i].input2) == 773 arrTestCase[i].expVal ); 774 // LLA: last case removed, due to the fact of complexity of the test code :-( 775 // LLA: if(i<=7) 776 // LLA: { 777 c_rtl_tres_state 778 ( 779 hRtlTestResult, 780 lastRes, 781 arrTestCase[i].comments, 782 createName( pMeth, "charAt", i ) 783 784 ); 785 // LLA: } 786 // LLA: else 787 // LLA: { 788 // LLA: c_rtl_tres_state 789 // LLA: ( 790 // LLA: hRtlTestResult, 791 // LLA: sal_True, 792 // LLA: arrTestCase[i].comments, 793 // LLA: createName( pMeth, "charAt", i ) 794 // LLA: 795 // LLA: ); 796 // LLA: } 797 res &= lastRes; 798 } 799 c_rtl_tres_state_end( hRtlTestResult, "charAt"); 800 // return ( res ); 801 } 802 //------------------------------------------------------------------------ 803 // testing the operator const sal_Unicode * (csuc for short) 804 //------------------------------------------------------------------------ 805 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_csuc( 806 hTestResult hRtlTestResult) 807 { 808 c_rtl_tres_state_start( hRtlTestResult, "csuc"); 809 sal_Char methName[MAXBUFLENGTH]; 810 sal_Char* pMeth = methName; 811 812 const sal_Unicode tmpUC=0x0; 813 rtl_uString* tmpUstring = NULL; 814 const sal_Char *tmpStr=kTestStr1; 815 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len; 816 //sal_Int32 cmpLen = 0; 817 OUString tempString(aUStr1); 818 819 rtl_string2UString( &tmpUstring, tmpStr, tmpLen, 820 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); 821 OSL_ASSERT(tmpUstring != NULL); 822 823 824 typedef struct TestCase 825 { 826 sal_Char* comments; 827 const sal_Unicode* expVal; 828 sal_Int32 cmpLen; 829 OUStringBuffer* input1; 830 ~TestCase() { delete input1; } 831 } TestCase; 832 833 TestCase arrTestCase[] = 834 { 835 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len, 836 new OUStringBuffer(tempString)}, 837 {"test empty ustring",&tmpUC, 1, new OUStringBuffer()} 838 }; 839 840 sal_Bool res = sal_True; 841 sal_uInt32 i; 842 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 843 { 844 const sal_Unicode* pstr = *arrTestCase[i].input1; 845 846 res &= c_rtl_tres_state 847 ( 848 hRtlTestResult, 849 cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ), 850 arrTestCase[i].comments, 851 createName( pMeth, "const sal_Unicode*", i ) 852 ); 853 } 854 c_rtl_tres_state_end( hRtlTestResult, "csuc"); 855 // return ( res ); 856 } 857 //------------------------------------------------------------------------ 858 // testing the method const sal_Unicode * getStr() 859 //------------------------------------------------------------------------ 860 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getStr( 861 hTestResult hRtlTestResult) 862 { 863 c_rtl_tres_state_start( hRtlTestResult, "getStr"); 864 sal_Char methName[MAXBUFLENGTH]; 865 sal_Char* pMeth = methName; 866 867 const sal_Unicode tmpUC=0x0; 868 rtl_uString* tmpUstring = NULL; 869 const sal_Char *tmpStr=kTestStr1; 870 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len; 871 //sal_Int32 cmpLen = 0; 872 OUString tempString(aUStr1); 873 874 rtl_string2UString( &tmpUstring, tmpStr, tmpLen, 875 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); 876 OSL_ASSERT(tmpUstring != NULL); 877 878 879 typedef struct TestCase 880 { 881 sal_Char* comments; 882 const sal_Unicode* expVal; 883 sal_Int32 cmpLen; 884 OUStringBuffer* input1; 885 ~TestCase() { delete input1;} 886 } TestCase; 887 888 TestCase arrTestCase[] = 889 { 890 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len, 891 new OUStringBuffer(tempString)}, 892 {"test empty ustring",&tmpUC, 1, new OUStringBuffer()} 893 }; 894 895 sal_Bool res = sal_True; 896 sal_uInt32 i; 897 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 898 { 899 const sal_Unicode* pstr = arrTestCase[i].input1->getStr(); 900 901 res &= c_rtl_tres_state 902 ( 903 hRtlTestResult, 904 cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ), 905 arrTestCase[i].comments, 906 createName( pMeth, "getStr", i ) 907 ); 908 } 909 c_rtl_tres_state_end( hRtlTestResult, "getStr"); 910 // return ( res ); 911 } 912 //------------------------------------------------------------------------ 913 // testing the method setCharAt(sal_Int32 index, sal_Unicode ch) 914 //------------------------------------------------------------------------ 915 916 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_setCharAt( 917 hTestResult hRtlTestResult) 918 { 919 c_rtl_tres_state_start( hRtlTestResult, "setCharAt"); 920 sal_Char methName[MAXBUFLENGTH]; 921 sal_Char* pMeth = methName; 922 923 OUString arrOUS[4]={OUString( aUStr1 ), 924 OUString( aUStr27), 925 OUString( aUStr28), 926 OUString( )}; 927 928 typedef struct TestCase 929 { 930 sal_Char* comments; 931 OUString* expVal; 932 OUStringBuffer* input1; 933 sal_Int32 input2; 934 sal_Unicode input3; 935 ~TestCase() { delete input1; delete expVal; } 936 } TestCase; 937 938 TestCase arrTestCase[]={ 939 940 {"set the first character of OUStringBuffer(aUStr1) with s", 941 new OUString(aUStr31), 942 new OUStringBuffer(arrOUS[0]), 0, 115 }, 943 {"set the middle character of OUStringBuffer(aUStr1) with m", 944 new OUString(aUStr3), 945 new OUStringBuffer(arrOUS[0]), 4, 109 }, 946 {"set the last character of OUStringBuffer(aUStr1) with ' '", 947 new OUString(aUStr32), 948 new OUStringBuffer(arrOUS[0]), 15, 32 }, 949 {"set the only character of OUStringBuffer(aUStr27) with ' '", 950 new OUString(aUStr33), 951 new OUStringBuffer(arrOUS[1]), 0, 32}, 952 {"set the only of OUStringBuffer(aUStr28) with special character", 953 new OUString(aUStr34), 954 new OUStringBuffer(arrOUS[2]), 1, 5}, 955 /* 956 {"set the only of OUStringBuffer(aUStr28) with special character", 957 new OUString(aUStr35), 958 new OUStringBuffer(arrOUS[2]), 1, -5} 959 */ 960 #ifdef WITH_CORE 961 ,{"invalid character of OUStringBuffer()", 962 0, 963 new OUStringBuffer(arrOUS[3]), 0, 5}, 964 {"invalid character of OUStringBuffer()", 965 0, 966 new OUStringBuffer(arrOUS[3]), -2, 5}, 967 {"invalid character of OUStringBuffer()", 968 0, 969 new OUStringBuffer(arrOUS[3]), 3, 5} 970 #endif 971 972 }; 973 974 975 sal_Bool res = sal_True; 976 sal_uInt32 i; 977 978 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 979 { 980 sal_Bool lastRes = 981 ( (arrTestCase[i].input1->setCharAt(arrTestCase[i].input2, 982 arrTestCase[i].input3)).getStr() == *(arrTestCase[i].expVal) ); 983 if(i<=4) 984 { 985 c_rtl_tres_state 986 ( 987 hRtlTestResult, 988 lastRes, 989 arrTestCase[i].comments, 990 createName( pMeth, "setCharAt", i ) 991 992 ); 993 } 994 else 995 { 996 c_rtl_tres_state 997 ( 998 hRtlTestResult, 999 sal_True, 1000 arrTestCase[i].comments, 1001 createName( pMeth, "setCharAt", i ) 1002 1003 ); 1004 } 1005 res &= lastRes; 1006 } 1007 c_rtl_tres_state_end( hRtlTestResult, "setCharAt"); 1008 // return ( res ); 1009 } 1010 //------------------------------------------------------------------------ 1011 // testing the method append(const OUString &str) 1012 //------------------------------------------------------------------------ 1013 1014 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_001( 1015 hTestResult hRtlTestResult) 1016 { 1017 sal_Char methName[MAXBUFLENGTH]; 1018 sal_Char* pMeth = methName; 1019 1020 OUString arrOUS[5]={OUString( aUStr7 ), 1021 OUString(), 1022 OUString( aUStr25 ), 1023 OUString( "\0",0, 1024 kEncodingRTLTextUSASCII, 1025 kConvertFlagsOStringToOUString), 1026 OUString( aUStr28 )}; 1027 1028 typedef struct TestCase 1029 { 1030 sal_Char* comments; 1031 OUString* expVal; 1032 OUStringBuffer* input1; 1033 OUString* input2; 1034 1035 ~TestCase() { delete input1; delete input2; delete expVal; } 1036 } TestCase; 1037 1038 TestCase arrTestCase[]={ 1039 1040 {"Appends the string(length less than 16) to the string buffer arrOUS[0]", 1041 new OUString(aUStr1), 1042 new OUStringBuffer(arrOUS[0]), new OUString(aUStr8) }, 1043 {"Appends the string(length more than 16) to the string buffer arrOUS[0]", 1044 new OUString(aUStr2), 1045 new OUStringBuffer(arrOUS[0]), new OUString(aUStr36) }, 1046 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]", 1047 new OUString(aUStr37), 1048 new OUStringBuffer(arrOUS[0]), new OUString(aUStr23) }, 1049 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]", 1050 new OUString(aUStr7), 1051 new OUStringBuffer(arrOUS[0]), new OUString()}, 1052 {"Appends the string(length less than 16) to the string buffer arrOUS[1]", 1053 new OUString(aUStr7), 1054 new OUStringBuffer(arrOUS[1]), new OUString(aUStr7)}, 1055 {"Appends the string(length more than 16) to the string buffer arrOUS[1]", 1056 new OUString(aUStr2), 1057 new OUStringBuffer(arrOUS[1]), new OUString(aUStr2)}, 1058 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]", 1059 new OUString(aUStr1), 1060 new OUStringBuffer(arrOUS[1]), new OUString(aUStr1) }, 1061 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]", 1062 new OUString(), 1063 new OUStringBuffer(arrOUS[1]), new OUString()}, 1064 {"Appends the string(length less than 16) to the string buffer arrOUS[2]", 1065 new OUString(aUStr7), 1066 new OUStringBuffer(arrOUS[2]), new OUString(aUStr7)}, 1067 {"Appends the string(length more than 16) to the string buffer arrOUS[2]", 1068 new OUString(aUStr2), 1069 new OUStringBuffer(arrOUS[2]), new OUString(aUStr2)}, 1070 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]", 1071 new OUString(aUStr1), 1072 new OUStringBuffer(arrOUS[2]), new OUString(aUStr1) }, 1073 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]", 1074 new OUString(), 1075 new OUStringBuffer(arrOUS[2]), new OUString()}, 1076 {"Appends the string(length less than 16) to the string buffer arrOUS[3]", 1077 new OUString(aUStr7), 1078 new OUStringBuffer(arrOUS[3]), new OUString(aUStr7)}, 1079 {"Appends the string(length more than 16) to the string buffer arrOUS[3]", 1080 new OUString(aUStr2), 1081 new OUStringBuffer(arrOUS[3]), new OUString(aUStr2)}, 1082 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]", 1083 new OUString(aUStr1), 1084 new OUStringBuffer(arrOUS[3]), new OUString(aUStr1) }, 1085 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]", 1086 new OUString(), 1087 new OUStringBuffer(arrOUS[3]), new OUString()}, 1088 {"Appends the string(length less than 16) to the string buffer arrOUS[4]", 1089 new OUString(aUStr29), 1090 new OUStringBuffer(arrOUS[4]), new OUString(aUStr38)}, 1091 {"Appends the string(length more than 16) to the string buffer arrOUS[4]", 1092 new OUString(aUStr39), 1093 new OUStringBuffer(arrOUS[4]), new OUString(aUStr17)}, 1094 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]", 1095 new OUString(aUStr40), 1096 new OUStringBuffer(arrOUS[4]), new OUString(aUStr31) }, 1097 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]", 1098 new OUString(aUStr28), 1099 new OUStringBuffer(arrOUS[4]), new OUString()} 1100 #ifdef WITH_CORE 1101 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ", 1102 new OUString(), 1103 new OUStringBuffer(kSInt32Max), new OUString()} 1104 #endif 1105 }; 1106 1107 1108 sal_Bool res = sal_True; 1109 sal_uInt32 i; 1110 1111 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 1112 { 1113 arrTestCase[i].input1->append( *(arrTestCase[i].input2) ); 1114 sal_Bool lastRes = 1115 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) && 1116 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() ); 1117 1118 c_rtl_tres_state 1119 ( 1120 hRtlTestResult, 1121 lastRes, 1122 arrTestCase[i].comments, 1123 createName( pMeth, "append(const OUString &str)_001", i ) 1124 1125 ); 1126 1127 res &= lastRes; 1128 } 1129 1130 return ( res ); 1131 } 1132 //------------------------------------------------------------------------ 1133 // testing the method append( const sal_Unicode * str ) 1134 //------------------------------------------------------------------------ 1135 1136 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_002( 1137 hTestResult hRtlTestResult) 1138 { 1139 sal_Char methName[MAXBUFLENGTH]; 1140 sal_Char* pMeth = methName; 1141 1142 OUString arrOUS[5]={OUString( aUStr7 ), 1143 OUString(), 1144 OUString( aUStr25 ), 1145 OUString( "\0",0, 1146 kEncodingRTLTextUSASCII, 1147 kConvertFlagsOStringToOUString), 1148 OUString( aUStr28 )}; 1149 1150 typedef struct TestCase 1151 { 1152 sal_Char* comments; 1153 OUString* expVal; 1154 OUStringBuffer* input1; 1155 sal_Unicode* input2; 1156 1157 ~TestCase() { delete input1; delete expVal; } 1158 } TestCase; 1159 1160 TestCase arrTestCase[]={ 1161 1162 {"Appends the string(length less than 16) to the string buffer arrOUS[0]", 1163 new OUString(aUStr1), 1164 new OUStringBuffer(arrOUS[0]), aUStr8 }, 1165 {"Appends the string(length more than 16) to the string buffer arrOUS[0]", 1166 new OUString(aUStr2), 1167 new OUStringBuffer(arrOUS[0]), aUStr36 }, 1168 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]", 1169 new OUString(aUStr37), 1170 new OUStringBuffer(arrOUS[0]), aUStr23 }, 1171 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]", 1172 new OUString(aUStr7), 1173 new OUStringBuffer(arrOUS[0]), aUStr25 }, 1174 {"Appends the string(length less than 16) to the string buffer arrOUS[1]", 1175 new OUString(aUStr7), 1176 new OUStringBuffer(arrOUS[1]), aUStr7 }, 1177 {"Appends the string(length more than 16) to the string buffer arrOUS[1]", 1178 new OUString(aUStr2), 1179 new OUStringBuffer(arrOUS[1]), aUStr2 }, 1180 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]", 1181 new OUString(aUStr1), 1182 new OUStringBuffer(arrOUS[1]), aUStr1 }, 1183 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]", 1184 new OUString(), 1185 new OUStringBuffer(arrOUS[1]), aUStr25 }, 1186 {"Appends the string(length less than 16) to the string buffer arrOUS[2]", 1187 new OUString(aUStr7), 1188 new OUStringBuffer(arrOUS[2]), aUStr7 }, 1189 {"Appends the string(length more than 16) to the string buffer arrOUS[2]", 1190 new OUString(aUStr2), 1191 new OUStringBuffer(arrOUS[2]), aUStr2 }, 1192 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]", 1193 new OUString(aUStr1), 1194 new OUStringBuffer(arrOUS[2]), aUStr1 }, 1195 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]", 1196 new OUString(), 1197 new OUStringBuffer(arrOUS[2]), aUStr25 }, 1198 {"Appends the string(length less than 16) to the string buffer arrOUS[3]", 1199 new OUString(aUStr7), 1200 new OUStringBuffer(arrOUS[3]), aUStr7 }, 1201 {"Appends the string(length more than 16) to the string buffer arrOUS[3]", 1202 new OUString(aUStr2), 1203 new OUStringBuffer(arrOUS[3]), aUStr2 }, 1204 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]", 1205 new OUString(aUStr1), 1206 new OUStringBuffer(arrOUS[3]), aUStr1 }, 1207 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]", 1208 new OUString(), 1209 new OUStringBuffer(arrOUS[3]), aUStr25 }, 1210 {"Appends the string(length less than 16) to the string buffer arrOUS[4]", 1211 new OUString(aUStr29), 1212 new OUStringBuffer(arrOUS[4]), aUStr38 }, 1213 {"Appends the string(length more than 16) to the string buffer arrOUS[4]", 1214 new OUString(aUStr39), 1215 new OUStringBuffer(arrOUS[4]), aUStr17 }, 1216 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]", 1217 new OUString(aUStr40), 1218 new OUStringBuffer(arrOUS[4]), aUStr31 }, 1219 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]", 1220 new OUString(aUStr28), 1221 new OUStringBuffer(arrOUS[4]), aUStr25 } 1222 #ifdef WITH_CORE 1223 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ", 1224 new OUString(), 1225 new OUStringBuffer(kSInt32Max), aUStr25 } 1226 #endif 1227 }; 1228 1229 1230 sal_Bool res = sal_True; 1231 sal_uInt32 i; 1232 1233 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 1234 { 1235 arrTestCase[i].input1->append( arrTestCase[i].input2 ); 1236 sal_Bool lastRes = 1237 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) && 1238 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() ); 1239 1240 c_rtl_tres_state 1241 ( 1242 hRtlTestResult, 1243 lastRes, 1244 arrTestCase[i].comments, 1245 createName( pMeth, "append( const sal_Unicode * str )_002", i ) 1246 1247 ); 1248 1249 res &= lastRes; 1250 } 1251 1252 return ( res ); 1253 } 1254 //------------------------------------------------------------------------ 1255 // testing the method append( const sal_Unicode * str, sal_Int32 len) 1256 //------------------------------------------------------------------------ 1257 1258 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_003( 1259 hTestResult hRtlTestResult) 1260 { 1261 sal_Char methName[MAXBUFLENGTH]; 1262 sal_Char* pMeth = methName; 1263 1264 OUString arrOUS[5]={OUString( aUStr7 ), 1265 OUString(), 1266 OUString( aUStr25 ), 1267 OUString( "\0",0, 1268 kEncodingRTLTextUSASCII, 1269 kConvertFlagsOStringToOUString), 1270 OUString( aUStr28 )}; 1271 1272 typedef struct TestCase 1273 { 1274 sal_Char* comments; 1275 OUString* expVal; 1276 OUStringBuffer* input1; 1277 sal_Unicode* input2; 1278 sal_Int32 input3; 1279 1280 ~TestCase() { delete input1; delete expVal; } 1281 } TestCase; 1282 1283 TestCase arrTestCase[]={ 1284 1285 {"Appends the string(length less than 16) to the string buffer arrOUS[0]", 1286 new OUString(aUStr1), 1287 new OUStringBuffer(arrOUS[0]), aUStr36, 12 }, 1288 {"Appends the string(length more than 16) to the string buffer arrOUS[0]", 1289 new OUString(aUStr2), 1290 new OUStringBuffer(arrOUS[0]), aUStr36, 28 }, 1291 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]", 1292 new OUString(aUStr37), 1293 new OUStringBuffer(arrOUS[0]), aUStr23, 16 }, 1294 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]", 1295 new OUString(aUStr7), 1296 new OUStringBuffer(arrOUS[0]), aUStr2, 0 }, 1297 /* LLA: input3 must null < 0 1298 {"Appends the string(length less than 0) to the string buffer arrOUS[0]", 1299 new OUString(aUStr41), 1300 new OUStringBuffer(arrOUS[0]), aUStr2, -1 }, 1301 */ 1302 {"Appends the string(length less than 16) to the string buffer arrOUS[1]", 1303 new OUString(aUStr7), 1304 new OUStringBuffer(arrOUS[1]), aUStr2, 4 }, 1305 {"Appends the string(length more than 16) to the string buffer arrOUS[1]", 1306 new OUString(aUStr2), 1307 new OUStringBuffer(arrOUS[1]), aUStr2, 32 }, 1308 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]", 1309 new OUString(aUStr1), 1310 new OUStringBuffer(arrOUS[1]), aUStr2, 16 }, 1311 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]", 1312 new OUString(), 1313 new OUStringBuffer(arrOUS[1]), aUStr2, 0 }, 1314 /* LLA: input3 must null < 0 1315 {"Appends the string(length less than 0) to the string buffer arrOUS[1]", 1316 new OUString(), 1317 new OUStringBuffer(arrOUS[1]), aUStr2, -1 }, 1318 */ 1319 {"Appends the string(length less than 16) to the string buffer arrOUS[2]", 1320 new OUString(aUStr7), 1321 new OUStringBuffer(arrOUS[2]), aUStr2, 4 }, 1322 {"Appends the string(length more than 16) to the string buffer arrOUS[2]", 1323 new OUString(aUStr2), 1324 new OUStringBuffer(arrOUS[2]), aUStr2, 32 }, 1325 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]", 1326 new OUString(aUStr1), 1327 new OUStringBuffer(arrOUS[2]), aUStr2, 16 }, 1328 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]", 1329 new OUString(), 1330 new OUStringBuffer(arrOUS[2]), aUStr2, 0 }, 1331 /* LLA: input3 must null < 0 1332 {"Appends the string(length less than 0) to the string buffer arrOUS[2]", 1333 new OUString(), 1334 new OUStringBuffer(arrOUS[2]), aUStr2, -1 }, 1335 */ 1336 {"Appends the string(length less than 16) to the string buffer arrOUS[3]", 1337 new OUString(aUStr7), 1338 new OUStringBuffer(arrOUS[3]), aUStr2, 4 }, 1339 {"Appends the string(length more than 16) to the string buffer arrOUS[3]", 1340 new OUString(aUStr2), 1341 new OUStringBuffer(arrOUS[3]), aUStr2, 32 }, 1342 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]", 1343 new OUString(aUStr1), 1344 new OUStringBuffer(arrOUS[3]), aUStr2, 16 }, 1345 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]", 1346 new OUString(), 1347 new OUStringBuffer(arrOUS[3]), aUStr2, 0 }, 1348 /* LLA: input3 must null < 0 1349 {"Appends the string(length less than 0) to the string buffer arrOUS[3]", 1350 new OUString(), 1351 new OUStringBuffer(arrOUS[3]), aUStr2, -1 }, 1352 */ 1353 {"Appends the string(length less than 16) to the string buffer arrOUS[4]", 1354 new OUString(aUStr29), 1355 new OUStringBuffer(arrOUS[4]), aUStr38, 7 }, 1356 {"Appends the string(length more than 16) to the string buffer arrOUS[4]", 1357 new OUString(aUStr39), 1358 new OUStringBuffer(arrOUS[4]), aUStr17, 22 }, 1359 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]", 1360 new OUString(aUStr40), 1361 new OUStringBuffer(arrOUS[4]), aUStr31, 16 }, 1362 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]", 1363 new OUString(aUStr28), 1364 new OUStringBuffer(arrOUS[4]), aUStr2, 0 }, 1365 /* LLA: input3 must null < 0 1366 {"Appends the string(length less than 0) to the string buffer arrOUS[4]", 1367 new OUString(aUStr42), 1368 new OUStringBuffer(arrOUS[4]), aUStr2, -1 } 1369 */ 1370 #ifdef WITH_CORE 1371 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ", 1372 new OUString(), 1373 new OUStringBuffer(kSInt32Max), aUStr25 } 1374 #endif 1375 }; 1376 1377 1378 sal_Bool res = sal_True; 1379 sal_uInt32 i; 1380 1381 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 1382 { 1383 arrTestCase[i].input1->append( 1384 arrTestCase[i].input2, arrTestCase[i].input3); 1385 sal_Bool lastRes = 1386 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) && 1387 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() ); 1388 1389 c_rtl_tres_state 1390 ( 1391 hRtlTestResult, 1392 lastRes, 1393 arrTestCase[i].comments, 1394 createName( pMeth, "append( const sal_Unicode * str, sal_Int32 len)_003", i ) 1395 1396 ); 1397 1398 res &= lastRes; 1399 } 1400 1401 return ( res ); 1402 } 1403 //------------------------------------------------------------------------ 1404 // testing the method append(sal_Bool b) 1405 //------------------------------------------------------------------------ 1406 1407 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_004( 1408 hTestResult hRtlTestResult) 1409 { 1410 sal_Char methName[MAXBUFLENGTH]; 1411 sal_Char* pMeth = methName; 1412 1413 OUString arrOUS[5]={OUString( aUStr7 ), 1414 OUString(), 1415 OUString( aUStr25 ), 1416 OUString( "\0",0, 1417 kEncodingRTLTextUSASCII, 1418 kConvertFlagsOStringToOUString), 1419 OUString( aUStr28 )}; 1420 1421 typedef struct TestCase 1422 { 1423 sal_Char* comments; 1424 OUString* expVal; 1425 OUStringBuffer* input1; 1426 sal_Bool input2; 1427 1428 ~TestCase() { delete input1; delete expVal; } 1429 } TestCase; 1430 1431 TestCase arrTestCase[]={ 1432 1433 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[0]", 1434 new OUString(aUStr45), 1435 new OUStringBuffer(arrOUS[0]), sal_True }, 1436 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[0]", 1437 new OUString(aUStr46), 1438 new OUStringBuffer(arrOUS[0]), sal_False }, 1439 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[1]", 1440 new OUString(aUStr47), 1441 new OUStringBuffer(arrOUS[1]), sal_True }, 1442 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[1]", 1443 new OUString(aUStr48), 1444 new OUStringBuffer(arrOUS[1]), sal_False }, 1445 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[2]", 1446 new OUString(aUStr47), 1447 new OUStringBuffer(arrOUS[2]), sal_True }, 1448 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[2]", 1449 new OUString(aUStr48), 1450 new OUStringBuffer(arrOUS[2]), sal_False }, 1451 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[3]", 1452 new OUString(aUStr47), 1453 new OUStringBuffer(arrOUS[3]), sal_True }, 1454 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[3]", 1455 new OUString(aUStr48), 1456 new OUStringBuffer(arrOUS[3]), sal_False }, 1457 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[4]", 1458 new OUString(aUStr49), 1459 new OUStringBuffer(arrOUS[4]), sal_True }, 1460 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[4]", 1461 new OUString(aUStr50), 1462 new OUStringBuffer(arrOUS[4]), sal_False } 1463 #ifdef WITH_CORE 1464 ,{"Appends the sal_Bool(sal_True) to the string buffer(with INT_MAX) ", 1465 new OUString(aUStr47), 1466 new OUStringBuffer(kSInt32Max), sal_True }, 1467 {"Appends the sal_Bool(sal_False) to the string buffer(with INT_MAX) ", 1468 new OUString(aUStr48), 1469 new OUStringBuffer(kSInt32Max), sal_False } 1470 #endif 1471 }; 1472 1473 1474 sal_Bool res = sal_True; 1475 sal_uInt32 i; 1476 1477 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 1478 { 1479 arrTestCase[i].input1->append( 1480 arrTestCase[i].input2 ); 1481 sal_Bool lastRes = 1482 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) && 1483 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() ); 1484 1485 c_rtl_tres_state 1486 ( 1487 hRtlTestResult, 1488 lastRes, 1489 arrTestCase[i].comments, 1490 createName( pMeth, "append( sal_Bool b)_004", i ) 1491 1492 ); 1493 1494 res &= lastRes; 1495 } 1496 1497 return ( res ); 1498 } 1499 1500 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appends( 1501 hTestResult hRtlTestResult ) 1502 { 1503 c_rtl_tres_state_start( hRtlTestResult, "appends"); 1504 sal_Bool bTSState = test_rtl_OUStringBuffer_append_001( hRtlTestResult ); 1505 bTSState &= test_rtl_OUStringBuffer_append_002( hRtlTestResult); 1506 bTSState &= test_rtl_OUStringBuffer_append_003( hRtlTestResult); 1507 bTSState &= test_rtl_OUStringBuffer_append_004( hRtlTestResult); 1508 1509 c_rtl_tres_state_end( hRtlTestResult, "appends"); 1510 // return( bTSState ); 1511 } 1512 //------------------------------------------------------------------------ 1513 // testing the method appendAscii( const sal_Char * str ) 1514 //------------------------------------------------------------------------ 1515 1516 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_001( 1517 hTestResult hRtlTestResult) 1518 { 1519 sal_Char methName[MAXBUFLENGTH]; 1520 sal_Char* pMeth = methName; 1521 1522 OUString arrOUS[5]={OUString( aUStr7 ), 1523 OUString(), 1524 OUString( aUStr25 ), 1525 OUString( "\0",0, 1526 kEncodingRTLTextUSASCII, 1527 kConvertFlagsOStringToOUString), 1528 OUString( aUStr28 )}; 1529 1530 typedef struct TestCase 1531 { 1532 sal_Char* comments; 1533 OUString* expVal; 1534 OUStringBuffer* input1; 1535 const sal_Char* input2; 1536 1537 ~TestCase() { delete input1; delete expVal; } 1538 } TestCase; 1539 1540 TestCase arrTestCase[]={ 1541 1542 {"Appends the string(length less than 16) to the string buffer arrOUS[0]", 1543 new OUString(aUStr1), 1544 new OUStringBuffer(arrOUS[0]), kTestStr8 }, 1545 {"Appends the string(length more than 16) to the string buffer arrOUS[0]", 1546 new OUString(aUStr2), 1547 new OUStringBuffer(arrOUS[0]), kTestStr36 }, 1548 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]", 1549 new OUString(aUStr37), 1550 new OUStringBuffer(arrOUS[0]), kTestStr23 }, 1551 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]", 1552 new OUString(aUStr7), 1553 new OUStringBuffer(arrOUS[0]), kTestStr25 }, 1554 {"Appends the string(length less than 16) to the string buffer arrOUS[1]", 1555 new OUString(aUStr7), 1556 new OUStringBuffer(arrOUS[1]), kTestStr7 }, 1557 {"Appends the string(length more than 16) to the string buffer arrOUS[1]", 1558 new OUString(aUStr2), 1559 new OUStringBuffer(arrOUS[1]), kTestStr2 }, 1560 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]", 1561 new OUString(aUStr1), 1562 new OUStringBuffer(arrOUS[1]), kTestStr1 }, 1563 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]", 1564 new OUString(), 1565 new OUStringBuffer(arrOUS[1]), kTestStr25 }, 1566 {"Appends the string(length less than 16) to the string buffer arrOUS[2]", 1567 new OUString(aUStr7), 1568 new OUStringBuffer(arrOUS[2]), kTestStr7 }, 1569 {"Appends the string(length more than 16) to the string buffer arrOUS[2]", 1570 new OUString(aUStr2), 1571 new OUStringBuffer(arrOUS[2]), kTestStr2 }, 1572 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]", 1573 new OUString(aUStr1), 1574 new OUStringBuffer(arrOUS[2]), kTestStr1 }, 1575 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]", 1576 new OUString(), 1577 new OUStringBuffer(arrOUS[2]), kTestStr25 }, 1578 {"Appends the string(length less than 16) to the string buffer arrOUS[3]", 1579 new OUString(aUStr7), 1580 new OUStringBuffer(arrOUS[3]), kTestStr7 }, 1581 {"Appends the string(length more than 16) to the string buffer arrOUS[3]", 1582 new OUString(aUStr2), 1583 new OUStringBuffer(arrOUS[3]), kTestStr2 }, 1584 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]", 1585 new OUString(aUStr1), 1586 new OUStringBuffer(arrOUS[3]), kTestStr1 }, 1587 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]", 1588 new OUString(), 1589 new OUStringBuffer(arrOUS[3]), kTestStr25 }, 1590 {"Appends the string(length less than 16) to the string buffer arrOUS[4]", 1591 new OUString(aUStr29), 1592 new OUStringBuffer(arrOUS[4]), kTestStr38 }, 1593 {"Appends the string(length more than 16) to the string buffer arrOUS[4]", 1594 new OUString(aUStr39), 1595 new OUStringBuffer(arrOUS[4]), kTestStr17 }, 1596 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]", 1597 new OUString(aUStr40), 1598 new OUStringBuffer(arrOUS[4]), kTestStr31 }, 1599 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]", 1600 new OUString(aUStr28), 1601 new OUStringBuffer(arrOUS[4]), kTestStr25 } 1602 /*{"Appends the string(with special characters) to the string buffer arrOUS[4]", 1603 new OUString(aUStr43), 1604 new OUStringBuffer(arrOUS[4]), kTestStr44 }*/ 1605 #ifdef WITH_CORE 1606 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ", 1607 new OUString(), 1608 new OUStringBuffer(kSInt32Max), kTestStr25 } 1609 #endif 1610 1611 }; 1612 1613 1614 sal_Bool res = sal_True; 1615 sal_uInt32 i; 1616 1617 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 1618 { 1619 arrTestCase[i].input1->appendAscii( arrTestCase[i].input2 ); 1620 sal_Bool lastRes = 1621 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) && 1622 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() ); 1623 1624 c_rtl_tres_state 1625 ( 1626 hRtlTestResult, 1627 lastRes, 1628 arrTestCase[i].comments, 1629 createName( pMeth, "appendAscii_001", i ) 1630 ); 1631 1632 res &= lastRes; 1633 } 1634 return ( res ); 1635 } 1636 //------------------------------------------------------------------------ 1637 // testing the method appendAscii( const sal_Char * str, sal_Int32 len) 1638 //------------------------------------------------------------------------ 1639 1640 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_002( 1641 hTestResult hRtlTestResult) 1642 { 1643 sal_Char methName[MAXBUFLENGTH]; 1644 sal_Char* pMeth = methName; 1645 1646 OUString arrOUS[5]={OUString( aUStr7 ), 1647 OUString(), 1648 OUString( aUStr25 ), 1649 OUString( "\0",0, 1650 kEncodingRTLTextUSASCII, 1651 kConvertFlagsOStringToOUString), 1652 OUString( aUStr28 )}; 1653 1654 typedef struct TestCase 1655 { 1656 sal_Char* comments; 1657 OUString* expVal; 1658 OUStringBuffer* input1; 1659 const sal_Char* input2; 1660 sal_Int32 input3; 1661 1662 ~TestCase() { delete input1; delete expVal; } 1663 } TestCase; 1664 1665 TestCase arrTestCase[]={ 1666 1667 {"Appends the string(length less than 16) to the string buffer arrOUS[0]", 1668 new OUString(aUStr1), 1669 new OUStringBuffer(arrOUS[0]), kTestStr36, 12 }, 1670 {"Appends the string(length more than 16) to the string buffer arrOUS[0]", 1671 new OUString(aUStr2), 1672 new OUStringBuffer(arrOUS[0]), kTestStr36, 28 }, 1673 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]", 1674 new OUString(aUStr37), 1675 new OUStringBuffer(arrOUS[0]), kTestStr23, 16 }, 1676 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]", 1677 new OUString(aUStr7), 1678 new OUStringBuffer(arrOUS[0]), kTestStr2, 0 }, 1679 /* LLA: input3 must null < 0 1680 {"Appends the string(length less than 0) to the string buffer arrOUS[0]", 1681 new OUString(aUStr41), 1682 new OUStringBuffer(arrOUS[0]), kTestStr2, -1 }, 1683 */ 1684 {"Appends the string(length less than 16) to the string buffer arrOUS[1]", 1685 new OUString(aUStr7), 1686 new OUStringBuffer(arrOUS[1]), kTestStr2, 4 }, 1687 {"Appends the string(length more than 16) to the string buffer arrOUS[1]", 1688 new OUString(aUStr2), 1689 new OUStringBuffer(arrOUS[1]), kTestStr2, 32 }, 1690 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]", 1691 new OUString(aUStr1), 1692 new OUStringBuffer(arrOUS[1]), kTestStr2, 16 }, 1693 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]", 1694 new OUString(), 1695 new OUStringBuffer(arrOUS[1]), kTestStr2, 0 }, 1696 /* LLA: input3 must null < 0 1697 {"Appends the string(length less than 0) to the string buffer arrOUS[1]", 1698 new OUString(), 1699 new OUStringBuffer(arrOUS[1]), kTestStr2, -1 }, 1700 */ 1701 {"Appends the string(length less than 16) to the string buffer arrOUS[2]", 1702 new OUString(aUStr7), 1703 new OUStringBuffer(arrOUS[2]), kTestStr2, 4 }, 1704 {"Appends the string(length more than 16) to the string buffer arrOUS[2]", 1705 new OUString(aUStr2), 1706 new OUStringBuffer(arrOUS[2]), kTestStr2, 32 }, 1707 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]", 1708 new OUString(aUStr1), 1709 new OUStringBuffer(arrOUS[2]), kTestStr2, 16 }, 1710 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]", 1711 new OUString(), 1712 new OUStringBuffer(arrOUS[2]), kTestStr2, 0 }, 1713 /* LLA: input3 must null < 0 1714 {"Appends the string(length less than 0) to the string buffer arrOUS[2]", 1715 new OUString(), 1716 new OUStringBuffer(arrOUS[2]), kTestStr2, -1 }, 1717 */ 1718 {"Appends the string(length less than 16) to the string buffer arrOUS[3]", 1719 new OUString(aUStr7), 1720 new OUStringBuffer(arrOUS[3]), kTestStr2, 4 }, 1721 {"Appends the string(length more than 16) to the string buffer arrOUS[3]", 1722 new OUString(aUStr2), 1723 new OUStringBuffer(arrOUS[3]), kTestStr2, 32 }, 1724 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]", 1725 new OUString(aUStr1), 1726 new OUStringBuffer(arrOUS[3]), kTestStr2, 16 }, 1727 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]", 1728 new OUString(), 1729 new OUStringBuffer(arrOUS[3]), kTestStr2, 0 }, 1730 /* LLA: input3 must null < 0 1731 {"Appends the string(length less than 0) to the string buffer arrOUS[3]", 1732 new OUString(), 1733 new OUStringBuffer(arrOUS[3]), kTestStr2, -1 }, 1734 */ 1735 {"Appends the string(length less than 16) to the string buffer arrOUS[4]", 1736 new OUString(aUStr29), 1737 new OUStringBuffer(arrOUS[4]), kTestStr38, 7 }, 1738 {"Appends the string(length more than 16) to the string buffer arrOUS[4]", 1739 new OUString(aUStr39), 1740 new OUStringBuffer(arrOUS[4]), kTestStr17, 22 }, 1741 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]", 1742 new OUString(aUStr40), 1743 new OUStringBuffer(arrOUS[4]), kTestStr31, 16 }, 1744 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]", 1745 new OUString(aUStr28), 1746 new OUStringBuffer(arrOUS[4]), kTestStr2, 0 }, 1747 /* LLA: input3 must null < 0 1748 {"Appends the string(length less than 0) to the string buffer arrOUS[4]", 1749 new OUString(aUStr42), 1750 new OUStringBuffer(arrOUS[4]), kTestStr2, -1 } 1751 */ 1752 #ifdef WITH_CORE 1753 ,{"Appends the string(length equal to 0) to the string buffer(with INT_MAX) ", 1754 new OUString(), 1755 new OUStringBuffer(kSInt32Max), kTestStr25 } 1756 #endif 1757 }; 1758 1759 1760 sal_Bool res = sal_True; 1761 sal_uInt32 i; 1762 1763 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) 1764 { 1765 arrTestCase[i].input1->appendAscii( 1766 arrTestCase[i].input2, arrTestCase[i].input3); 1767 sal_Bool lastRes = 1768 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) && 1769 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() ); 1770 1771 c_rtl_tres_state 1772 ( 1773 hRtlTestResult, 1774 lastRes, 1775 arrTestCase[i].comments, 1776 createName( pMeth, "appendAscii_002", i ) 1777 1778 ); 1779 1780 res &= lastRes; 1781 } 1782 return ( res ); 1783 } 1784 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appendAsciis( 1785 hTestResult hRtlTestResult ) 1786 { 1787 c_rtl_tres_state_start( hRtlTestResult, "appendAsciis"); 1788 sal_Bool bTSState = test_rtl_OUStringBuffer_appendAscii_001( hRtlTestResult ); 1789 bTSState &= test_rtl_OUStringBuffer_appendAscii_002( hRtlTestResult); 1790 1791 c_rtl_tres_state_end( hRtlTestResult, "appendAsciis"); 1792 // return( bTSState ); 1793 } 1794 // ----------------------------------------------------------------------------- 1795 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer( hTestResult hRtlTestResult ) 1796 { 1797 1798 c_rtl_tres_state_start(hRtlTestResult, "rtl_OUStringBuffer" ); 1799 1800 test_rtl_OUStringBuffer_ctors( hRtlTestResult ); 1801 test_rtl_OUStringBuffer_makeStringAndClear( hRtlTestResult ); 1802 test_rtl_OUStringBuffer_getLength( hRtlTestResult ); 1803 test_rtl_OUStringBuffer_getCapacity( hRtlTestResult ); 1804 test_rtl_OUStringBuffer_ensureCapacity( hRtlTestResult ); 1805 test_rtl_OUStringBuffer_setLength( hRtlTestResult ); 1806 test_rtl_OUStringBuffer_charAt( hRtlTestResult ); 1807 test_rtl_OUStringBuffer_csuc( hRtlTestResult ); 1808 test_rtl_OUStringBuffer_getStr( hRtlTestResult ); 1809 test_rtl_OUStringBuffer_setCharAt( hRtlTestResult ); 1810 test_rtl_OUStringBuffer_appends( hRtlTestResult ); 1811 test_rtl_OUStringBuffer_appendAsciis( hRtlTestResult ); 1812 1813 c_rtl_tres_state_end(hRtlTestResult, "rtl_OUStringBuffer"); 1814 } 1815 1816 // ----------------------------------------------------------------------------- 1817 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc) 1818 { 1819 if (_pFunc) 1820 { 1821 (_pFunc)(&test_rtl_OUStringBuffer, ""); 1822 } 1823 } 1824