1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <cppunit/TestFixture.h>
21 #include <cppunit/extensions/HelperMacros.h>
22 #include <cppunit/plugin/TestPlugIn.h>
24 /** print a UNI_CODE file name.
27 inline void printOUString( OUString const & _suStr )
31 printf( "OUString: " );
32 aString = OUStringToOString( _suStr, RTL_TEXTENCODING_ASCII_US );
33 printf( "%s\n", aString.getStr( ) );
40 class compare
: public CppUnit::TestFixture
46 rtl_ustr_compare( NULL
, NULL
);
52 OUString
aStr1("Line must be equal.");
53 rtl_ustr_compare( aStr1
.getStr(), NULL
);
61 sal_Int32 nValue
= rtl_ustr_compare( aStr1
.getStr(), aStr2
.getStr());
62 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
67 OUString
aStr1("Line must be equal.");
68 OUString
aStr2("Line must be equal.");
70 sal_Int32 nValue
= rtl_ustr_compare( aStr1
.getStr(), aStr2
.getStr());
71 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
76 OUString
aStr1("Line must differ.");
77 OUString
aStr2("Line foo bar, ok, differ.");
79 sal_Int32 nValue
= rtl_ustr_compare( aStr1
.getStr(), aStr2
.getStr());
80 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
83 // Change the following lines only, if you add, remove or rename
84 // member functions of the current class,
85 // because these macros are need by auto register mechanism.
87 CPPUNIT_TEST_SUITE(compare
);
88 CPPUNIT_TEST(compare_000
);
89 CPPUNIT_TEST(compare_000_1
);
90 CPPUNIT_TEST(compare_001
);
91 CPPUNIT_TEST(compare_002
);
92 CPPUNIT_TEST(compare_003
);
93 CPPUNIT_TEST_SUITE_END();
96 class compareIgnoreAsciiCase
: public CppUnit::TestFixture
102 rtl_ustr_compareIgnoreAsciiCase( NULL
, NULL
);
107 OUString
aStr1("Line must be equal.");
108 rtl_ustr_compareIgnoreAsciiCase( aStr1
.getStr(), NULL
);
115 sal_Int32 nValue
= rtl_ustr_compareIgnoreAsciiCase( aStr1
.getStr(), aStr2
.getStr());
116 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
121 OUString
aStr1("Line must be equal.");
122 OUString
aStr2("Line must be equal.");
124 sal_Int32 nValue
= rtl_ustr_compareIgnoreAsciiCase( aStr1
.getStr(), aStr2
.getStr());
125 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
130 OUString
aStr1("Line must be equal.");
131 OUString
aStr2("LINE MUST BE EQUAL.");
133 sal_Int32 nValue
= rtl_ustr_compareIgnoreAsciiCase( aStr1
.getStr(), aStr2
.getStr());
134 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitive).", nValue
== 0);
139 OUString
aStr1("Line must differ.");
140 OUString
aStr2("Line foo bar, ok, differ.");
142 sal_Int32 nValue
= rtl_ustr_compareIgnoreAsciiCase( aStr1
.getStr(), aStr2
.getStr());
143 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
146 // Change the following lines only, if you add, remove or rename
147 // member functions of the current class,
148 // because these macros are need by auto register mechanism.
150 CPPUNIT_TEST_SUITE(compareIgnoreAsciiCase
);
151 CPPUNIT_TEST(compare_000
);
152 CPPUNIT_TEST(compare_000_1
);
153 CPPUNIT_TEST(compare_001
);
154 CPPUNIT_TEST(compare_002
);
155 CPPUNIT_TEST(compare_002_1
);
156 CPPUNIT_TEST(compare_003
);
157 CPPUNIT_TEST_SUITE_END();
158 }; // class compareIgnoreAsciiCase
160 class shortenedCompareIgnoreAsciiCase_WithLength
: public CppUnit::TestFixture
166 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( NULL
, 0, NULL
, 0, 0);
171 OUString
aStr1("Line must be equal.");
172 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(), NULL
, 0, 1);
179 sal_Int32 nValue
= rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(), aStr2
.getStr(), aStr2
.getLength(), aStr1
.getLength());
180 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
185 OUString
aStr1("Line must be equal.");
186 OUString
aStr2("Line must be equal.");
188 sal_Int32 nValue
= rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(),
189 aStr2
.getStr(), aStr2
.getLength(),
191 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
196 OUString
aStr1("Line must be equal.");
197 OUString
aStr2("LINE MUST BE EQUAL.");
199 sal_Int32 nValue
= rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(),
200 aStr2
.getStr(), aStr2
.getLength(),
202 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitive).", nValue
== 0);
207 OUString
aStr1("Line must differ.");
208 OUString
aStr2("Line foo bar, ok, differ.");
210 sal_Int32 nValue
= rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(),
211 aStr2
.getStr(), aStr2
.getLength(),
213 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal first 5 characters.", nValue
== 0);
218 OUString
aStr1("Line must differ.");
219 OUString
aStr2("Line foo bar, ok, differ.");
221 sal_Int32 nValue
= rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(),
222 aStr2
.getStr(), aStr2
.getLength(),
224 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
227 // Change the following lines only, if you add, remove or rename
228 // member functions of the current class,
229 // because these macros are need by auto register mechanism.
231 CPPUNIT_TEST_SUITE(shortenedCompareIgnoreAsciiCase_WithLength
);
232 CPPUNIT_TEST(compare_000
);
233 CPPUNIT_TEST(compare_000_1
);
234 CPPUNIT_TEST(compare_001
);
235 CPPUNIT_TEST(compare_002
);
236 CPPUNIT_TEST(compare_002_1
);
237 CPPUNIT_TEST(compare_003
);
238 CPPUNIT_TEST(compare_004
);
239 CPPUNIT_TEST_SUITE_END();
244 // class hashCode : public CppUnit::TestFixture
248 // void hashCode_000()
250 // sal_Int32 nHashCode = rtl_ustr_hashCode( NULL );
251 // volatile int dummy = 0;
254 // void hashCode_001()
256 // OString aStr1 = "Line for a hashCode.";
257 // sal_Int32 nHashCode = rtl_ustr_hashCode( aStr1.getStr() );
258 // printf("hashcode: %d\n", nHashCode);
259 // // CPPUNIT_ASSERT_MESSAGE("failed.", nValue == 0);
262 // void hashCode_002()
264 // OString aStr1 = "Line for a hashCode.";
265 // sal_Int32 nHashCode1 = rtl_ustr_hashCode( aStr1.getStr() );
267 // OString aStr2 = "Line for a hashCode.";
268 // sal_Int32 nHashCode2 = rtl_ustr_hashCode( aStr2.getStr() );
270 // CPPUNIT_ASSERT_MESSAGE("hashcodes must be equal.", nHashCode1 == nHashCode2 );
273 // void hashCode_003()
275 // OString aStr1 = "Line for a hashCode.";
276 // sal_Int32 nHashCode1 = rtl_ustr_hashCode( aStr1.getStr() );
278 // OString aStr2 = "Line for another hashcode.";
279 // sal_Int32 nHashCode2 = rtl_ustr_hashCode( aStr2.getStr() );
281 // CPPUNIT_ASSERT_MESSAGE("hashcodes must differ.", nHashCode1 != nHashCode2 );
284 // // Change the following lines only, if you add, remove or rename
285 // // member functions of the current class,
286 // // because these macros are need by auto register mechanism.
288 // CPPUNIT_TEST_SUITE(hashCode);
289 // CPPUNIT_TEST(hashCode_000);
290 // CPPUNIT_TEST(hashCode_001);
291 // CPPUNIT_TEST(hashCode_002);
292 // CPPUNIT_TEST(hashCode_003);
293 // CPPUNIT_TEST_SUITE_END();
294 // }; // class compare
296 class indexOfChar
: public CppUnit::TestFixture
300 void indexOfChar_000()
302 rtl_ustr_indexOfChar( NULL
, 0 );
305 void indexOfChar_001()
307 OUString
aStr1("Line for an indexOfChar.");
309 sal_Int32 nIndex
= rtl_ustr_indexOfChar( aStr1
.getStr(), 'L' );
310 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 0);
312 /* sal_Int32 */ nIndex
= rtl_ustr_indexOfChar( aStr1
.getStr(), 'i' );
313 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 1);
315 /* sal_Int32 */ nIndex
= rtl_ustr_indexOfChar( aStr1
.getStr(), 'n' );
316 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 2);
318 /* sal_Int32 */ nIndex
= rtl_ustr_indexOfChar( aStr1
.getStr(), 'e' );
319 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 3);
322 void indexOfChar_002()
324 OUString
aStr1("Line for an indexOfChar.");
325 sal_Int32 nIndex
= rtl_ustr_indexOfChar( aStr1
.getStr(), 'y' );
327 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== -1 );
330 // Change the following lines only, if you add, remove or rename
331 // member functions of the current class,
332 // because these macros are need by auto register mechanism.
334 CPPUNIT_TEST_SUITE(indexOfChar
);
335 CPPUNIT_TEST(indexOfChar_000
);
336 CPPUNIT_TEST(indexOfChar_001
);
337 CPPUNIT_TEST(indexOfChar_002
);
338 CPPUNIT_TEST_SUITE_END();
339 }; // class indexOfChar
341 class lastIndexOfChar
: public CppUnit::TestFixture
345 void lastIndexOfChar_000()
347 rtl_ustr_lastIndexOfChar( NULL
, 0 );
350 void lastIndexOfChar_001()
352 OUString
aStr1("Line for a lastIndexOfChar.");
354 sal_Int32 nIndex
= rtl_ustr_lastIndexOfChar( aStr1
.getStr(), 'C' );
355 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 22);
357 /* sal_Int32 */ nIndex
= rtl_ustr_lastIndexOfChar( aStr1
.getStr(), 'h' );
358 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 23);
360 /* sal_Int32 */ nIndex
= rtl_ustr_lastIndexOfChar( aStr1
.getStr(), 'a' );
361 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 24);
363 /* sal_Int32 */ nIndex
= rtl_ustr_lastIndexOfChar( aStr1
.getStr(), 'r' );
364 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 25);
367 void lastIndexOfChar_002()
369 OUString
aStr1("Line for a lastIndexOfChar.");
370 sal_Int32 nIndex
= rtl_ustr_lastIndexOfChar( aStr1
.getStr(), 'y' );
372 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== -1 );
375 // Change the following lines only, if you add, remove or rename
376 // member functions of the current class,
377 // because these macros are need by auto register mechanism.
379 CPPUNIT_TEST_SUITE(lastIndexOfChar
);
380 CPPUNIT_TEST(lastIndexOfChar_000
);
381 CPPUNIT_TEST(lastIndexOfChar_001
);
382 CPPUNIT_TEST(lastIndexOfChar_002
);
383 CPPUNIT_TEST_SUITE_END();
384 }; // class lastIndexOfChar
386 class indexOfStr
: public CppUnit::TestFixture
390 void indexOfStr_000()
392 rtl_ustr_indexOfStr( NULL
, 0 );
395 void indexOfStr_000_1()
397 OUString
aStr1("Line for an indexOfStr.");
398 rtl_ustr_indexOfStr( aStr1
.getStr(), 0 );
401 void indexOfStr_001()
403 OUString
aStr1("Line for an indexOfStr.");
405 OUString
suSearch("Line");
406 sal_Int32 nIndex
= rtl_ustr_indexOfStr( aStr1
.getStr(), suSearch
);
407 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 0);
409 /* OUString */ suSearch("for");
410 /* sal_Int32 */ nIndex
= rtl_ustr_indexOfStr( aStr1
.getStr(), suSearch
);
411 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 5);
413 /* OUString */ suSearch("a");
414 /* sal_Int32 */ nIndex
= rtl_ustr_indexOfStr( aStr1
.getStr(), suSearch
);
415 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 9);
417 /* OUString */ suSearch("an index");
418 /* sal_Int32 */ nIndex
= rtl_ustr_indexOfStr( aStr1
.getStr(), suSearch
);
419 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
==9);
422 void indexOfStr_002()
424 OUString
aStr1("Line for an indexOfStr.");
425 OUString
suSearch("not exist");
426 sal_Int32 nIndex
= rtl_ustr_indexOfStr( aStr1
.getStr(), suSearch
);
428 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== -1 );
431 // Change the following lines only, if you add, remove or rename
432 // member functions of the current class,
433 // because these macros are need by auto register mechanism.
435 CPPUNIT_TEST_SUITE(indexOfStr
);
436 CPPUNIT_TEST(indexOfStr_000
);
437 CPPUNIT_TEST(indexOfStr_001
);
438 CPPUNIT_TEST(indexOfStr_002
);
439 CPPUNIT_TEST_SUITE_END();
442 class lastIndexOfStr
: public CppUnit::TestFixture
446 void lastIndexOfStr_000()
448 rtl_ustr_lastIndexOfStr( NULL
, NULL
);
451 void lastIndexOfStr_000_1()
453 OUString
aStr1("Line for a lastIndexOfStr.");
454 rtl_ustr_lastIndexOfStr( aStr1
.getStr(), NULL
);
457 void lastIndexOfStr_001()
459 OUString
aStr1("Line for a lastIndexOfStr.");
460 OUString
aSearchStr("Index");
462 sal_Int32 nIndex
= rtl_ustr_lastIndexOfStr( aStr1
.getStr(), aSearchStr
.getStr() );
463 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 15);
465 /* OString */ aSearchStr
= OUString("Line");
466 /* sal_Int32 */ nIndex
= rtl_ustr_lastIndexOfStr( aStr1
.getStr(), aSearchStr
.getStr() );
467 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 0);
469 /* OString */ aSearchStr
= OUString();
470 /* sal_Int32 */ nIndex
= rtl_ustr_lastIndexOfStr( aStr1
.getStr(), aSearchStr
.getStr() );
471 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== -1);
474 void lastIndexOfStr_002()
476 OUString
aStr1("Line for a lastIndexOfStr.");
477 OUString
aSearchStr("foo");
478 sal_Int32 nIndex
= rtl_ustr_lastIndexOfStr( aStr1
.getStr(), aSearchStr
.getStr() );
480 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== -1 );
483 void lastIndexOfStr_003()
485 OUString
aStr1("Line for a lastIndexOfStr.");
486 OUString
aSearchStr("O");
487 sal_Int32 nIndex
= rtl_ustr_lastIndexOfStr( aStr1
.getStr(), aSearchStr
.getStr() );
489 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex
== 20 );
492 // Change the following lines only, if you add, remove or rename
493 // member functions of the current class,
494 // because these macros are need by auto register mechanism.
496 CPPUNIT_TEST_SUITE(lastIndexOfStr
);
497 CPPUNIT_TEST(lastIndexOfStr_000
);
498 CPPUNIT_TEST(lastIndexOfStr_001
);
499 CPPUNIT_TEST(lastIndexOfStr_002
);
500 CPPUNIT_TEST(lastIndexOfStr_003
);
501 CPPUNIT_TEST_SUITE_END();
502 }; // class lastIndexOfStr
504 class replaceChar
: public CppUnit::TestFixture
508 void replaceChar_000()
510 rtl_ustr_replaceChar( NULL
, 0, 0 );
513 void replaceChar_001()
515 OUString
aStr1("replace char.");
516 OUString
aShouldStr1("ruplacu char.");
518 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
519 sal_Unicode
* pStr
= (sal_Unicode
*) malloc( nLength
+ sizeof(sal_Unicode
)); // length + 1 (null terminator)
520 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
521 memcpy(pStr
, aStr1
.getStr(), nLength
);
522 pStr
[aStr1
.getLength()] = 0;
524 rtl_ustr_replaceChar( pStr
, 'e', 'u' );
525 OUString
suStr(pStr
, aStr1
.getLength());
527 CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1
.equals(suStr
) == sal_True
);
531 // Change the following lines only, if you add, remove or rename
532 // member functions of the current class,
533 // because these macros are need by auto register mechanism.
535 CPPUNIT_TEST_SUITE(replaceChar
);
536 CPPUNIT_TEST(replaceChar_000
);
537 CPPUNIT_TEST(replaceChar_001
);
538 CPPUNIT_TEST_SUITE_END();
539 }; // class replaceChar
541 class replaceChar_WithLength
: public CppUnit::TestFixture
545 void replaceChar_WithLength_000()
547 rtl_ustr_replaceChar_WithLength( NULL
, 0, 0, 0 );
550 void replaceChar_WithLength_000_1()
552 rtl_ustr_replaceChar_WithLength( NULL
, 1, 0, 0 );
554 void replaceChar_WithLength_001()
556 OUString
aStr1("replace char.");
557 OUString
aShouldStr1("ruplace char.");
559 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
560 sal_Unicode
* pStr
= (sal_Unicode
*) malloc(nLength
);
561 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
562 memcpy(pStr
, aStr1
.getStr(), nLength
);
564 rtl_ustr_replaceChar_WithLength( pStr
, 6, 'e', 'u' );
565 OUString
suStr(pStr
, aStr1
.getLength());
567 CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1
.equals(suStr
) == sal_True
);
571 void replaceChar_WithLength_002()
573 OUString
aStr1 ("eeeeeeeeeeeee");
574 OUString
aShouldStr1("uuuuuueeeeeee");
576 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
577 sal_Unicode
* pStr
= (sal_Unicode
*) malloc(nLength
); // no null terminator is need
578 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
579 memcpy(pStr
, aStr1
.getStr(), nLength
);
581 rtl_ustr_replaceChar_WithLength( pStr
, 6, 'e', 'u' );
582 OUString
suStr(pStr
, aStr1
.getLength());
584 CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1
.equals(suStr
) == sal_True
);
588 // Change the following lines only, if you add, remove or rename
589 // member functions of the current class,
590 // because these macros are need by auto register mechanism.
592 CPPUNIT_TEST_SUITE(replaceChar_WithLength
);
593 CPPUNIT_TEST(replaceChar_WithLength_000
);
594 CPPUNIT_TEST(replaceChar_WithLength_000_1
);
595 CPPUNIT_TEST(replaceChar_WithLength_001
);
596 CPPUNIT_TEST(replaceChar_WithLength_002
);
597 CPPUNIT_TEST_SUITE_END();
598 }; // class replaceChar
600 class toAsciiLowerCase
: public CppUnit::TestFixture
604 void toAsciiLowerCase_000()
606 rtl_ustr_toAsciiLowerCase( NULL
);
609 void toAsciiLowerCase_001()
611 OUString
aStr1("CHANGE THIS TO ASCII LOWER CASE.");
612 OUString
aShouldStr1("change this to ascii lower case.");
614 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
615 sal_Unicode
* pStr
= (sal_Unicode
*) malloc(nLength
+ sizeof(sal_Unicode
) ); // we need to add '\0' so one more
616 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
617 memcpy(pStr
, aStr1
.getStr(), nLength
);
618 pStr
[aStr1
.getLength()] = 0;
620 rtl_ustr_toAsciiLowerCase( pStr
);
621 OUString
suStr(pStr
, aStr1
.getLength());
623 CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1
.equals(suStr
) == sal_True
);
627 // Change the following lines only, if you add, remove or rename
628 // member functions of the current class,
629 // because these macros are need by auto register mechanism.
631 CPPUNIT_TEST_SUITE(toAsciiLowerCase
);
632 CPPUNIT_TEST(toAsciiLowerCase_000
);
633 CPPUNIT_TEST(toAsciiLowerCase_001
);
634 CPPUNIT_TEST_SUITE_END();
635 }; // class replaceChar
637 class toAsciiLowerCase_WithLength
: public CppUnit::TestFixture
641 void toAsciiLowerCase_WithLength_000()
643 rtl_ustr_toAsciiLowerCase_WithLength( NULL
, 0 );
646 void toAsciiLowerCase_WithLength_001()
648 OUString
aStr1("CHANGE THIS TO ASCII LOWER CASE.");
649 OUString
aShouldStr1("change thiS TO ASCII LOWER CASE.");
651 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
652 sal_Unicode
* pStr
= (sal_Unicode
*) malloc(nLength
);
653 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
654 memcpy(pStr
, aStr1
.getStr(), nLength
);
656 rtl_ustr_toAsciiLowerCase_WithLength( pStr
, 10 );
658 OUString
suStr(pStr
, aStr1
.getLength());
659 sal_Bool bResult
= aShouldStr1
.equals(suStr
);
661 printOUString(suStr
);
662 printf("Result length: %d\n", suStr
.getLength() );
663 printf("Result: %d\n", bResult
);
665 CPPUNIT_ASSERT_MESSAGE("failed", bResult
== sal_True
);
669 // Change the following lines only, if you add, remove or rename
670 // member functions of the current class,
671 // because these macros are need by auto register mechanism.
673 CPPUNIT_TEST_SUITE(toAsciiLowerCase_WithLength
);
674 CPPUNIT_TEST(toAsciiLowerCase_WithLength_000
);
675 CPPUNIT_TEST(toAsciiLowerCase_WithLength_001
);
676 CPPUNIT_TEST_SUITE_END();
677 }; // class replaceChar
679 class toAsciiUpperCase
: public CppUnit::TestFixture
683 void toAsciiUpperCase_000()
685 rtl_ustr_toAsciiUpperCase( NULL
);
688 void toAsciiUpperCase_001()
690 OUString
aStr1("change this to ascii upper case.");
691 OUString
aShouldStr1("CHANGE THIS TO ASCII UPPER CASE.");
693 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
694 sal_Unicode
* pStr
= (sal_Unicode
*) malloc(nLength
+ sizeof(sal_Unicode
)); // length + null terminator
695 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
696 memcpy(pStr
, aStr1
.getStr(), nLength
);
697 pStr
[aStr1
.getLength()] = 0;
699 rtl_ustr_toAsciiUpperCase( pStr
);
700 OUString
suStr(pStr
, aStr1
.getLength());
702 CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1
.equals(suStr
) == sal_True
);
706 // Change the following lines only, if you add, remove or rename
707 // member functions of the current class,
708 // because these macros are need by auto register mechanism.
710 CPPUNIT_TEST_SUITE(toAsciiUpperCase
);
711 CPPUNIT_TEST(toAsciiUpperCase_000
);
712 CPPUNIT_TEST(toAsciiUpperCase_001
);
713 CPPUNIT_TEST_SUITE_END();
714 }; // class replaceChar
716 class toAsciiUpperCase_WithLength
: public CppUnit::TestFixture
720 void toAsciiUpperCase_WithLength_000()
722 rtl_ustr_toAsciiUpperCase_WithLength( NULL
, 0 );
725 void toAsciiUpperCase_WithLength_001()
727 OUString
aStr1("change this to ascii lower case.");
728 OUString
aShouldStr1("CHANGE THIs to ascii lower case.");
730 sal_uInt32 nLength
= aStr1
.getLength() * sizeof(sal_Unicode
);
731 sal_Unicode
* pStr
= (sal_Unicode
*) malloc(nLength
);
732 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr
!= NULL
);
734 memcpy(pStr
, aStr1
.getStr(), nLength
);
735 rtl_ustr_toAsciiUpperCase_WithLength( pStr
, 10 );
736 OUString
suStr(pStr
, aStr1
.getLength());
738 // printf("Uppercase with length: '%s'\n", aStr1.getStr());
739 CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1
.equals(suStr
) == sal_True
);
743 // Change the following lines only, if you add, remove or rename
744 // member functions of the current class,
745 // because these macros are need by auto register mechanism.
747 CPPUNIT_TEST_SUITE(toAsciiUpperCase_WithLength
);
748 CPPUNIT_TEST(toAsciiUpperCase_WithLength_000
);
749 CPPUNIT_TEST(toAsciiUpperCase_WithLength_001
);
750 CPPUNIT_TEST_SUITE_END();
751 }; // class replaceChar
753 class trim_WithLength
: public CppUnit::TestFixture
756 void trim_WithLength_000()
758 rtl_ustr_trim_WithLength(NULL
, 0);
762 void trim_WithLength_000_1()
764 OUString
suStr(" trim this");
766 sal_uInt32 nLength
= suStr
.getLength() * sizeof(sal_Unicode
);
767 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(nLength
);
768 memcpy(pStr
, suStr
.getStr(), nLength
);
770 rtl_ustr_trim_WithLength( pStr
, 0 );
774 void trim_WithLength_001()
776 OUString
suStr(" trim this");
777 sal_uInt32 nLength
= suStr
.getLength() * sizeof(sal_Unicode
);
778 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(nLength
);
779 memcpy(pStr
, suStr
.getStr(), nLength
);
781 rtl_ustr_trim_WithLength( pStr
, 2 );
783 CPPUNIT_ASSERT_MESSAGE("string should be empty", OUString(pStr
).getLength() == 0);
787 void trim_WithLength_002()
789 OUString
suStr("trim this");
791 sal_uInt32 nLength
= suStr
.getLength() * sizeof(sal_Unicode
);
792 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(nLength
);
793 memcpy(pStr
, suStr
.getStr(), nLength
);
795 rtl_ustr_trim_WithLength( pStr
, 5 );
797 CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", OUString(pStr
).getLength() == 4);
801 void trim_WithLength_003()
803 OUString
suStr(" trim this");
805 sal_uInt32 nLength
= suStr
.getLength() * sizeof(sal_Unicode
);
806 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(nLength
);
807 memcpy(pStr
, suStr
.getStr(), nLength
);
809 rtl_ustr_trim_WithLength( pStr
, 11 );
811 CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", OUString(pStr
).getLength() == 4);
815 void trim_WithLength_004()
817 OUString
suStr("\r\n\t \n\r trim \n this");
819 sal_uInt32 nLength
= suStr
.getLength() * sizeof(sal_Unicode
);
820 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(nLength
);
821 memcpy(pStr
, suStr
.getStr(), nLength
);
823 rtl_ustr_trim_WithLength( pStr
, 17 );
825 CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", OUString(pStr
).getLength() == 4);
829 void trim_WithLength_005()
831 OUString
suStr("\r\n\t \n\r trim \t this \n\r\t\t ");
833 sal_uInt32 nLength
= suStr
.getLength() * sizeof(sal_Unicode
);
834 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(nLength
);
835 memcpy(pStr
, suStr
.getStr(), nLength
);
837 rtl_ustr_trim_WithLength( pStr
, suStr
.getLength() );
839 CPPUNIT_ASSERT_MESSAGE("string should contain 'trim \\t this'", OUString(pStr
).getLength() == 11);
843 // Change the following lines only, if you add, remove or rename
844 // member functions of the current class,
845 // because these macros are need by auto register mechanism.
847 CPPUNIT_TEST_SUITE(trim_WithLength
);
848 CPPUNIT_TEST(trim_WithLength_000
);
849 CPPUNIT_TEST(trim_WithLength_000_1
);
850 CPPUNIT_TEST(trim_WithLength_001
);
851 CPPUNIT_TEST(trim_WithLength_002
);
852 CPPUNIT_TEST(trim_WithLength_003
);
853 CPPUNIT_TEST(trim_WithLength_004
);
854 CPPUNIT_TEST(trim_WithLength_005
);
855 CPPUNIT_TEST_SUITE_END();
858 class valueOfChar
: public CppUnit::TestFixture
861 void valueOfChar_000()
863 rtl_ustr_valueOfChar(NULL
, 0);
866 void valueOfChar_001()
868 sal_Unicode
*pStr
= (sal_Unicode
*)malloc(RTL_USTR_MAX_VALUEOFCHAR
);
871 rtl_ustr_valueOfChar(pStr
, 'A');
873 CPPUNIT_ASSERT_MESSAGE("string should contain 'A'", pStr
[0] == L
'A');
878 // Change the following lines only, if you add, remove or rename
879 // member functions of the current class,
880 // because these macros are need by auto register mechanism.
882 CPPUNIT_TEST_SUITE(valueOfChar
);
883 CPPUNIT_TEST(valueOfChar_000
);
884 CPPUNIT_TEST(valueOfChar_001
);
885 CPPUNIT_TEST_SUITE_END();
888 class ascii_compare_WithLength
: public CppUnit::TestFixture
893 sal_Unicode pUnicode
[] = {0xffff, 0xffff};
894 char const * pAscii
= "reference";
896 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(pUnicode
, 0, pAscii
);
897 CPPUNIT_ASSERT_MESSAGE("ref string is empty, compare failed, needs to be <0.", value
< 0);
900 void equal_ascii_shorter()
902 OUString
refStr("referenceString");
903 char const * pAscii
= "reference";
905 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(refStr
.pData
->buffer
, refStr
.pData
->length
, pAscii
);
906 CPPUNIT_ASSERT_MESSAGE("ref string is bigger, compare failed, needs to be >0.", value
> 0);
909 void equal_ascii_shorter_asciiLength()
911 OUString
refStr("referenceString");
912 char const * pAscii
= "reference";
914 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(refStr
.pData
->buffer
, rtl_str_getLength(pAscii
), pAscii
);
915 CPPUNIT_ASSERT_MESSAGE("ref string is bigger despite ascii length, compare failed, needs to be == 0.", value
== 0);
918 void equal_ref_shorter()
920 OUString
refStr("reference");
921 char const * pAscii
= "referenceString";
923 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(refStr
.pData
->buffer
, refStr
.pData
->length
, pAscii
);
924 CPPUNIT_ASSERT_MESSAGE("ascii string is bigger, but only compared to ref length, needs to be 0.", value
< 0);
929 OUString
refStr("reference");
930 char const * pAscii
= "reference";
932 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(refStr
.pData
->buffer
, refStr
.pData
->length
, pAscii
);
933 CPPUNIT_ASSERT_MESSAGE("strings are equal, compare failed, needs to be 0.", value
== 0);
936 void unequal_reference_bigger()
938 OUString
refStr("defghi");
939 char const * pAscii
= "abc";
941 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(refStr
.pData
->buffer
, refStr
.pData
->length
, pAscii
);
942 CPPUNIT_ASSERT_MESSAGE("strings are unequal and ref is bigger, needs to be >0.", value
> 0);
945 void unequal_ascii_bigger()
947 OUString
refStr("abc");
948 char const * pAscii
= "defghi";
950 sal_Int32 value
= rtl_ustr_ascii_compare_WithLength(refStr
.pData
->buffer
, refStr
.pData
->length
, pAscii
);
952 CPPUNIT_ASSERT_MESSAGE("strings are unequal and ascii is bigger, needs to be <0.", value
< 0);
955 CPPUNIT_TEST_SUITE(ascii_compare_WithLength
);
956 CPPUNIT_TEST(zero_length
);
957 CPPUNIT_TEST(equal_ascii_shorter
);
958 CPPUNIT_TEST(equal_ascii_shorter_asciiLength
);
959 CPPUNIT_TEST(equal_ref_shorter
);
961 CPPUNIT_TEST(unequal_reference_bigger
);
962 CPPUNIT_TEST(unequal_ascii_bigger
);
963 CPPUNIT_TEST_SUITE_END();
966 class ascii_shortenedCompareIgnoreAsciiCase_WithLength
: public CppUnit::TestFixture
970 void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000()
972 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( NULL
, 0, NULL
, 0);
976 void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1()
978 OUString
aStr1("Line must be equal.");
979 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), aStr1
.getLength(), NULL
, 0);
982 void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2()
984 OUString
aStr1("Line must be equal.");
985 OString sStr2
= "Line is shorter.";
986 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1
.getStr(), sStr2
.getLength(), sStr2
.getStr(), 0);
989 void ascii_shortenedCompareIgnoreAsciiCase_WithLength_001()
994 sal_Int32 nValue
= rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1
, 0, sStr2
.getStr(), 0);
995 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
998 void ascii_shortenedCompareIgnoreAsciiCase_WithLength_002()
1000 OUString
suStr1("Line must be equal.");
1001 OString sStr2
= "Line must be equal.";
1003 sal_Int32 nValue
= rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1
.getStr(), suStr1
.getLength(), sStr2
.getStr(), sStr2
.getLength());
1004 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1007 void ascii_shortenedCompareIgnoreAsciiCase_WithLength_003()
1009 OUString
suStr1("Line must differ.");
1010 OString sStr2
= "Line must be differ and longer.";
1012 sal_Int32 nValue
= rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1
.getStr(), suStr1
.getLength(), sStr2
.getStr(), sStr2
.getLength());
1013 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
1016 // Change the following lines only, if you add, remove or rename
1017 // member functions of the current class,
1018 // because these macros are need by auto register mechanism.
1020 CPPUNIT_TEST_SUITE(ascii_shortenedCompareIgnoreAsciiCase_WithLength
);
1021 CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000
);
1022 CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1
);
1023 CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2
);
1024 CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_001
);
1025 CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_002
);
1026 CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_003
);
1027 CPPUNIT_TEST_SUITE_END();
1028 }; // class ascii_shortenedCompareIgnoreAsciiCase_WithLength
1030 class ascii_compareIgnoreAsciiCase_WithLength
: public CppUnit::TestFixture
1034 void ascii_compareIgnoreAsciiCase_WithLength_000()
1036 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( NULL
, 0, NULL
);
1040 void ascii_compareIgnoreAsciiCase_WithLength_000_1()
1042 OUString
aStr1("Line must be equal.");
1043 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1
.getStr(), 0, NULL
);
1046 void ascii_compareIgnoreAsciiCase_WithLength_000_2()
1048 OUString
aStr1("Line must be equal.");
1049 OString sStr2
= "Line is shorter.";
1050 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1
.getStr(), sStr2
.getLength(), sStr2
.getStr());
1053 void ascii_compareIgnoreAsciiCase_WithLength_001()
1058 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1
, 0, sStr2
.getStr());
1059 CPPUNIT_ASSERT_MESSAGE("compareIgnoreAsciiCase_WithLength failed, strings are equal.", nValue
== 0);
1062 void ascii_compareIgnoreAsciiCase_WithLength_002()
1064 OUString
suStr1("Line must be equal.");
1065 OString sStr2
= "Line must be equal.";
1067 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1
.getStr(), suStr1
.getLength(), sStr2
.getStr());
1068 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1071 void ascii_compareIgnoreAsciiCase_WithLength_003()
1073 OUString
suStr1("Line must differ.");
1074 OString sStr2
= "Line must be differ and longer.";
1076 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1
.getStr(), suStr1
.getLength(), sStr2
.getStr());
1077 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
1080 // Change the following lines only, if you add, remove or rename
1081 // member functions of the current class,
1082 // because these macros are need by auto register mechanism.
1084 CPPUNIT_TEST_SUITE(ascii_compareIgnoreAsciiCase_WithLength
);
1085 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000
);
1086 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000_1
);
1087 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000_2
);
1088 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_001
);
1089 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_002
);
1090 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_003
);
1091 CPPUNIT_TEST_SUITE_END();
1092 }; // class ascii_compareIgnoreAsciiCase_WithLength
1094 class ascii_compare
: public CppUnit::TestFixture
1098 void ascii_compare_000()
1100 rtl_ustr_ascii_compare( NULL
, NULL
);
1104 void ascii_compare_000_1()
1106 OUString
aStr1("Line must be equal.");
1107 rtl_ustr_ascii_compare( aStr1
.getStr(), NULL
);
1110 void ascii_compare_001()
1115 sal_Int32 nValue
= rtl_ustr_ascii_compare( suStr1
, sStr2
.getStr());
1116 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1119 void ascii_compare_002()
1121 OUString
suStr1("Line must be equal.");
1122 OString sStr2
= "Line must be equal.";
1124 sal_Int32 nValue
= rtl_ustr_ascii_compare( suStr1
.getStr(), sStr2
.getStr());
1125 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1128 void ascii_compare_003()
1130 OUString
suStr1("Line must differ.");
1131 OString sStr2
= "Line foo bar, ok, differ.";
1133 sal_Int32 nValue
= rtl_ustr_ascii_compare( suStr1
.getStr(), sStr2
.getStr());
1134 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
1137 // Change the following lines only, if you add, remove or rename
1138 // member functions of the current class,
1139 // because these macros are need by auto register mechanism.
1141 CPPUNIT_TEST_SUITE(ascii_compare
);
1142 CPPUNIT_TEST(ascii_compare_000
);
1143 CPPUNIT_TEST(ascii_compare_000_1
);
1144 CPPUNIT_TEST(ascii_compare_001
);
1145 CPPUNIT_TEST(ascii_compare_002
);
1146 CPPUNIT_TEST(ascii_compare_003
);
1147 CPPUNIT_TEST_SUITE_END();
1148 }; // class ascii_compare
1150 class ascii_compareIgnoreAsciiCase
: public CppUnit::TestFixture
1154 void ascii_compareIgnoreAsciiCase_000()
1156 rtl_ustr_ascii_compareIgnoreAsciiCase( NULL
, NULL
);
1160 void ascii_compareIgnoreAsciiCase_000_1()
1162 OUString
aStr1("Line must be equal.");
1163 rtl_ustr_ascii_compareIgnoreAsciiCase( aStr1
.getStr(), NULL
);
1166 void ascii_compareIgnoreAsciiCase_001()
1171 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
, sStr2
.getStr());
1172 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1175 void ascii_compareIgnoreAsciiCase_002()
1177 OUString
suStr1("Line must be equal.");
1178 OString sStr2
= "Line must be equal.";
1180 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
.getStr(), sStr2
.getStr());
1181 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1184 void ascii_compareIgnoreAsciiCase_002_1()
1186 OUString
suStr1("Line must be equal, when ignore case.");
1187 OString sStr2
= "LINE MUST BE EQUAL, WHEN IGNORE CASE.";
1189 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
.getStr(), sStr2
.getStr());
1190 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitive).", nValue
== 0);
1193 void ascii_compareIgnoreAsciiCase_003()
1195 OUString
suStr1("Line must differ.");
1196 OString sStr2
= "Line foo bar, ok, differ.";
1198 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
.getStr(), sStr2
.getStr());
1199 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
1202 //! LLA: some more tests with some high level strings
1204 // void ascii_compareIgnoreAsciiCase_001()
1206 // OUString suStr1("change this to ascii upper case.");
1207 // OUString aShouldStr1("CHANGE THIS TO ASCII UPPER CASE.");
1209 // sal_uInt32 nLength = suStr1.getLength() * sizeof(sal_Unicode);
1210 // sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
1211 // CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
1212 // memset(pStr, 0, nLength + sizeof(sal_Unicode));
1213 // memcpy(pStr, suStr1.getStr(), nLength);
1215 // rtl_ustr_ascii_compareIgnoreAsciiCase( pStr );
1216 // OUString suStr(pStr, suStr1.getLength());
1218 // CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
1222 // Change the following lines only, if you add, remove or rename
1223 // member functions of the current class,
1224 // because these macros are need by auto register mechanism.
1226 CPPUNIT_TEST_SUITE(ascii_compareIgnoreAsciiCase
);
1227 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000
);
1228 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000_1
);
1229 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_001
);
1230 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002
);
1231 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002_1
);
1232 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_003
);
1233 CPPUNIT_TEST_SUITE_END();
1234 }; // class ascii_compareIgnoreAsciiCase
1236 // sample out of inc/rtl/ustring.hxx
1237 // rtl_uString * pToken = NULL;
1238 // sal_Int32 nIndex = 0;
1242 // nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
1245 // while (nIndex >= 0);
1247 class getToken
: public CppUnit::TestFixture
1253 rtl_ustr_ascii_compareIgnoreAsciiCase( NULL
, NULL
);
1257 void ascii_compareIgnoreAsciiCase_000_1()
1259 OUString
aStr1("Line must be equal.");
1260 rtl_ustr_ascii_compareIgnoreAsciiCase( aStr1
.getStr(), NULL
);
1263 void ascii_compareIgnoreAsciiCase_001()
1268 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
, sStr2
.getStr());
1269 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1272 void ascii_compareIgnoreAsciiCase_002()
1274 OUString
suStr1("Line must be equal.");
1275 OString sStr2
= "Line must be equal.";
1277 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
.getStr(), sStr2
.getStr());
1278 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue
== 0);
1281 void ascii_compareIgnoreAsciiCase_002_1()
1283 OUString
suStr1("Line must be equal, when ignore case.");
1284 OString sStr2
= "LINE MUST BE EQUAL, WHEN IGNORE CASE.";
1286 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
.getStr(), sStr2
.getStr());
1287 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitive).", nValue
== 0);
1290 void ascii_compareIgnoreAsciiCase_003()
1292 OUString
suStr1("Line must differ.");
1293 OString sStr2
= "Line foo bar, ok, differ.";
1295 sal_Int32 nValue
= rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1
.getStr(), sStr2
.getStr());
1296 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue
!= 0);
1299 //! LLA: some more tests with some high level strings
1301 // void ascii_compareIgnoreAsciiCase_001()
1303 // OUString suStr1("change this to ascii upper case.");
1304 // OUString aShouldStr1("CHANGE THIS TO ASCII UPPER CASE.");
1306 // sal_uInt32 nLength = suStr1.getLength() * sizeof(sal_Unicode);
1307 // sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
1308 // CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
1309 // memset(pStr, 0, nLength + sizeof(sal_Unicode));
1310 // memcpy(pStr, suStr1.getStr(), nLength);
1312 // rtl_ustr_ascii_compareIgnoreAsciiCase( pStr );
1313 // OUString suStr(pStr, suStr1.getLength());
1315 // CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
1319 // Change the following lines only, if you add, remove or rename
1320 // member functions of the current class,
1321 // because these macros are need by auto register mechanism.
1323 CPPUNIT_TEST_SUITE(ascii_compareIgnoreAsciiCase
);
1324 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000
);
1325 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000_1
);
1326 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_001
);
1327 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002
);
1328 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002_1
);
1329 CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_003
);
1330 CPPUNIT_TEST_SUITE_END();
1331 }; // class ascii_compareIgnoreAsciiCase
1333 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::compare
);
1334 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::compareIgnoreAsciiCase
);
1336 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::ascii_compare_WithLength
);
1338 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::shortenedCompareIgnoreAsciiCase_WithLength
);
1339 // CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::hashCode);
1341 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::indexOfChar
);
1342 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::lastIndexOfChar
);
1343 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::indexOfStr
);
1344 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::lastIndexOfStr
);
1346 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::replaceChar
);
1347 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::replaceChar_WithLength
);
1349 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::toAsciiLowerCase
);
1350 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::toAsciiLowerCase_WithLength
);
1351 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::toAsciiUpperCase
);
1352 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::toAsciiUpperCase_WithLength
);
1354 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::trim_WithLength
);
1355 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::valueOfChar
);
1357 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::ascii_compare
);
1358 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::ascii_compareIgnoreAsciiCase
);
1359 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::ascii_compareIgnoreAsciiCase_WithLength
);
1360 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_ustr::ascii_shortenedCompareIgnoreAsciiCase_WithLength
);
1362 } // namespace rtl_ustr
1364 // this macro creates an empty function, which will called by the RegisterAllFunctions("")
1365 // to let the user the possibility to also register some functions by hand.
1366 CPPUNIT_PLUGIN_IMPLEMENT();
1368 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */