update credits
[LibreOffice.git] / sal / qa / rtl_strings / rtl_OUStringBuffer.cxx
blob56d8926662c5d9a3ca711110afd60c379d252db5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
21 #include <testshl/tresstatewrapper.hxx>
22 #include <rtl/string.hxx>
23 #include <rtl/ustring.h>
24 #include <rtl/ustring.hxx>
25 #include <rtl/ustrbuf.h>
26 #include <rtl/ustrbuf.hxx>
27 #include <osl/thread.h>
28 #include <rtl_String_Const.h>
29 #include <rtl_String_Utils.hxx>
30 #include "stdio.h"
32 using ::rtl::OUString;
33 using ::rtl::OUStringBuffer;
35 //------------------------------------------------------------------------
36 // test classes
37 //------------------------------------------------------------------------
38 const int MAXBUFLENGTH = 255;
39 //------------------------------------------------------------------------
40 // helper functions
41 //------------------------------------------------------------------------
42 static void unused()
44 (void)kBinaryNumsStr;
45 (void)kOctolNumsStr;
46 (void)kDecimalNumsStr;
47 (void)kHexDecimalNumsStr;
48 (void)kBase36NumsStr;
49 (void)inputChar;
50 (void)input1StrDefault;
51 (void)input1StrNormal;
52 (void)input1StrLastDefault;
53 (void)input1StrLastNormal;
54 unused();
57 //------------------------------------------------------------------------
58 // testing constructors
59 //------------------------------------------------------------------------
60 static sal_Bool test_rtl_OUStringBuffer_ctor_001( hTestResult hRtlTestResult )
63 ::rtl::OUStringBuffer aUStrBuf;
65 bool b1 =
66 aUStrBuf.isEmpty() &&
67 ! *(aUStrBuf.getStr()) && aUStrBuf.getCapacity() == 16;
69 ::rtl::OUStringBuffer aUStrBuf2(0);
71 bool b2 =
72 aUStrBuf2.isEmpty() &&
73 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: !!! */ 0;
75 return
77 c_rtl_tres_state
79 hRtlTestResult,
80 b1 && b2,
81 "New OUStringBuffer containing no characters",
82 "ctor_001"
87 //------------------------------------------------------------------------
89 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_002(
90 hTestResult hRtlTestResult )
92 ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 );
93 ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp );
94 sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr());
95 return
97 c_rtl_tres_state
99 hRtlTestResult,
100 aUStrBuf.getLength()==aUStrBuftmp.getLength() &&
101 aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() && res ,
102 "New OUStringBuffer from another OUStringBuffer",
103 "ctor_002"
107 //------------------------------------------------------------------------
109 /* static */
110 sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_003(
111 hTestResult hRtlTestResult )
113 ::rtl::OUStringBuffer aUStrBuf1(kTestStr2Len);
114 ::rtl::OUStringBuffer aUStrBuf2(0);
115 ::rtl::OUStringBuffer aUStrBuf3(kNonSInt32Max);
118 bool b1 =
119 aUStrBuf1.isEmpty() &&
120 ! *(aUStrBuf1.getStr()) && aUStrBuf1.getCapacity() == kTestStr2Len ;
122 bool b2 =
123 aUStrBuf2.isEmpty() &&
124 ! *(aUStrBuf2.getStr()) && aUStrBuf2.getCapacity() == /* LLA: ??? 16 */ 0;
126 bool b3 =
127 aUStrBuf3.isEmpty() &&
128 ! *(aUStrBuf3.getStr()) && aUStrBuf3.getCapacity() == kNonSInt32Max;
130 return
132 c_rtl_tres_state
134 hRtlTestResult,
135 b1 && b2 && b3,
136 "New OUStringBuffer containing no characters and contain assigned capacity",
137 "ctor_003( will core dump,because the kSInt32Max )"
143 //------------------------------------------------------------------------
145 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_004(
146 hTestResult hRtlTestResult)
148 ::rtl::OUString aUStrtmp( aUStr1 );
149 ::rtl::OUStringBuffer aUStrBuf( aUStrtmp );
150 sal_Int32 leg = aUStrBuf.getLength();
151 return
153 c_rtl_tres_state
155 hRtlTestResult,
156 aUStrBuf.getStr() == aUStrtmp &&
157 leg == aUStrtmp.pData->length &&
158 aUStrBuf.getCapacity() == leg+16 ,
159 "New OUStringBuffer from OUstring",
160 "ctor_004"
165 static sal_Bool SAL_CALL test_rtl_OUStringBuffer_ctor_005(
166 hTestResult hRtlTestResult)
168 ::rtl::OUStringBuffer aUStrBuftmp( aUStr1 );
169 ::rtl::OUString aUStrtmp = aUStrBuftmp.makeStringAndClear();
170 ::rtl::OUStringBuffer aUStrBuf( aUStrBuftmp );
171 sal_Bool res = cmpustr(aUStrBuftmp.getStr(),aUStrBuf.getStr());
172 sal_Int32 leg = aUStrBuf.getLength();
173 return
175 c_rtl_tres_state
177 hRtlTestResult,
178 aUStrBuf.getLength()==aUStrBuftmp.getLength() &&
179 aUStrBuf.getCapacity() == aUStrBuftmp.getCapacity() &&
180 res && leg == 0,
181 "New OUStringBuffer from another OUStringBuffer after makeClearFromString",
182 "ctor_005"
187 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ctors(
188 hTestResult hRtlTestResult )
190 c_rtl_tres_state_start( hRtlTestResult, "ctors");
191 sal_Bool DCState = test_ini_uString();
192 (void)DCState;
193 sal_Bool bTSState = test_rtl_OUStringBuffer_ctor_001( hRtlTestResult );
194 bTSState &= test_rtl_OUStringBuffer_ctor_002( hRtlTestResult);
195 bTSState &= test_rtl_OUStringBuffer_ctor_003( hRtlTestResult);
196 bTSState &= test_rtl_OUStringBuffer_ctor_004( hRtlTestResult);
197 bTSState &= test_rtl_OUStringBuffer_ctor_005( hRtlTestResult);
199 c_rtl_tres_state_end( hRtlTestResult, "ctors");
200 // return( bTSState );
203 //------------------------------------------------------------------------
204 // testing the method makeStringAndClear()
205 //------------------------------------------------------------------------
206 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_makeStringAndClear(
207 hTestResult hRtlTestResult )
209 c_rtl_tres_state_start( hRtlTestResult, "makeStringAndClear");
210 sal_Char methName[MAXBUFLENGTH];
211 sal_Char* pMeth = methName;
213 typedef struct TestCase
215 sal_Char* comments;
216 OUString* expVal;
217 OUStringBuffer* input1;
219 ~TestCase() { delete input1;}
220 } TestCase;
222 OUString arrOUS[6]={
223 OUString( aUStr1 ),
224 OUString( aUStr14 ),
225 OUString( aUStr25 ),
226 OUString( aUStr27 ),
227 OUString( aUStr29 ),
228 OUString( "\0",1,
229 kEncodingRTLTextUSASCII,
230 kConvertFlagsOStringToOUString)
233 TestCase arrTestCase[]={
235 {"two empty strings(def. constructor)", new OUString(),
236 new OUStringBuffer()},
237 {"two empty strings(with a argu)", new OUString(),
238 new OUStringBuffer(26)},
239 {"normal string", new OUString(arrOUS[0]),
240 new OUStringBuffer(arrOUS[0])},
241 {"string with space ", new OUString(arrOUS[1]),
242 new OUStringBuffer(arrOUS[1])},
243 {"empty string", new OUString(arrOUS[2]),
244 new OUStringBuffer(arrOUS[2])},
245 {"string with a character", new OUString(arrOUS[3]),
246 new OUStringBuffer(arrOUS[3])},
247 {"string with special characters", new OUString(arrOUS[4]),
248 new OUStringBuffer(arrOUS[4])},
249 {"string only with (\0)", new OUString(arrOUS[5]),
250 new OUStringBuffer(arrOUS[5])}
253 sal_Bool res = sal_True;
254 sal_uInt32 i;
256 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
258 sal_Bool lastRes =
259 ( arrTestCase[i].input1->makeStringAndClear() ==
260 *( arrTestCase[i].expVal ));
261 lastRes = lastRes && ( arrTestCase[i].input1->getCapacity() == 0 );
262 lastRes = lastRes && ( *(arrTestCase[i].input1->getStr()) == '\0' );
264 c_rtl_tres_state
266 hRtlTestResult,
267 lastRes,
268 arrTestCase[i].comments,
269 createName( pMeth, "makeStringAndClear", i )
272 res &= lastRes;
274 c_rtl_tres_state_end( hRtlTestResult, "makeStringAndClear");
275 // return (res);
277 //------------------------------------------------------------------------
278 // testing the method getLength
279 //------------------------------------------------------------------------
281 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getLength(
282 hTestResult hRtlTestResult)
284 c_rtl_tres_state_start( hRtlTestResult, "getLength");
285 sal_Char methName[MAXBUFLENGTH];
286 sal_Char* pMeth = methName;
288 OUString arrOUS[6]={OUString( aUStr1 ),
289 OUString( "1",1,
290 kEncodingRTLTextUSASCII,
291 kConvertFlagsOStringToOUString),
292 OUString(),
293 OUString( "",0,
294 kEncodingRTLTextUSASCII,
295 kConvertFlagsOStringToOUString),
296 OUString( "\0",1,
297 kEncodingRTLTextUSASCII,
298 kConvertFlagsOStringToOUString),
299 OUString( aUStr2 )};
301 typedef struct TestCase
303 sal_Char* comments;
304 sal_Int32 expVal;
305 OUStringBuffer* input;
306 ~TestCase() { delete input;}
307 } TestCase;
309 TestCase arrTestCase[]={
311 {"length of ascii string", kTestStr1Len,
312 new OUStringBuffer(arrOUS[0]) },
313 {"length of ascci string of size 1", 1,
314 new OUStringBuffer(arrOUS[1])},
315 {"length of empty string", 0,
316 new OUStringBuffer(arrOUS[2])},
317 {"length of empty string (empty ascii string arg)",0,
318 new OUStringBuffer(arrOUS[3])},
319 {"length of empty string (string arg = \"\\0\")", 1,
320 new OUStringBuffer(arrOUS[4])},
321 {"length(>16) of ascii string", kTestStr2Len,
322 new OUStringBuffer(arrOUS[5]) },
323 {"length of empty string (default constructor)", 0,
324 new OUStringBuffer()},
325 {"length of empty string (with capacity)", 0,
326 new OUStringBuffer(26)}
330 sal_Bool res = sal_True;
331 sal_uInt32 i;
333 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
335 sal_Int32 length = arrTestCase[i].input->getLength();
336 sal_Bool lastRes = (length == arrTestCase[i].expVal);
337 c_rtl_tres_state
339 hRtlTestResult,
340 lastRes,
341 arrTestCase[i].comments,
342 createName( pMeth, "getLength", i )
345 res &= lastRes;
347 c_rtl_tres_state_end( hRtlTestResult, "getLength");
348 // return ( res );
350 //------------------------------------------------------------------------
351 // testing the method getCapacity()
352 //------------------------------------------------------------------------
354 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getCapacity(
355 hTestResult hRtlTestResult)
357 c_rtl_tres_state_start( hRtlTestResult, "getCapacity");
358 sal_Char methName[MAXBUFLENGTH];
359 sal_Char* pMeth = methName;
361 OUString arrOUS[6]={OUString( aUStr1 ),
362 OUString( "1",1,
363 kEncodingRTLTextUSASCII,
364 kConvertFlagsOStringToOUString),
365 OUString(),
366 OUString( "",0,
367 kEncodingRTLTextUSASCII,
368 kConvertFlagsOStringToOUString),
369 OUString( "\0",1,
370 kEncodingRTLTextUSASCII,
371 kConvertFlagsOStringToOUString),
372 OUString( aUStr2 )};
374 typedef struct TestCase
376 sal_Char* comments;
377 sal_Int32 expVal;
378 OUStringBuffer* input;
379 ~TestCase() { delete input;}
380 } TestCase;
382 TestCase arrTestCase[]={
384 {"capacity of ascii string", kTestStr1Len+16,
385 new OUStringBuffer(arrOUS[0]) },
386 {"capacity of ascci string of size 1", 1+16,
387 new OUStringBuffer(arrOUS[1]) },
388 {"capacity of empty string", 0+16,
389 new OUStringBuffer(arrOUS[2]) },
390 {"capacity of empty string (empty ascii string arg)",0+16,
391 new OUStringBuffer(arrOUS[3]) },
392 {"capacity of empty string (string arg = \"\\0\")", 1+16,
393 new OUStringBuffer(arrOUS[4]) },
394 {"capacity(>16) of ascii string", kTestStr2Len+16,
395 new OUStringBuffer(arrOUS[5]) },
396 {"capacity of empty string (default constructor)", 16,
397 new OUStringBuffer() },
398 {"capacity of empty string (with capacity -2147483648)", kNonSInt32Max,
399 new OUStringBuffer(kNonSInt32Max) },
400 {"capacity of empty string (with capacity 16)", 16,
401 new OUStringBuffer(16) },
402 {"capacity of empty string (with capacity 6)", 6,
403 new OUStringBuffer(6) },
404 {"capacity of empty string (with capacity 0)", 0,
405 new OUStringBuffer(0) },
406 {"capacity of empty string (with capacity -2)", -2,
407 new OUStringBuffer(-2) }
411 sal_Bool res = sal_True;
412 sal_uInt32 i;
414 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
416 sal_Int32 length = arrTestCase[i].input->getCapacity();
417 sal_Bool lastRes = (length == arrTestCase[i].expVal);
418 c_rtl_tres_state
420 hRtlTestResult,
421 lastRes,
422 arrTestCase[i].comments,
423 createName( pMeth, "getCapacity", i )
426 res &= lastRes;
428 c_rtl_tres_state_end( hRtlTestResult, "getCapacity");
429 // return ( res );
431 //------------------------------------------------------------------------
432 // testing the method ensureCapacity(sal_Int32 minimumCapacity)
433 //------------------------------------------------------------------------
435 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_ensureCapacity(
436 hTestResult hRtlTestResult)
438 c_rtl_tres_state_start( hRtlTestResult, "ensureCapacity");
439 sal_Char methName[MAXBUFLENGTH];
440 sal_Char* pMeth = methName;
442 typedef struct TestCase
444 sal_Char* comments;
445 sal_Int32 expVal;
446 OUStringBuffer* input1;
447 sal_Int32 input2;
448 ~TestCase() { delete input1;}
449 } TestCase;
451 TestCase arrTestCase[]={
453 {"capacity equal to 16, minimum is 5 ", 16,
454 new OUStringBuffer(), 5 },
455 {"capacity equal to 16, minimum is -5", 16,
456 new OUStringBuffer(), -5},
457 {"capacity equal to 16, minimum is 0", 16,
458 new OUStringBuffer(), 0},
459 {"capacity equal to 16, minimum is 20", 20, //the testcase is based on comments
460 new OUStringBuffer(), 20},
461 {"capacity equal to 16, minimum is 50", 50,
462 new OUStringBuffer(), 50},
463 {"capacity equal to 6, minimum is 20", 20,
464 new OUStringBuffer(6), 20 },
465 {"capacity equal to 6, minimum is 2", 6,
466 new OUStringBuffer(6), 2},
467 {"capacity equal to 6, minimum is -6", 6,
468 new OUStringBuffer(6), -6},
469 {"capacity equal to 6, minimum is -6", 10, //the testcase is based on comments
470 new OUStringBuffer(6), 10},
471 {"capacity equal to 0, minimum is 6", 6,
472 new OUStringBuffer(0), 6},
473 {"capacity equal to 0, minimum is 1", 2, //the testcase is based on comments
474 new OUStringBuffer(0), 1},
476 {"capacity equal to 0, minimum is -1", 0,
477 new OUStringBuffer(0), -1},
479 {"capacity equal to -2147483648, minimum is 65535", 65535,
480 new OUStringBuffer(kNonSInt32Max), 65535},
481 {"capacity equal to -2147483648, minimum is -1", 2,
482 new OUStringBuffer(kNonSInt32Max), -1},
483 {"capacity equal to -2147483648, minimum is 0", 2,
484 new OUStringBuffer(kNonSInt32Max), 0},
485 {"capacity equal to -2147483648, minimum is -2147483648", kNonSInt32Max,
486 new OUStringBuffer(kNonSInt32Max), kNonSInt32Max}
490 sal_Bool res = sal_True;
491 sal_uInt32 i;
493 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
495 arrTestCase[i].input1->ensureCapacity(arrTestCase[i].input2);
496 sal_Int32 length = arrTestCase[i].input1->getCapacity();
497 sal_Bool lastRes = (length == arrTestCase[i].expVal);
499 c_rtl_tres_state
501 hRtlTestResult,
502 lastRes,
503 arrTestCase[i].comments,
504 createName( pMeth, "ensureCapacity", i )
507 res &= lastRes;
509 c_rtl_tres_state_end( hRtlTestResult, "ensureCapacity");
510 // return ( res );
512 //------------------------------------------------------------------------
513 // testing the method setLength(sal_Int32 newLength)
514 //------------------------------------------------------------------------
516 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_setLength(
517 hTestResult hRtlTestResult)
519 c_rtl_tres_state_start( hRtlTestResult, "setLength");
520 sal_Char methName[MAXBUFLENGTH];
521 sal_Char* pMeth = methName;
523 OUString arrOUS[6]={OUString( aUStr1 ),
524 OUString( aUStr27),
525 OUString(),
526 OUString( "",0,
527 kEncodingRTLTextUSASCII,
528 kConvertFlagsOStringToOUString),
529 OUString( "\0",1,
530 kEncodingRTLTextUSASCII,
531 kConvertFlagsOStringToOUString),
532 OUString( aUStr2 )};
534 typedef struct TestCase
536 sal_Char* comments;
537 sal_Int32 expVal1;
538 OUString* expVal2;
539 sal_Int32 expVal3;
540 OUStringBuffer* input1;
541 sal_Int32 input2;
542 ~TestCase() { delete input1; delete expVal2;}
543 } TestCase;
545 TestCase arrTestCase[]={
547 {"newLength more than the capacity of OUStringBuffer(aUStr1)",
548 50, new OUString(aUStr1), 50,
549 new OUStringBuffer(arrOUS[0]), 50 },
550 {"newLength more than the length of OUStringBuffer(aUStr1)",
551 kTestStr13Len, new OUString(aUStr1), 32,
552 new OUStringBuffer(arrOUS[0]), kTestStr13Len },
553 {"newLength equal to the length of OUStringBuffer(aUStr1)",
554 kTestStr1Len, new OUString(aUStr1), 32,
555 new OUStringBuffer(arrOUS[0]), kTestStr1Len },
556 {"newLength less than the length of OUStringBuffer(aUStr1)",
557 kTestStr7Len, new OUString(aUStr7), 32,
558 new OUStringBuffer(arrOUS[0]), kTestStr7Len},
559 {"newLength equal to 0",
560 0, new OUString(), 32,
561 new OUStringBuffer(arrOUS[0]), 0},
562 {"newLength more than the capacity of OUStringBuffer(1)",
563 25, new OUString(arrOUS[1]), 25,
564 new OUStringBuffer(arrOUS[1]), 25},
565 {"newLength more than the length of OUStringBuffer(1)",
566 5, new OUString(arrOUS[1]), 17,
567 new OUStringBuffer(arrOUS[1]), 5},
568 {"newLength equal to the length of OUStringBuffer(1)",
569 kTestStr27Len, new OUString(arrOUS[1]), 17,
570 new OUStringBuffer(arrOUS[1]), kTestStr27Len},
571 {"newLength less than the length of OUStringBuffer(1)",
572 0, new OUString(), 17,
573 new OUStringBuffer(arrOUS[1]), 0},
574 {"newLength more than the capacity of OUStringBuffer()",
575 20, new OUString(), 20,
576 new OUStringBuffer(arrOUS[2]), 20},
577 {"newLength more than the length of OUStringBuffer()",
578 3, new OUString(), 16,
579 new OUStringBuffer(arrOUS[2]), 3},
580 {"newLength less than the length of OUStringBuffer()",
581 0, new OUString(), 16,
582 new OUStringBuffer(arrOUS[2]), 0},
583 {"newLength more than the capacity of OUStringBuffer("")",
584 20, new OUString(), 20,
585 new OUStringBuffer(arrOUS[3]), 20},
586 {"newLength more than the length of OUStringBuffer("")",
587 5, new OUString(), 16,
588 new OUStringBuffer(arrOUS[3]), 5},
589 {"newLength less than the length of OUStringBuffer("")",
590 0, new OUString(), 16,
591 new OUStringBuffer(arrOUS[3]), 0},
592 {"newLength more than the length of OUStringBuffer(\0)",
593 20, new OUString(), 20,
594 new OUStringBuffer(arrOUS[4]), 20},
595 {"newLength more than the length of OUStringBuffer(\0)",
596 5, new OUString(), 16,
597 new OUStringBuffer(arrOUS[4]), 5},
598 {"newLength less than the length of OUStringBuffer(\0)",
599 0, new OUString(), 16,
600 new OUStringBuffer(arrOUS[4]), 0},
601 {"newLength more than the capacity of OUStringBuffer(aUStr2)",
602 50, new OUString(aUStr2), 66,
603 new OUStringBuffer(arrOUS[5]), 50,},
604 {"newLength more than the length of OUStringBuffer(aUStr2)",
605 40, new OUString(aUStr2), 48,
606 new OUStringBuffer(arrOUS[5]), 40,},
607 {"newLength equal to the length of OUStringBuffer(aUStr2)",
608 kTestStr2Len, new OUString(aUStr2), 48,
609 new OUStringBuffer(arrOUS[5]), kTestStr2Len,},
610 {"newLength less than the length of OUStringBuffer(aUStr2)",
611 kTestStr7Len, new OUString(aUStr7), 48,
612 new OUStringBuffer(arrOUS[5]), kTestStr7Len},
613 {"newLength equal to 0",
614 0, new OUString(), 48,
615 new OUStringBuffer(arrOUS[5]), 0}
620 sal_Bool res = sal_True;
621 sal_uInt32 i;
623 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
625 arrTestCase[i].input1->setLength(arrTestCase[i].input2);
626 sal_Bool lastRes =
627 ( arrTestCase[i].input1->getStr() == *(arrTestCase[i].expVal2) &&
628 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal1 &&
629 arrTestCase[i].input1->getCapacity() == arrTestCase[i].expVal3 );
631 c_rtl_tres_state
633 hRtlTestResult,
634 lastRes,
635 arrTestCase[i].comments,
636 createName( pMeth, "setLength", i )
639 res &= lastRes;
641 c_rtl_tres_state_end( hRtlTestResult, "setLength");
642 // return ( res );
644 //------------------------------------------------------------------------
645 // testing the operator const sal_Unicode * (csuc for short)
646 //------------------------------------------------------------------------
647 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_csuc(
648 hTestResult hRtlTestResult)
650 c_rtl_tres_state_start( hRtlTestResult, "csuc");
651 sal_Char methName[MAXBUFLENGTH];
652 sal_Char* pMeth = methName;
654 const sal_Unicode tmpUC=0x0;
655 rtl_uString* tmpUstring = NULL;
656 const sal_Char *tmpStr=kTestStr1;
657 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
658 //sal_Int32 cmpLen = 0;
659 OUString tempString(aUStr1);
661 rtl_string2UString( &tmpUstring, tmpStr, tmpLen,
662 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
663 OSL_ASSERT(tmpUstring != NULL);
666 typedef struct TestCase
668 sal_Char* comments;
669 const sal_Unicode* expVal;
670 sal_Int32 cmpLen;
671 OUStringBuffer* input1;
672 ~TestCase() { delete input1; }
673 } TestCase;
675 TestCase arrTestCase[] =
677 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
678 new OUStringBuffer(tempString)},
679 {"test empty ustring",&tmpUC, 1, new OUStringBuffer()}
682 sal_Bool res = sal_True;
683 sal_uInt32 i;
684 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
686 const sal_Unicode* pstr = *arrTestCase[i].input1;
688 res &= c_rtl_tres_state
690 hRtlTestResult,
691 cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ),
692 arrTestCase[i].comments,
693 createName( pMeth, "const sal_Unicode*", i )
696 c_rtl_tres_state_end( hRtlTestResult, "csuc");
697 // return ( res );
699 //------------------------------------------------------------------------
700 // testing the method const sal_Unicode * getStr()
701 //------------------------------------------------------------------------
702 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_getStr(
703 hTestResult hRtlTestResult)
705 c_rtl_tres_state_start( hRtlTestResult, "getStr");
706 sal_Char methName[MAXBUFLENGTH];
707 sal_Char* pMeth = methName;
709 const sal_Unicode tmpUC=0x0;
710 rtl_uString* tmpUstring = NULL;
711 const sal_Char *tmpStr=kTestStr1;
712 sal_Int32 tmpLen=(sal_Int32) kTestStr1Len;
713 //sal_Int32 cmpLen = 0;
714 OUString tempString(aUStr1);
716 rtl_string2UString( &tmpUstring, tmpStr, tmpLen,
717 osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
718 OSL_ASSERT(tmpUstring != NULL);
721 typedef struct TestCase
723 sal_Char* comments;
724 const sal_Unicode* expVal;
725 sal_Int32 cmpLen;
726 OUStringBuffer* input1;
727 ~TestCase() { delete input1;}
728 } TestCase;
730 TestCase arrTestCase[] =
732 {"test normal ustring",(*tmpUstring).buffer,kTestStr1Len,
733 new OUStringBuffer(tempString)},
734 {"test empty ustring",&tmpUC, 1, new OUStringBuffer()}
737 sal_Bool res = sal_True;
738 sal_uInt32 i;
739 for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
741 const sal_Unicode* pstr = arrTestCase[i].input1->getStr();
743 res &= c_rtl_tres_state
745 hRtlTestResult,
746 cmpustr( pstr, arrTestCase[i].expVal, arrTestCase[i].cmpLen ),
747 arrTestCase[i].comments,
748 createName( pMeth, "getStr", i )
751 c_rtl_tres_state_end( hRtlTestResult, "getStr");
752 // return ( res );
754 //------------------------------------------------------------------------
755 // testing the method append(const OUString &str)
756 //------------------------------------------------------------------------
758 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_001(
759 hTestResult hRtlTestResult)
761 sal_Char methName[MAXBUFLENGTH];
762 sal_Char* pMeth = methName;
764 OUString arrOUS[5]={OUString( aUStr7 ),
765 OUString(),
766 OUString( aUStr25 ),
767 OUString( "\0",1,
768 kEncodingRTLTextUSASCII,
769 kConvertFlagsOStringToOUString),
770 OUString( aUStr28 )};
772 typedef struct TestCase
774 sal_Char* comments;
775 OUString* expVal;
776 OUStringBuffer* input1;
777 OUString* input2;
779 ~TestCase() { delete input1; delete input2; delete expVal; }
780 } TestCase;
782 TestCase arrTestCase[]={
784 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
785 new OUString(aUStr1),
786 new OUStringBuffer(arrOUS[0]), new OUString(aUStr8) },
787 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
788 new OUString(aUStr2),
789 new OUStringBuffer(arrOUS[0]), new OUString(aUStr36) },
790 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
791 new OUString(aUStr37),
792 new OUStringBuffer(arrOUS[0]), new OUString(aUStr23) },
793 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
794 new OUString(aUStr7),
795 new OUStringBuffer(arrOUS[0]), new OUString()},
796 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
797 new OUString(aUStr7),
798 new OUStringBuffer(arrOUS[1]), new OUString(aUStr7)},
799 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
800 new OUString(aUStr2),
801 new OUStringBuffer(arrOUS[1]), new OUString(aUStr2)},
802 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
803 new OUString(aUStr1),
804 new OUStringBuffer(arrOUS[1]), new OUString(aUStr1) },
805 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
806 new OUString(),
807 new OUStringBuffer(arrOUS[1]), new OUString()},
808 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
809 new OUString(aUStr7),
810 new OUStringBuffer(arrOUS[2]), new OUString(aUStr7)},
811 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
812 new OUString(aUStr2),
813 new OUStringBuffer(arrOUS[2]), new OUString(aUStr2)},
814 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
815 new OUString(aUStr1),
816 new OUStringBuffer(arrOUS[2]), new OUString(aUStr1) },
817 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
818 new OUString(),
819 new OUStringBuffer(arrOUS[2]), new OUString()},
820 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
821 new OUString(aUStr7),
822 new OUStringBuffer(arrOUS[3]), new OUString(aUStr7)},
823 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
824 new OUString(aUStr2),
825 new OUStringBuffer(arrOUS[3]), new OUString(aUStr2)},
826 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
827 new OUString(aUStr1),
828 new OUStringBuffer(arrOUS[3]), new OUString(aUStr1) },
829 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
830 new OUString(),
831 new OUStringBuffer(arrOUS[3]), new OUString()},
832 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
833 new OUString(aUStr29),
834 new OUStringBuffer(arrOUS[4]), new OUString(aUStr38)},
835 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
836 new OUString(aUStr39),
837 new OUStringBuffer(arrOUS[4]), new OUString(aUStr17)},
838 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
839 new OUString(aUStr40),
840 new OUStringBuffer(arrOUS[4]), new OUString(aUStr31) },
841 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
842 new OUString(aUStr28),
843 new OUStringBuffer(arrOUS[4]), new OUString()}
847 sal_Bool res = sal_True;
848 sal_uInt32 i;
850 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
852 arrTestCase[i].input1->append( *(arrTestCase[i].input2) );
853 sal_Bool lastRes =
854 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
855 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
857 c_rtl_tres_state
859 hRtlTestResult,
860 lastRes,
861 arrTestCase[i].comments,
862 createName( pMeth, "append(const OUString &str)_001", i )
866 res &= lastRes;
869 return ( res );
871 //------------------------------------------------------------------------
872 // testing the method append( const sal_Unicode * str )
873 //------------------------------------------------------------------------
875 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_002(
876 hTestResult hRtlTestResult)
878 sal_Char methName[MAXBUFLENGTH];
879 sal_Char* pMeth = methName;
881 OUString arrOUS[5]={OUString( aUStr7 ),
882 OUString(),
883 OUString( aUStr25 ),
884 OUString( "\0",1,
885 kEncodingRTLTextUSASCII,
886 kConvertFlagsOStringToOUString),
887 OUString( aUStr28 )};
889 typedef struct TestCase
891 sal_Char* comments;
892 OUString* expVal;
893 OUStringBuffer* input1;
894 sal_Unicode* input2;
896 ~TestCase() { delete input1; delete expVal; }
897 } TestCase;
899 TestCase arrTestCase[]={
901 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
902 new OUString(aUStr1),
903 new OUStringBuffer(arrOUS[0]), aUStr8 },
904 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
905 new OUString(aUStr2),
906 new OUStringBuffer(arrOUS[0]), aUStr36 },
907 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
908 new OUString(aUStr37),
909 new OUStringBuffer(arrOUS[0]), aUStr23 },
910 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
911 new OUString(aUStr7),
912 new OUStringBuffer(arrOUS[0]), aUStr25 },
913 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
914 new OUString(aUStr7),
915 new OUStringBuffer(arrOUS[1]), aUStr7 },
916 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
917 new OUString(aUStr2),
918 new OUStringBuffer(arrOUS[1]), aUStr2 },
919 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
920 new OUString(aUStr1),
921 new OUStringBuffer(arrOUS[1]), aUStr1 },
922 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
923 new OUString(),
924 new OUStringBuffer(arrOUS[1]), aUStr25 },
925 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
926 new OUString(aUStr7),
927 new OUStringBuffer(arrOUS[2]), aUStr7 },
928 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
929 new OUString(aUStr2),
930 new OUStringBuffer(arrOUS[2]), aUStr2 },
931 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
932 new OUString(aUStr1),
933 new OUStringBuffer(arrOUS[2]), aUStr1 },
934 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
935 new OUString(),
936 new OUStringBuffer(arrOUS[2]), aUStr25 },
937 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
938 new OUString(aUStr7),
939 new OUStringBuffer(arrOUS[3]), aUStr7 },
940 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
941 new OUString(aUStr2),
942 new OUStringBuffer(arrOUS[3]), aUStr2 },
943 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
944 new OUString(aUStr1),
945 new OUStringBuffer(arrOUS[3]), aUStr1 },
946 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
947 new OUString(),
948 new OUStringBuffer(arrOUS[3]), aUStr25 },
949 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
950 new OUString(aUStr29),
951 new OUStringBuffer(arrOUS[4]), aUStr38 },
952 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
953 new OUString(aUStr39),
954 new OUStringBuffer(arrOUS[4]), aUStr17 },
955 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
956 new OUString(aUStr40),
957 new OUStringBuffer(arrOUS[4]), aUStr31 },
958 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
959 new OUString(aUStr28),
960 new OUStringBuffer(arrOUS[4]), aUStr25 }
964 sal_Bool res = sal_True;
965 sal_uInt32 i;
967 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
969 arrTestCase[i].input1->append( arrTestCase[i].input2 );
970 sal_Bool lastRes =
971 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
972 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
974 c_rtl_tres_state
976 hRtlTestResult,
977 lastRes,
978 arrTestCase[i].comments,
979 createName( pMeth, "append( const sal_Unicode * str )_002", i )
983 res &= lastRes;
986 return ( res );
988 //------------------------------------------------------------------------
989 // testing the method append( const sal_Unicode * str, sal_Int32 len)
990 //------------------------------------------------------------------------
992 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_003(
993 hTestResult hRtlTestResult)
995 sal_Char methName[MAXBUFLENGTH];
996 sal_Char* pMeth = methName;
998 OUString arrOUS[5]={OUString( aUStr7 ),
999 OUString(),
1000 OUString( aUStr25 ),
1001 OUString( "\0",1,
1002 kEncodingRTLTextUSASCII,
1003 kConvertFlagsOStringToOUString),
1004 OUString( aUStr28 )};
1006 typedef struct TestCase
1008 sal_Char* comments;
1009 OUString* expVal;
1010 OUStringBuffer* input1;
1011 sal_Unicode* input2;
1012 sal_Int32 input3;
1014 ~TestCase() { delete input1; delete expVal; }
1015 } TestCase;
1017 TestCase arrTestCase[]={
1019 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1020 new OUString(aUStr1),
1021 new OUStringBuffer(arrOUS[0]), aUStr36, 12 },
1022 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1023 new OUString(aUStr2),
1024 new OUStringBuffer(arrOUS[0]), aUStr36, 28 },
1025 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1026 new OUString(aUStr37),
1027 new OUStringBuffer(arrOUS[0]), aUStr23, 16 },
1028 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1029 new OUString(aUStr7),
1030 new OUStringBuffer(arrOUS[0]), aUStr2, 0 },
1031 /* LLA: input3 must null < 0
1032 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1033 new OUString(aUStr41),
1034 new OUStringBuffer(arrOUS[0]), aUStr2, -1 },
1036 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1037 new OUString(aUStr7),
1038 new OUStringBuffer(arrOUS[1]), aUStr2, 4 },
1039 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1040 new OUString(aUStr2),
1041 new OUStringBuffer(arrOUS[1]), aUStr2, 32 },
1042 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1043 new OUString(aUStr1),
1044 new OUStringBuffer(arrOUS[1]), aUStr2, 16 },
1045 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1046 new OUString(),
1047 new OUStringBuffer(arrOUS[1]), aUStr2, 0 },
1048 /* LLA: input3 must null < 0
1049 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1050 new OUString(),
1051 new OUStringBuffer(arrOUS[1]), aUStr2, -1 },
1053 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1054 new OUString(aUStr7),
1055 new OUStringBuffer(arrOUS[2]), aUStr2, 4 },
1056 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1057 new OUString(aUStr2),
1058 new OUStringBuffer(arrOUS[2]), aUStr2, 32 },
1059 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1060 new OUString(aUStr1),
1061 new OUStringBuffer(arrOUS[2]), aUStr2, 16 },
1062 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1063 new OUString(),
1064 new OUStringBuffer(arrOUS[2]), aUStr2, 0 },
1065 /* LLA: input3 must null < 0
1066 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1067 new OUString(),
1068 new OUStringBuffer(arrOUS[2]), aUStr2, -1 },
1070 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1071 new OUString(aUStr7),
1072 new OUStringBuffer(arrOUS[3]), aUStr2, 4 },
1073 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1074 new OUString(aUStr2),
1075 new OUStringBuffer(arrOUS[3]), aUStr2, 32 },
1076 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1077 new OUString(aUStr1),
1078 new OUStringBuffer(arrOUS[3]), aUStr2, 16 },
1079 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1080 new OUString(),
1081 new OUStringBuffer(arrOUS[3]), aUStr2, 0 },
1082 /* LLA: input3 must null < 0
1083 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1084 new OUString(),
1085 new OUStringBuffer(arrOUS[3]), aUStr2, -1 },
1087 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1088 new OUString(aUStr29),
1089 new OUStringBuffer(arrOUS[4]), aUStr38, 7 },
1090 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1091 new OUString(aUStr39),
1092 new OUStringBuffer(arrOUS[4]), aUStr17, 22 },
1093 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1094 new OUString(aUStr40),
1095 new OUStringBuffer(arrOUS[4]), aUStr31, 16 },
1096 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1097 new OUString(aUStr28),
1098 new OUStringBuffer(arrOUS[4]), aUStr2, 0 },
1102 sal_Bool res = sal_True;
1103 sal_uInt32 i;
1105 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1107 arrTestCase[i].input1->append(
1108 arrTestCase[i].input2, arrTestCase[i].input3);
1109 sal_Bool lastRes =
1110 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1111 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1113 c_rtl_tres_state
1115 hRtlTestResult,
1116 lastRes,
1117 arrTestCase[i].comments,
1118 createName( pMeth, "append( const sal_Unicode * str, sal_Int32 len)_003", i )
1122 res &= lastRes;
1125 return ( res );
1127 //------------------------------------------------------------------------
1128 // testing the method append(sal_Bool b)
1129 //------------------------------------------------------------------------
1131 sal_Bool SAL_CALL test_rtl_OUStringBuffer_append_004(
1132 hTestResult hRtlTestResult)
1134 sal_Char methName[MAXBUFLENGTH];
1135 sal_Char* pMeth = methName;
1137 OUString arrOUS[5]={OUString( aUStr7 ),
1138 OUString(),
1139 OUString( aUStr25 ),
1140 OUString( "\0",1,
1141 kEncodingRTLTextUSASCII,
1142 kConvertFlagsOStringToOUString),
1143 OUString( aUStr28 )};
1145 typedef struct TestCase
1147 sal_Char* comments;
1148 OUString* expVal;
1149 OUStringBuffer* input1;
1150 sal_Bool input2;
1152 ~TestCase() { delete input1; delete expVal; }
1153 } TestCase;
1155 TestCase arrTestCase[]={
1157 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[0]",
1158 new OUString(aUStr45),
1159 new OUStringBuffer(arrOUS[0]), sal_True },
1160 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[0]",
1161 new OUString(aUStr46),
1162 new OUStringBuffer(arrOUS[0]), sal_False },
1163 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[1]",
1164 new OUString(aUStr47),
1165 new OUStringBuffer(arrOUS[1]), sal_True },
1166 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[1]",
1167 new OUString(aUStr48),
1168 new OUStringBuffer(arrOUS[1]), sal_False },
1169 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[2]",
1170 new OUString(aUStr47),
1171 new OUStringBuffer(arrOUS[2]), sal_True },
1172 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[2]",
1173 new OUString(aUStr48),
1174 new OUStringBuffer(arrOUS[2]), sal_False },
1175 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[3]",
1176 new OUString(aUStr47),
1177 new OUStringBuffer(arrOUS[3]), sal_True },
1178 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[3]",
1179 new OUString(aUStr48),
1180 new OUStringBuffer(arrOUS[3]), sal_False },
1181 {"Appends the sal_Bool(sal_True) to the string buffer arrOUS[4]",
1182 new OUString(aUStr49),
1183 new OUStringBuffer(arrOUS[4]), sal_True },
1184 {"Appends the sal_Bool(sal_False) to the string buffer arrOUS[4]",
1185 new OUString(aUStr50),
1186 new OUStringBuffer(arrOUS[4]), sal_False }
1190 sal_Bool res = sal_True;
1191 sal_uInt32 i;
1193 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1195 arrTestCase[i].input1->append(
1196 arrTestCase[i].input2 );
1197 sal_Bool lastRes =
1198 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1199 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1201 c_rtl_tres_state
1203 hRtlTestResult,
1204 lastRes,
1205 arrTestCase[i].comments,
1206 createName( pMeth, "append( sal_Bool b)_004", i )
1210 res &= lastRes;
1213 return ( res );
1216 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appends(
1217 hTestResult hRtlTestResult )
1219 c_rtl_tres_state_start( hRtlTestResult, "appends");
1220 sal_Bool bTSState = test_rtl_OUStringBuffer_append_001( hRtlTestResult );
1221 bTSState &= test_rtl_OUStringBuffer_append_002( hRtlTestResult);
1222 bTSState &= test_rtl_OUStringBuffer_append_003( hRtlTestResult);
1223 bTSState &= test_rtl_OUStringBuffer_append_004( hRtlTestResult);
1225 c_rtl_tres_state_end( hRtlTestResult, "appends");
1226 // return( bTSState );
1228 //------------------------------------------------------------------------
1229 // testing the method appendAscii( const sal_Char * str )
1230 //------------------------------------------------------------------------
1232 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_001(
1233 hTestResult hRtlTestResult)
1235 sal_Char methName[MAXBUFLENGTH];
1236 sal_Char* pMeth = methName;
1238 OUString arrOUS[5]={OUString( aUStr7 ),
1239 OUString(),
1240 OUString( aUStr25 ),
1241 OUString( "\0",1,
1242 kEncodingRTLTextUSASCII,
1243 kConvertFlagsOStringToOUString),
1244 OUString( aUStr28 )};
1246 typedef struct TestCase
1248 sal_Char* comments;
1249 OUString* expVal;
1250 OUStringBuffer* input1;
1251 const sal_Char* input2;
1253 ~TestCase() { delete input1; delete expVal; }
1254 } TestCase;
1256 TestCase arrTestCase[]={
1258 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1259 new OUString(aUStr1),
1260 new OUStringBuffer(arrOUS[0]), kTestStr8 },
1261 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1262 new OUString(aUStr2),
1263 new OUStringBuffer(arrOUS[0]), kTestStr36 },
1264 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1265 new OUString(aUStr37),
1266 new OUStringBuffer(arrOUS[0]), kTestStr23 },
1267 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1268 new OUString(aUStr7),
1269 new OUStringBuffer(arrOUS[0]), kTestStr25 },
1270 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1271 new OUString(aUStr7),
1272 new OUStringBuffer(arrOUS[1]), kTestStr7 },
1273 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1274 new OUString(aUStr2),
1275 new OUStringBuffer(arrOUS[1]), kTestStr2 },
1276 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1277 new OUString(aUStr1),
1278 new OUStringBuffer(arrOUS[1]), kTestStr1 },
1279 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1280 new OUString(),
1281 new OUStringBuffer(arrOUS[1]), kTestStr25 },
1282 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1283 new OUString(aUStr7),
1284 new OUStringBuffer(arrOUS[2]), kTestStr7 },
1285 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1286 new OUString(aUStr2),
1287 new OUStringBuffer(arrOUS[2]), kTestStr2 },
1288 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1289 new OUString(aUStr1),
1290 new OUStringBuffer(arrOUS[2]), kTestStr1 },
1291 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1292 new OUString(),
1293 new OUStringBuffer(arrOUS[2]), kTestStr25 },
1294 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1295 new OUString(aUStr7),
1296 new OUStringBuffer(arrOUS[3]), kTestStr7 },
1297 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1298 new OUString(aUStr2),
1299 new OUStringBuffer(arrOUS[3]), kTestStr2 },
1300 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1301 new OUString(aUStr1),
1302 new OUStringBuffer(arrOUS[3]), kTestStr1 },
1303 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1304 new OUString(),
1305 new OUStringBuffer(arrOUS[3]), kTestStr25 },
1306 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1307 new OUString(aUStr29),
1308 new OUStringBuffer(arrOUS[4]), kTestStr38 },
1309 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1310 new OUString(aUStr39),
1311 new OUStringBuffer(arrOUS[4]), kTestStr17 },
1312 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1313 new OUString(aUStr40),
1314 new OUStringBuffer(arrOUS[4]), kTestStr31 },
1315 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1316 new OUString(aUStr28),
1317 new OUStringBuffer(arrOUS[4]), kTestStr25 }
1321 sal_Bool res = sal_True;
1322 sal_uInt32 i;
1324 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1326 arrTestCase[i].input1->appendAscii( arrTestCase[i].input2 );
1327 sal_Bool lastRes =
1328 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1329 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1331 c_rtl_tres_state
1333 hRtlTestResult,
1334 lastRes,
1335 arrTestCase[i].comments,
1336 createName( pMeth, "appendAscii_001", i )
1339 res &= lastRes;
1341 return ( res );
1343 //------------------------------------------------------------------------
1344 // testing the method appendAscii( const sal_Char * str, sal_Int32 len)
1345 //------------------------------------------------------------------------
1347 sal_Bool SAL_CALL test_rtl_OUStringBuffer_appendAscii_002(
1348 hTestResult hRtlTestResult)
1350 sal_Char methName[MAXBUFLENGTH];
1351 sal_Char* pMeth = methName;
1353 OUString arrOUS[5]={OUString( aUStr7 ),
1354 OUString(),
1355 OUString( aUStr25 ),
1356 OUString( "\0",1,
1357 kEncodingRTLTextUSASCII,
1358 kConvertFlagsOStringToOUString),
1359 OUString( aUStr28 )};
1361 typedef struct TestCase
1363 sal_Char* comments;
1364 OUString* expVal;
1365 OUStringBuffer* input1;
1366 const sal_Char* input2;
1367 sal_Int32 input3;
1369 ~TestCase() { delete input1; delete expVal; }
1370 } TestCase;
1372 TestCase arrTestCase[]={
1374 {"Appends the string(length less than 16) to the string buffer arrOUS[0]",
1375 new OUString(aUStr1),
1376 new OUStringBuffer(arrOUS[0]), kTestStr36, 12 },
1377 {"Appends the string(length more than 16) to the string buffer arrOUS[0]",
1378 new OUString(aUStr2),
1379 new OUStringBuffer(arrOUS[0]), kTestStr36, 28 },
1380 {"Appends the string(length equal to 16) to the string buffer arrOUS[0]",
1381 new OUString(aUStr37),
1382 new OUStringBuffer(arrOUS[0]), kTestStr23, 16 },
1383 {"Appends the string(length equal to 0) to the string buffer arrOUS[0]",
1384 new OUString(aUStr7),
1385 new OUStringBuffer(arrOUS[0]), kTestStr2, 0 },
1386 /* LLA: input3 must null < 0
1387 {"Appends the string(length less than 0) to the string buffer arrOUS[0]",
1388 new OUString(aUStr41),
1389 new OUStringBuffer(arrOUS[0]), kTestStr2, -1 },
1391 {"Appends the string(length less than 16) to the string buffer arrOUS[1]",
1392 new OUString(aUStr7),
1393 new OUStringBuffer(arrOUS[1]), kTestStr2, 4 },
1394 {"Appends the string(length more than 16) to the string buffer arrOUS[1]",
1395 new OUString(aUStr2),
1396 new OUStringBuffer(arrOUS[1]), kTestStr2, 32 },
1397 {"Appends the string(length equal to 16) to the string buffer arrOUS[1]",
1398 new OUString(aUStr1),
1399 new OUStringBuffer(arrOUS[1]), kTestStr2, 16 },
1400 {"Appends the string(length equal to 0) to the string buffer arrOUS[1]",
1401 new OUString(),
1402 new OUStringBuffer(arrOUS[1]), kTestStr2, 0 },
1403 /* LLA: input3 must null < 0
1404 {"Appends the string(length less than 0) to the string buffer arrOUS[1]",
1405 new OUString(),
1406 new OUStringBuffer(arrOUS[1]), kTestStr2, -1 },
1408 {"Appends the string(length less than 16) to the string buffer arrOUS[2]",
1409 new OUString(aUStr7),
1410 new OUStringBuffer(arrOUS[2]), kTestStr2, 4 },
1411 {"Appends the string(length more than 16) to the string buffer arrOUS[2]",
1412 new OUString(aUStr2),
1413 new OUStringBuffer(arrOUS[2]), kTestStr2, 32 },
1414 {"Appends the string(length equal to 16) to the string buffer arrOUS[2]",
1415 new OUString(aUStr1),
1416 new OUStringBuffer(arrOUS[2]), kTestStr2, 16 },
1417 {"Appends the string(length equal to 0) to the string buffer arrOUS[2]",
1418 new OUString(),
1419 new OUStringBuffer(arrOUS[2]), kTestStr2, 0 },
1420 /* LLA: input3 must null < 0
1421 {"Appends the string(length less than 0) to the string buffer arrOUS[2]",
1422 new OUString(),
1423 new OUStringBuffer(arrOUS[2]), kTestStr2, -1 },
1425 {"Appends the string(length less than 16) to the string buffer arrOUS[3]",
1426 new OUString(aUStr7),
1427 new OUStringBuffer(arrOUS[3]), kTestStr2, 4 },
1428 {"Appends the string(length more than 16) to the string buffer arrOUS[3]",
1429 new OUString(aUStr2),
1430 new OUStringBuffer(arrOUS[3]), kTestStr2, 32 },
1431 {"Appends the string(length equal to 16) to the string buffer arrOUS[3]",
1432 new OUString(aUStr1),
1433 new OUStringBuffer(arrOUS[3]), kTestStr2, 16 },
1434 {"Appends the string(length equal to 0) to the string buffer arrOUS[3]",
1435 new OUString(),
1436 new OUStringBuffer(arrOUS[3]), kTestStr2, 0 },
1437 /* LLA: input3 must null < 0
1438 {"Appends the string(length less than 0) to the string buffer arrOUS[3]",
1439 new OUString(),
1440 new OUStringBuffer(arrOUS[3]), kTestStr2, -1 },
1442 {"Appends the string(length less than 16) to the string buffer arrOUS[4]",
1443 new OUString(aUStr29),
1444 new OUStringBuffer(arrOUS[4]), kTestStr38, 7 },
1445 {"Appends the string(length more than 16) to the string buffer arrOUS[4]",
1446 new OUString(aUStr39),
1447 new OUStringBuffer(arrOUS[4]), kTestStr17, 22 },
1448 {"Appends the string(length equal to 16) to the string buffer arrOUS[4]",
1449 new OUString(aUStr40),
1450 new OUStringBuffer(arrOUS[4]), kTestStr31, 16 },
1451 {"Appends the string(length equal to 0) to the string buffer arrOUS[4]",
1452 new OUString(aUStr28),
1453 new OUStringBuffer(arrOUS[4]), kTestStr2, 0 },
1457 sal_Bool res = sal_True;
1458 sal_uInt32 i;
1460 for (i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++)
1462 arrTestCase[i].input1->appendAscii(
1463 arrTestCase[i].input2, arrTestCase[i].input3);
1464 sal_Bool lastRes =
1465 ( arrTestCase[i].input1->getStr()== *(arrTestCase[i].expVal) &&
1466 arrTestCase[i].input1->getLength() == arrTestCase[i].expVal->getLength() );
1468 c_rtl_tres_state
1470 hRtlTestResult,
1471 lastRes,
1472 arrTestCase[i].comments,
1473 createName( pMeth, "appendAscii_002", i )
1477 res &= lastRes;
1479 return ( res );
1481 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer_appendAsciis(
1482 hTestResult hRtlTestResult )
1484 c_rtl_tres_state_start( hRtlTestResult, "appendAsciis");
1485 sal_Bool bTSState = test_rtl_OUStringBuffer_appendAscii_001( hRtlTestResult );
1486 bTSState &= test_rtl_OUStringBuffer_appendAscii_002( hRtlTestResult);
1488 c_rtl_tres_state_end( hRtlTestResult, "appendAsciis");
1489 // return( bTSState );
1491 // -----------------------------------------------------------------------------
1492 extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUStringBuffer( hTestResult hRtlTestResult )
1495 c_rtl_tres_state_start(hRtlTestResult, "rtl_OUStringBuffer" );
1497 test_rtl_OUStringBuffer_ctors( hRtlTestResult );
1498 test_rtl_OUStringBuffer_makeStringAndClear( hRtlTestResult );
1499 test_rtl_OUStringBuffer_getLength( hRtlTestResult );
1500 test_rtl_OUStringBuffer_getCapacity( hRtlTestResult );
1501 test_rtl_OUStringBuffer_ensureCapacity( hRtlTestResult );
1502 test_rtl_OUStringBuffer_setLength( hRtlTestResult );
1503 test_rtl_OUStringBuffer_csuc( hRtlTestResult );
1504 test_rtl_OUStringBuffer_getStr( hRtlTestResult );
1505 test_rtl_OUStringBuffer_appends( hRtlTestResult );
1506 test_rtl_OUStringBuffer_appendAsciis( hRtlTestResult );
1508 c_rtl_tres_state_end(hRtlTestResult, "rtl_OUStringBuffer");
1511 // -----------------------------------------------------------------------------
1512 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
1514 if (_pFunc)
1516 (_pFunc)(&test_rtl_OUStringBuffer, "");
1520 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */