xref: /aoo42x/main/sal/qa/rtl/oustring/rtl_ustr.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
30*cdf0e10cSrcweir #include "precompiled_sal.hxx"
31*cdf0e10cSrcweir #include <testshl/simpleheader.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir /** print a UNI_CODE file name.
34*cdf0e10cSrcweir */
35*cdf0e10cSrcweir inline void printOUString( ::rtl::OUString const & _suStr )
36*cdf0e10cSrcweir {
37*cdf0e10cSrcweir     rtl::OString aString;
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir     t_print( "OUString: " );
40*cdf0e10cSrcweir     aString = ::rtl::OUStringToOString( _suStr, RTL_TEXTENCODING_ASCII_US );
41*cdf0e10cSrcweir     t_print( "%s\n", aString.getStr( ) );
42*cdf0e10cSrcweir }
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace rtl_ustr
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     class compare : public CppUnit::TestFixture
49*cdf0e10cSrcweir     {
50*cdf0e10cSrcweir     public:
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir         void compare_000()
54*cdf0e10cSrcweir             {
55*cdf0e10cSrcweir                 rtl_ustr_compare( NULL, NULL);
56*cdf0e10cSrcweir                 // should not GPF
57*cdf0e10cSrcweir             }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir         void compare_000_1()
60*cdf0e10cSrcweir             {
61*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
62*cdf0e10cSrcweir                 rtl_ustr_compare( aStr1.getStr(), NULL);
63*cdf0e10cSrcweir                 // should not GPF
64*cdf0e10cSrcweir             }
65*cdf0e10cSrcweir         void compare_001()
66*cdf0e10cSrcweir             {
67*cdf0e10cSrcweir                 rtl::OUString aStr1;
68*cdf0e10cSrcweir                 rtl::OUString aStr2;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr());
71*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
72*cdf0e10cSrcweir             }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir         void compare_002()
75*cdf0e10cSrcweir             {
76*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
77*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line must be equal.");
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr());
80*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
81*cdf0e10cSrcweir             }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir         void compare_003()
84*cdf0e10cSrcweir             {
85*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
86*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr());
89*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
90*cdf0e10cSrcweir             }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
93*cdf0e10cSrcweir     // member functions of the current class,
94*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(compare);
97*cdf0e10cSrcweir     CPPUNIT_TEST(compare_000);
98*cdf0e10cSrcweir     CPPUNIT_TEST(compare_000_1);
99*cdf0e10cSrcweir     CPPUNIT_TEST(compare_001);
100*cdf0e10cSrcweir     CPPUNIT_TEST(compare_002);
101*cdf0e10cSrcweir     CPPUNIT_TEST(compare_003);
102*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
103*cdf0e10cSrcweir }; // class compare
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     class compareIgnoreAsciiCase : public CppUnit::TestFixture
107*cdf0e10cSrcweir     {
108*cdf0e10cSrcweir     public:
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         void compare_000()
111*cdf0e10cSrcweir             {
112*cdf0e10cSrcweir                 rtl_ustr_compareIgnoreAsciiCase( NULL, NULL);
113*cdf0e10cSrcweir             }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir         void compare_000_1()
116*cdf0e10cSrcweir             {
117*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
118*cdf0e10cSrcweir                 rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
119*cdf0e10cSrcweir             }
120*cdf0e10cSrcweir         void compare_001()
121*cdf0e10cSrcweir             {
122*cdf0e10cSrcweir                 rtl::OUString aStr1;
123*cdf0e10cSrcweir                 rtl::OUString aStr2;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
126*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
127*cdf0e10cSrcweir             }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir         void compare_002()
130*cdf0e10cSrcweir             {
131*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
132*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line must be equal.");
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
135*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
136*cdf0e10cSrcweir             }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         void compare_002_1()
139*cdf0e10cSrcweir             {
140*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
141*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("LINE MUST BE EQUAL.");
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
144*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
145*cdf0e10cSrcweir             }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir         void compare_003()
148*cdf0e10cSrcweir             {
149*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
150*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
153*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
154*cdf0e10cSrcweir             }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
157*cdf0e10cSrcweir     // member functions of the current class,
158*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(compareIgnoreAsciiCase);
161*cdf0e10cSrcweir     CPPUNIT_TEST(compare_000);
162*cdf0e10cSrcweir     CPPUNIT_TEST(compare_000_1);
163*cdf0e10cSrcweir     CPPUNIT_TEST(compare_001);
164*cdf0e10cSrcweir     CPPUNIT_TEST(compare_002);
165*cdf0e10cSrcweir     CPPUNIT_TEST(compare_002_1);
166*cdf0e10cSrcweir     CPPUNIT_TEST(compare_003);
167*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
168*cdf0e10cSrcweir     }; // class compareIgnoreAsciiCase
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir // -----------------------------------------------------------------------------
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     class shortenedCompareIgnoreAsciiCase_WithLength : public CppUnit::TestFixture
173*cdf0e10cSrcweir     {
174*cdf0e10cSrcweir     public:
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         void compare_000()
177*cdf0e10cSrcweir             {
178*cdf0e10cSrcweir                 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( NULL, 0, NULL, 0, 0);
179*cdf0e10cSrcweir             }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         void compare_000_1()
182*cdf0e10cSrcweir             {
183*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
184*cdf0e10cSrcweir                 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), NULL, 0, 1);
185*cdf0e10cSrcweir             }
186*cdf0e10cSrcweir         void compare_001()
187*cdf0e10cSrcweir             {
188*cdf0e10cSrcweir                 rtl::OUString aStr1;
189*cdf0e10cSrcweir                 rtl::OUString aStr2;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), aStr1.getLength());
192*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
193*cdf0e10cSrcweir             }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         void compare_002()
196*cdf0e10cSrcweir             {
197*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
198*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line must be equal.");
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
201*cdf0e10cSrcweir                                                                                        aStr2.getStr(), aStr2.getLength(),
202*cdf0e10cSrcweir                                                                                        aStr1.getLength());
203*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
204*cdf0e10cSrcweir             }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         void compare_002_1()
207*cdf0e10cSrcweir             {
208*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
209*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("LINE MUST BE EQUAL.");
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
212*cdf0e10cSrcweir                                                                                        aStr2.getStr(), aStr2.getLength(),
213*cdf0e10cSrcweir                                                                                        aStr1.getLength());
214*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
215*cdf0e10cSrcweir             }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         void compare_003()
218*cdf0e10cSrcweir             {
219*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
220*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
223*cdf0e10cSrcweir                                                                                        aStr2.getStr(), aStr2.getLength(),
224*cdf0e10cSrcweir                                                                                        5);
225*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal first 5 characters.", nValue == 0);
226*cdf0e10cSrcweir             }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir         void compare_004()
229*cdf0e10cSrcweir             {
230*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
231*cdf0e10cSrcweir                 rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
234*cdf0e10cSrcweir                                                                                        aStr2.getStr(), aStr2.getLength(),
235*cdf0e10cSrcweir                                                                                        aStr1.getLength());
236*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
237*cdf0e10cSrcweir             }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
240*cdf0e10cSrcweir     // member functions of the current class,
241*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(shortenedCompareIgnoreAsciiCase_WithLength);
244*cdf0e10cSrcweir     CPPUNIT_TEST(compare_000);
245*cdf0e10cSrcweir     CPPUNIT_TEST(compare_000_1);
246*cdf0e10cSrcweir     CPPUNIT_TEST(compare_001);
247*cdf0e10cSrcweir     CPPUNIT_TEST(compare_002);
248*cdf0e10cSrcweir     CPPUNIT_TEST(compare_002_1);
249*cdf0e10cSrcweir     CPPUNIT_TEST(compare_003);
250*cdf0e10cSrcweir     CPPUNIT_TEST(compare_004);
251*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
252*cdf0e10cSrcweir }; // class compare
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir // // -----------------------------------------------------------------------------
256*cdf0e10cSrcweir //
257*cdf0e10cSrcweir //     class hashCode : public CppUnit::TestFixture
258*cdf0e10cSrcweir //     {
259*cdf0e10cSrcweir //     public:
260*cdf0e10cSrcweir //
261*cdf0e10cSrcweir //         void hashCode_000()
262*cdf0e10cSrcweir //             {
263*cdf0e10cSrcweir //                 sal_Int32 nHashCode = rtl_ustr_hashCode( NULL );
264*cdf0e10cSrcweir //                 volatile int dummy = 0;
265*cdf0e10cSrcweir //             }
266*cdf0e10cSrcweir //
267*cdf0e10cSrcweir //         void hashCode_001()
268*cdf0e10cSrcweir //             {
269*cdf0e10cSrcweir //                 rtl::OString aStr1 = "Line for a hashCode.";
270*cdf0e10cSrcweir //                 sal_Int32 nHashCode = rtl_ustr_hashCode( aStr1.getStr() );
271*cdf0e10cSrcweir //                 t_print("hashcode: %d\n", nHashCode);
272*cdf0e10cSrcweir //                 // CPPUNIT_ASSERT_MESSAGE("failed.", nValue == 0);
273*cdf0e10cSrcweir //             }
274*cdf0e10cSrcweir //
275*cdf0e10cSrcweir //         void hashCode_002()
276*cdf0e10cSrcweir //             {
277*cdf0e10cSrcweir //                 rtl::OString aStr1 = "Line for a hashCode.";
278*cdf0e10cSrcweir //                 sal_Int32 nHashCode1 = rtl_ustr_hashCode( aStr1.getStr() );
279*cdf0e10cSrcweir //
280*cdf0e10cSrcweir //                 rtl::OString aStr2 = "Line for a hashCode.";
281*cdf0e10cSrcweir //                 sal_Int32 nHashCode2 = rtl_ustr_hashCode( aStr2.getStr() );
282*cdf0e10cSrcweir //
283*cdf0e10cSrcweir //                 CPPUNIT_ASSERT_MESSAGE("hashcodes must be equal.", nHashCode1 == nHashCode2 );
284*cdf0e10cSrcweir //             }
285*cdf0e10cSrcweir //
286*cdf0e10cSrcweir //         void hashCode_003()
287*cdf0e10cSrcweir //             {
288*cdf0e10cSrcweir //                 rtl::OString aStr1 = "Line for a hashCode.";
289*cdf0e10cSrcweir //                 sal_Int32 nHashCode1 = rtl_ustr_hashCode( aStr1.getStr() );
290*cdf0e10cSrcweir //
291*cdf0e10cSrcweir //                 rtl::OString aStr2 = "Line for an other hashcode.";
292*cdf0e10cSrcweir //                 sal_Int32 nHashCode2 = rtl_ustr_hashCode( aStr2.getStr() );
293*cdf0e10cSrcweir //
294*cdf0e10cSrcweir //                 CPPUNIT_ASSERT_MESSAGE("hashcodes must differ.", nHashCode1 != nHashCode2 );
295*cdf0e10cSrcweir //             }
296*cdf0e10cSrcweir //
297*cdf0e10cSrcweir //         // Change the following lines only, if you add, remove or rename
298*cdf0e10cSrcweir //         // member functions of the current class,
299*cdf0e10cSrcweir //         // because these macros are need by auto register mechanism.
300*cdf0e10cSrcweir //
301*cdf0e10cSrcweir //         CPPUNIT_TEST_SUITE(hashCode);
302*cdf0e10cSrcweir //         CPPUNIT_TEST(hashCode_000);
303*cdf0e10cSrcweir //         CPPUNIT_TEST(hashCode_001);
304*cdf0e10cSrcweir //         CPPUNIT_TEST(hashCode_002);
305*cdf0e10cSrcweir //         CPPUNIT_TEST(hashCode_003);
306*cdf0e10cSrcweir //         CPPUNIT_TEST_SUITE_END();
307*cdf0e10cSrcweir //     }; // class compare
308*cdf0e10cSrcweir //
309*cdf0e10cSrcweir //
310*cdf0e10cSrcweir // // -----------------------------------------------------------------------------
311*cdf0e10cSrcweir //
312*cdf0e10cSrcweir     class indexOfChar : public CppUnit::TestFixture
313*cdf0e10cSrcweir     {
314*cdf0e10cSrcweir     public:
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir         void indexOfChar_000()
317*cdf0e10cSrcweir             {
318*cdf0e10cSrcweir                 rtl_ustr_indexOfChar( NULL, 0 );
319*cdf0e10cSrcweir             }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir         void indexOfChar_001()
322*cdf0e10cSrcweir             {
323*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfChar.");
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'L' );
326*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 0);
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'i' );
329*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 1);
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'n' );
332*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 2);
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'e' );
335*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 3);
336*cdf0e10cSrcweir             }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir         void indexOfChar_002()
339*cdf0e10cSrcweir             {
340*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfChar.");
341*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'y' );
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
344*cdf0e10cSrcweir             }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
347*cdf0e10cSrcweir         // member functions of the current class,
348*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(indexOfChar);
351*cdf0e10cSrcweir         CPPUNIT_TEST(indexOfChar_000);
352*cdf0e10cSrcweir         CPPUNIT_TEST(indexOfChar_001);
353*cdf0e10cSrcweir         CPPUNIT_TEST(indexOfChar_002);
354*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
355*cdf0e10cSrcweir     }; // class indexOfChar
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir // // -----------------------------------------------------------------------------
358*cdf0e10cSrcweir     class lastIndexOfChar : public CppUnit::TestFixture
359*cdf0e10cSrcweir     {
360*cdf0e10cSrcweir     public:
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir         void lastIndexOfChar_000()
363*cdf0e10cSrcweir             {
364*cdf0e10cSrcweir                 rtl_ustr_lastIndexOfChar( NULL, 0 );
365*cdf0e10cSrcweir             }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir         void lastIndexOfChar_001()
368*cdf0e10cSrcweir             {
369*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfChar.");
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'C' );
372*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 22);
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'h' );
375*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 23);
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'a' );
378*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 24);
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'r' );
381*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 25);
382*cdf0e10cSrcweir             }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir         void lastIndexOfChar_002()
385*cdf0e10cSrcweir             {
386*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfChar.");
387*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'y' );
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
390*cdf0e10cSrcweir             }
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
393*cdf0e10cSrcweir         // member functions of the current class,
394*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(lastIndexOfChar);
397*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfChar_000);
398*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfChar_001);
399*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfChar_002);
400*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
401*cdf0e10cSrcweir     }; // class lastIndexOfChar
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir // -----------------------------------------------------------------------------
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     class indexOfStr : public CppUnit::TestFixture
407*cdf0e10cSrcweir     {
408*cdf0e10cSrcweir     public:
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir         void indexOfStr_000()
411*cdf0e10cSrcweir             {
412*cdf0e10cSrcweir                 rtl_ustr_indexOfStr( NULL, 0 );
413*cdf0e10cSrcweir             }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir         void indexOfStr_000_1()
416*cdf0e10cSrcweir             {
417*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfStr.");
418*cdf0e10cSrcweir                 rtl_ustr_indexOfStr( aStr1.getStr(), 0 );
419*cdf0e10cSrcweir             }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir         void indexOfStr_001()
422*cdf0e10cSrcweir             {
423*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfStr.");
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir                 rtl::OUString suSearch = rtl::OUString::createFromAscii("Line");
426*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
427*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 0);
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir                 /* rtl::OUString */ suSearch = rtl::OUString::createFromAscii("for");
430*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
431*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 5);
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir                 /* rtl::OUString */ suSearch = rtl::OUString::createFromAscii("a");
434*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
435*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 9);
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir                 /* rtl::OUString */ suSearch = rtl::OUString::createFromAscii("a index");
438*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
439*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex ==9);
440*cdf0e10cSrcweir             }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir         void indexOfStr_002()
443*cdf0e10cSrcweir             {
444*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfStr.");
445*cdf0e10cSrcweir                 rtl::OUString suSearch = rtl::OUString::createFromAscii("not exist");
446*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
449*cdf0e10cSrcweir             }
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
452*cdf0e10cSrcweir         // member functions of the current class,
453*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(indexOfStr);
456*cdf0e10cSrcweir         CPPUNIT_TEST(indexOfStr_000);
457*cdf0e10cSrcweir         CPPUNIT_TEST(indexOfStr_001);
458*cdf0e10cSrcweir         CPPUNIT_TEST(indexOfStr_002);
459*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
460*cdf0e10cSrcweir     }; // class compare
461*cdf0e10cSrcweir // -----------------------------------------------------------------------------
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir     class lastIndexOfStr : public CppUnit::TestFixture
465*cdf0e10cSrcweir     {
466*cdf0e10cSrcweir     public:
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir         void lastIndexOfStr_000()
469*cdf0e10cSrcweir             {
470*cdf0e10cSrcweir                 rtl_ustr_lastIndexOfStr( NULL, NULL );
471*cdf0e10cSrcweir             }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir         void lastIndexOfStr_000_1()
474*cdf0e10cSrcweir             {
475*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
476*cdf0e10cSrcweir                 rtl_ustr_lastIndexOfStr( aStr1.getStr(), NULL );
477*cdf0e10cSrcweir             }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir         void lastIndexOfStr_001()
480*cdf0e10cSrcweir             {
481*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
482*cdf0e10cSrcweir                 rtl::OUString aSearchStr = rtl::OUString::createFromAscii("Index");
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
485*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 15);
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir                 /* rtl::OString */ aSearchStr = rtl::OUString::createFromAscii("Line");
488*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
489*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 0);
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir                 /* rtl::OString */ aSearchStr = rtl::OUString::createFromAscii("");
492*cdf0e10cSrcweir                 /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
493*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1);
494*cdf0e10cSrcweir             }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir         void lastIndexOfStr_002()
497*cdf0e10cSrcweir             {
498*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
499*cdf0e10cSrcweir                 rtl::OUString aSearchStr = rtl::OUString::createFromAscii("foo");
500*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
503*cdf0e10cSrcweir             }
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir         void lastIndexOfStr_003()
506*cdf0e10cSrcweir             {
507*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
508*cdf0e10cSrcweir                 rtl::OUString aSearchStr = rtl::OUString::createFromAscii("O");
509*cdf0e10cSrcweir                 sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 20 );
512*cdf0e10cSrcweir             }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
515*cdf0e10cSrcweir         // member functions of the current class,
516*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(lastIndexOfStr);
519*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfStr_000);
520*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfStr_001);
521*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfStr_002);
522*cdf0e10cSrcweir         CPPUNIT_TEST(lastIndexOfStr_003);
523*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
524*cdf0e10cSrcweir     }; // class lastIndexOfStr
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir // -----------------------------------------------------------------------------
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir     class replaceChar : public CppUnit::TestFixture
529*cdf0e10cSrcweir     {
530*cdf0e10cSrcweir     public:
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir         void replaceChar_000()
533*cdf0e10cSrcweir             {
534*cdf0e10cSrcweir                 rtl_ustr_replaceChar( NULL, 0, 0 );
535*cdf0e10cSrcweir             }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir         void replaceChar_001()
538*cdf0e10cSrcweir             {
539*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("replace char.");
540*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("ruplacu char.");
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
543*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc( nLength + sizeof(sal_Unicode)); // length + 1 (null terminator)
544*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
545*cdf0e10cSrcweir                 memset(pStr, 0, nLength + sizeof(sal_Unicode));
546*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir                 rtl_ustr_replaceChar( pStr, 'e', 'u' );
549*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1.equals(suStr) == sal_True);
552*cdf0e10cSrcweir                 free(pStr);
553*cdf0e10cSrcweir             }
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
556*cdf0e10cSrcweir         // member functions of the current class,
557*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(replaceChar);
560*cdf0e10cSrcweir         CPPUNIT_TEST(replaceChar_000);
561*cdf0e10cSrcweir         CPPUNIT_TEST(replaceChar_001);
562*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
563*cdf0e10cSrcweir     }; // class replaceChar
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir // -----------------------------------------------------------------------------
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir     class replaceChar_WithLength : public CppUnit::TestFixture
568*cdf0e10cSrcweir     {
569*cdf0e10cSrcweir     public:
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir         void replaceChar_WithLength_000()
572*cdf0e10cSrcweir             {
573*cdf0e10cSrcweir                 rtl_ustr_replaceChar_WithLength( NULL, 0, 0, 0 );
574*cdf0e10cSrcweir             }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir         void replaceChar_WithLength_000_1()
577*cdf0e10cSrcweir             {
578*cdf0e10cSrcweir                 rtl_ustr_replaceChar_WithLength( NULL, 1, 0, 0 );
579*cdf0e10cSrcweir             }
580*cdf0e10cSrcweir         void replaceChar_WithLength_001()
581*cdf0e10cSrcweir             {
582*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("replace char.");
583*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("ruplace char.");
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
586*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);
587*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
588*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir                 rtl_ustr_replaceChar_WithLength( pStr, 6, 'e', 'u' );
591*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1.equals(suStr) == sal_True);
594*cdf0e10cSrcweir                 free(pStr);
595*cdf0e10cSrcweir             }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir         void replaceChar_WithLength_002()
598*cdf0e10cSrcweir             {
599*cdf0e10cSrcweir                 rtl::OUString aStr1       = rtl::OUString::createFromAscii("eeeeeeeeeeeee");
600*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("uuuuuueeeeeee");
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
603*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);                 // no null terminator is need
604*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
605*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir                 rtl_ustr_replaceChar_WithLength( pStr, 6, 'e', 'u' );
608*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1.equals(suStr) == sal_True);
611*cdf0e10cSrcweir                 free(pStr);
612*cdf0e10cSrcweir             }
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
615*cdf0e10cSrcweir         // member functions of the current class,
616*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(replaceChar_WithLength);
619*cdf0e10cSrcweir         CPPUNIT_TEST(replaceChar_WithLength_000);
620*cdf0e10cSrcweir         CPPUNIT_TEST(replaceChar_WithLength_000_1);
621*cdf0e10cSrcweir         CPPUNIT_TEST(replaceChar_WithLength_001);
622*cdf0e10cSrcweir         CPPUNIT_TEST(replaceChar_WithLength_002);
623*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
624*cdf0e10cSrcweir     }; // class replaceChar
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir // -----------------------------------------------------------------------------
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir     class toAsciiLowerCase : public CppUnit::TestFixture
630*cdf0e10cSrcweir     {
631*cdf0e10cSrcweir     public:
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir         void toAsciiLowerCase_000()
634*cdf0e10cSrcweir             {
635*cdf0e10cSrcweir                 rtl_ustr_toAsciiLowerCase( NULL );
636*cdf0e10cSrcweir             }
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir         void toAsciiLowerCase_001()
639*cdf0e10cSrcweir             {
640*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII LOWER CASE.");
641*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("change this to ascii lower case.");
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
644*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode) );  // we need to add '\0' so one more
645*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
646*cdf0e10cSrcweir                 memset(pStr, 0, nLength + sizeof(sal_Unicode));                             // empty the sal_Unicode array
647*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir                 rtl_ustr_toAsciiLowerCase( pStr );
650*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
653*cdf0e10cSrcweir                 free(pStr);
654*cdf0e10cSrcweir             }
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
657*cdf0e10cSrcweir         // member functions of the current class,
658*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(toAsciiLowerCase);
661*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiLowerCase_000);
662*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiLowerCase_001);
663*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
664*cdf0e10cSrcweir     }; // class replaceChar
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir     class toAsciiLowerCase_WithLength : public CppUnit::TestFixture
668*cdf0e10cSrcweir     {
669*cdf0e10cSrcweir     public:
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir         void toAsciiLowerCase_WithLength_000()
672*cdf0e10cSrcweir             {
673*cdf0e10cSrcweir                 rtl_ustr_toAsciiLowerCase_WithLength( NULL, 0 );
674*cdf0e10cSrcweir             }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir         void toAsciiLowerCase_WithLength_001()
677*cdf0e10cSrcweir             {
678*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII LOWER CASE.");
679*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("change thiS TO ASCII LOWER CASE.");
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
682*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);
683*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
684*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir                 rtl_ustr_toAsciiLowerCase_WithLength( pStr, 10 );
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
689*cdf0e10cSrcweir                 sal_Bool bResult = aShouldStr1.equals(suStr);
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir                 printOUString(suStr);
692*cdf0e10cSrcweir                 t_print("Result length: %d\n", suStr.getLength() );
693*cdf0e10cSrcweir                 t_print("Result: %d\n", bResult);
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("failed", bResult == sal_True);
696*cdf0e10cSrcweir                 free(pStr);
697*cdf0e10cSrcweir             }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
700*cdf0e10cSrcweir         // member functions of the current class,
701*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(toAsciiLowerCase_WithLength);
704*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiLowerCase_WithLength_000);
705*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiLowerCase_WithLength_001);
706*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
707*cdf0e10cSrcweir     }; // class replaceChar
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir // -----------------------------------------------------------------------------
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir     class toAsciiUpperCase : public CppUnit::TestFixture
712*cdf0e10cSrcweir     {
713*cdf0e10cSrcweir     public:
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir         void toAsciiUpperCase_000()
716*cdf0e10cSrcweir             {
717*cdf0e10cSrcweir                 rtl_ustr_toAsciiUpperCase( NULL );
718*cdf0e10cSrcweir             }
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir         void toAsciiUpperCase_001()
721*cdf0e10cSrcweir             {
722*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("change this to ascii upper case.");
723*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII UPPER CASE.");
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
726*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
727*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
728*cdf0e10cSrcweir                 memset(pStr, 0, nLength + sizeof(sal_Unicode));
729*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir                 rtl_ustr_toAsciiUpperCase( pStr );
732*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
735*cdf0e10cSrcweir                 free(pStr);
736*cdf0e10cSrcweir             }
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
739*cdf0e10cSrcweir         // member functions of the current class,
740*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(toAsciiUpperCase);
743*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiUpperCase_000);
744*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiUpperCase_001);
745*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
746*cdf0e10cSrcweir     }; // class replaceChar
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir     class toAsciiUpperCase_WithLength : public CppUnit::TestFixture
750*cdf0e10cSrcweir     {
751*cdf0e10cSrcweir     public:
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir         void toAsciiUpperCase_WithLength_000()
754*cdf0e10cSrcweir             {
755*cdf0e10cSrcweir                 rtl_ustr_toAsciiUpperCase_WithLength( NULL, 0 );
756*cdf0e10cSrcweir             }
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir         void toAsciiUpperCase_WithLength_001()
759*cdf0e10cSrcweir             {
760*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("change this to ascii lower case.");
761*cdf0e10cSrcweir                 rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIs to ascii lower case.");
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir                 sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
764*cdf0e10cSrcweir                 sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);
765*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir                 memcpy(pStr, aStr1.getStr(), nLength);
768*cdf0e10cSrcweir                 rtl_ustr_toAsciiUpperCase_WithLength( pStr, 10 );
769*cdf0e10cSrcweir                 rtl::OUString suStr(pStr, aStr1.getLength());
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir                 // t_print("Uppercase with length: '%s'\n", aStr1.getStr());
772*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
773*cdf0e10cSrcweir                 free(pStr);
774*cdf0e10cSrcweir             }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
777*cdf0e10cSrcweir         // member functions of the current class,
778*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(toAsciiUpperCase_WithLength);
781*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiUpperCase_WithLength_000);
782*cdf0e10cSrcweir         CPPUNIT_TEST(toAsciiUpperCase_WithLength_001);
783*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
784*cdf0e10cSrcweir     }; // class replaceChar
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir     // -----------------------------------------------------------------------------
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir     class trim_WithLength : public CppUnit::TestFixture
790*cdf0e10cSrcweir     {
791*cdf0e10cSrcweir       public:
792*cdf0e10cSrcweir         void trim_WithLength_000()
793*cdf0e10cSrcweir         {
794*cdf0e10cSrcweir             rtl_ustr_trim_WithLength(NULL, 0);
795*cdf0e10cSrcweir             // should not GPF
796*cdf0e10cSrcweir         }
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir         void trim_WithLength_000_1()
799*cdf0e10cSrcweir         {
800*cdf0e10cSrcweir             rtl::OUString suStr = rtl::OUString::createFromAscii("  trim this");
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir             sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
803*cdf0e10cSrcweir             sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
804*cdf0e10cSrcweir             memcpy(pStr, suStr.getStr(), nLength);
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir             rtl_ustr_trim_WithLength( pStr, 0 );
807*cdf0e10cSrcweir             free(pStr);
808*cdf0e10cSrcweir         }
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir         void trim_WithLength_001()
811*cdf0e10cSrcweir         {
812*cdf0e10cSrcweir             rtl::OUString suStr = rtl::OUString::createFromAscii("  trim this");
813*cdf0e10cSrcweir             sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
814*cdf0e10cSrcweir             sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
815*cdf0e10cSrcweir             memcpy(pStr, suStr.getStr(), nLength);
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir             rtl_ustr_trim_WithLength( pStr, 2 );
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("string should be empty", rtl::OUString(pStr).getLength() == 0);
820*cdf0e10cSrcweir             free(pStr);
821*cdf0e10cSrcweir         }
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir         void trim_WithLength_002()
825*cdf0e10cSrcweir         {
826*cdf0e10cSrcweir             rtl::OUString suStr = rtl::OUString::createFromAscii("trim this");
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir             sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
829*cdf0e10cSrcweir             sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
830*cdf0e10cSrcweir             memcpy(pStr, suStr.getStr(), nLength);
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir             rtl_ustr_trim_WithLength( pStr, 5 );
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", rtl::OUString(pStr).getLength() == 4);
835*cdf0e10cSrcweir             free(pStr);
836*cdf0e10cSrcweir         }
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir         void trim_WithLength_003()
840*cdf0e10cSrcweir         {
841*cdf0e10cSrcweir             rtl::OUString suStr = rtl::OUString::createFromAscii("     trim   this");
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir             sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
844*cdf0e10cSrcweir             sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
845*cdf0e10cSrcweir             memcpy(pStr, suStr.getStr(), nLength);
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir             rtl_ustr_trim_WithLength( pStr, 11 );
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", rtl::OUString(pStr).getLength() == 4);
850*cdf0e10cSrcweir             free(pStr);
851*cdf0e10cSrcweir         }
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir         void trim_WithLength_004()
854*cdf0e10cSrcweir         {
855*cdf0e10cSrcweir             rtl::OUString suStr = rtl::OUString::createFromAscii("\r\n\t \n\r    trim  \n this");
856*cdf0e10cSrcweir 
857*cdf0e10cSrcweir             sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
858*cdf0e10cSrcweir             sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
859*cdf0e10cSrcweir             memcpy(pStr, suStr.getStr(), nLength);
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir             rtl_ustr_trim_WithLength( pStr, 17 );
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", rtl::OUString(pStr).getLength() == 4);
864*cdf0e10cSrcweir             free(pStr);
865*cdf0e10cSrcweir         }
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir         void trim_WithLength_005()
868*cdf0e10cSrcweir         {
869*cdf0e10cSrcweir             rtl::OUString suStr = rtl::OUString::createFromAscii("\r\n\t \n\r    trim \t this \n\r\t\t     ");
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir             sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
872*cdf0e10cSrcweir             sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
873*cdf0e10cSrcweir             memcpy(pStr, suStr.getStr(), nLength);
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir             rtl_ustr_trim_WithLength( pStr, suStr.getLength() );
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("string should contain 'trim \\t this'", rtl::OUString(pStr).getLength() == 11);
878*cdf0e10cSrcweir             free(pStr);
879*cdf0e10cSrcweir         }
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
882*cdf0e10cSrcweir         // member functions of the current class,
883*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(trim_WithLength);
886*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_000);
887*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_000_1);
888*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_001);
889*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_002);
890*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_003);
891*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_004);
892*cdf0e10cSrcweir         CPPUNIT_TEST(trim_WithLength_005);
893*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
894*cdf0e10cSrcweir     };
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir     // -----------------------------------------------------------------------------
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir     class valueOfChar : public CppUnit::TestFixture
899*cdf0e10cSrcweir     {
900*cdf0e10cSrcweir       public:
901*cdf0e10cSrcweir         void valueOfChar_000()
902*cdf0e10cSrcweir             {
903*cdf0e10cSrcweir                 rtl_ustr_valueOfChar(NULL, 0);
904*cdf0e10cSrcweir                 // should not GPF
905*cdf0e10cSrcweir             }
906*cdf0e10cSrcweir         void valueOfChar_001()
907*cdf0e10cSrcweir             {
908*cdf0e10cSrcweir                 sal_Unicode *pStr = (sal_Unicode*)malloc(RTL_USTR_MAX_VALUEOFCHAR);
909*cdf0e10cSrcweir                 if (pStr)
910*cdf0e10cSrcweir                 {
911*cdf0e10cSrcweir                     rtl_ustr_valueOfChar(pStr, 'A');
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir                     CPPUNIT_ASSERT_MESSAGE("string should contain 'A'", pStr[0] == L'A');
914*cdf0e10cSrcweir                     free(pStr);
915*cdf0e10cSrcweir                 }
916*cdf0e10cSrcweir             }
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
919*cdf0e10cSrcweir         // member functions of the current class,
920*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(valueOfChar);
923*cdf0e10cSrcweir         CPPUNIT_TEST(valueOfChar_000);
924*cdf0e10cSrcweir         CPPUNIT_TEST(valueOfChar_001);
925*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
926*cdf0e10cSrcweir     };
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir     class ascii_compare_WithLength : public CppUnit::TestFixture
932*cdf0e10cSrcweir     {
933*cdf0e10cSrcweir     public:
934*cdf0e10cSrcweir 		void zero_length()
935*cdf0e10cSrcweir         {
936*cdf0e10cSrcweir 			sal_Unicode pUnicode[] = {0xffff, 0xffff};
937*cdf0e10cSrcweir 			char const * pAscii = "reference";
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(pUnicode, 0, pAscii);
940*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("ref string is empty, compare failed, needs to be <0.", value < 0);
941*cdf0e10cSrcweir 		}
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir         void equal_ascii_shorter()
944*cdf0e10cSrcweir 		{
945*cdf0e10cSrcweir 			rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("referenceString"));
946*cdf0e10cSrcweir 			char const * pAscii = "reference";
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
949*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("ref string is bigger, compare failed, needs to be >0.", value > 0);
950*cdf0e10cSrcweir 		}
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir         void equal_ascii_shorter_asciiLength()
953*cdf0e10cSrcweir 		{
954*cdf0e10cSrcweir 			rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("referenceString"));
955*cdf0e10cSrcweir 			char const * pAscii = "reference";
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, rtl_str_getLength(pAscii), pAscii);
958*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("ref string is bigger despite ascii length, compare failed, needs to be == 0.", value == 0);
959*cdf0e10cSrcweir 		}
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir         void equal_ref_shorter()
962*cdf0e10cSrcweir 		{
963*cdf0e10cSrcweir 			rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("reference"));
964*cdf0e10cSrcweir 			char const * pAscii = "referenceString";
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
967*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("ascii string is bigger, but only compared to ref length, needs to be 0.", value < 0);
968*cdf0e10cSrcweir 		}
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir         void equal()
971*cdf0e10cSrcweir 		{
972*cdf0e10cSrcweir 			rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("reference"));
973*cdf0e10cSrcweir 			char const * pAscii = "reference";
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
976*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("strings are equal, compare failed, needs to be 0.", value == 0);
977*cdf0e10cSrcweir 		}
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir         void unequal_reference_bigger()
980*cdf0e10cSrcweir        {
981*cdf0e10cSrcweir 			rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("defghi"));
982*cdf0e10cSrcweir 			char const * pAscii = "abc";
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
985*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("strings are unequal and ref is bigger, needs to be >0.", value > 0);
986*cdf0e10cSrcweir 		}
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir         void unequal_ascii_bigger()
989*cdf0e10cSrcweir 		{
990*cdf0e10cSrcweir 			rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("abc"));
991*cdf0e10cSrcweir 			char const * pAscii = "defghi";
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir 			sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir 			CPPUNIT_ASSERT_MESSAGE("strings are unequal and ascii is bigger, needs to be <0.", value < 0);
996*cdf0e10cSrcweir 		}
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(ascii_compare_WithLength);
999*cdf0e10cSrcweir         CPPUNIT_TEST(zero_length);
1000*cdf0e10cSrcweir         CPPUNIT_TEST(equal_ascii_shorter);
1001*cdf0e10cSrcweir         CPPUNIT_TEST(equal_ascii_shorter_asciiLength);
1002*cdf0e10cSrcweir         CPPUNIT_TEST(equal_ref_shorter);
1003*cdf0e10cSrcweir         CPPUNIT_TEST(equal);
1004*cdf0e10cSrcweir         CPPUNIT_TEST(unequal_reference_bigger);
1005*cdf0e10cSrcweir         CPPUNIT_TEST(unequal_ascii_bigger);
1006*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
1007*cdf0e10cSrcweir 	};
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir     class ascii_shortenedCompareIgnoreAsciiCase_WithLength : public CppUnit::TestFixture
1013*cdf0e10cSrcweir     {
1014*cdf0e10cSrcweir     public:
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir         void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000()
1017*cdf0e10cSrcweir             {
1018*cdf0e10cSrcweir                 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( NULL, 0, NULL, 0);
1019*cdf0e10cSrcweir                 // should not GPF
1020*cdf0e10cSrcweir             }
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir         void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1()
1023*cdf0e10cSrcweir             {
1024*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1025*cdf0e10cSrcweir                 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), NULL, 0);
1026*cdf0e10cSrcweir                 // should not GPF
1027*cdf0e10cSrcweir             }
1028*cdf0e10cSrcweir         void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2()
1029*cdf0e10cSrcweir             {
1030*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1031*cdf0e10cSrcweir                 rtl::OString sStr2 =                                 "Line is shorter.";
1032*cdf0e10cSrcweir                 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), sStr2.getLength(), sStr2.getStr(), 0);
1033*cdf0e10cSrcweir                 // should not GPF
1034*cdf0e10cSrcweir             }
1035*cdf0e10cSrcweir         void ascii_shortenedCompareIgnoreAsciiCase_WithLength_001()
1036*cdf0e10cSrcweir             {
1037*cdf0e10cSrcweir                 rtl::OUString suStr1;
1038*cdf0e10cSrcweir                 rtl::OString sStr2;
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1, 0, sStr2.getStr(), 0);
1041*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1042*cdf0e10cSrcweir             }
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir         void ascii_shortenedCompareIgnoreAsciiCase_WithLength_002()
1045*cdf0e10cSrcweir             {
1046*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1047*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be equal.";
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr(), sStr2.getLength());
1050*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1051*cdf0e10cSrcweir             }
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir         void ascii_shortenedCompareIgnoreAsciiCase_WithLength_003()
1054*cdf0e10cSrcweir             {
1055*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
1056*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be differ and longer.";
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr(), sStr2.getLength());
1059*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
1060*cdf0e10cSrcweir             }
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
1063*cdf0e10cSrcweir         // member functions of the current class,
1064*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(ascii_shortenedCompareIgnoreAsciiCase_WithLength);
1067*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000);
1068*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1);
1069*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2);
1070*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_001);
1071*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_002);
1072*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_003);
1073*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
1074*cdf0e10cSrcweir     }; // class ascii_shortenedCompareIgnoreAsciiCase_WithLength
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir     class ascii_compareIgnoreAsciiCase_WithLength : public CppUnit::TestFixture
1079*cdf0e10cSrcweir     {
1080*cdf0e10cSrcweir     public:
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_WithLength_000()
1083*cdf0e10cSrcweir             {
1084*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( NULL, 0, NULL);
1085*cdf0e10cSrcweir                 // should not GPF
1086*cdf0e10cSrcweir             }
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_WithLength_000_1()
1089*cdf0e10cSrcweir             {
1090*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1091*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1.getStr(), 0, NULL);
1092*cdf0e10cSrcweir                 // should not GPF
1093*cdf0e10cSrcweir             }
1094*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_WithLength_000_2()
1095*cdf0e10cSrcweir             {
1096*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1097*cdf0e10cSrcweir                 rtl::OString sStr2 =                                 "Line is shorter.";
1098*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1.getStr(), sStr2.getLength(), sStr2.getStr());
1099*cdf0e10cSrcweir                 // should not GPF
1100*cdf0e10cSrcweir             }
1101*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_WithLength_001()
1102*cdf0e10cSrcweir             {
1103*cdf0e10cSrcweir                 rtl::OUString suStr1;
1104*cdf0e10cSrcweir                 rtl::OString sStr2;
1105*cdf0e10cSrcweir 
1106*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1, 0, sStr2.getStr());
1107*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compareIgnoreAsciiCase_WithLength failed, strings are equal.", nValue == 0);
1108*cdf0e10cSrcweir             }
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_WithLength_002()
1111*cdf0e10cSrcweir             {
1112*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1113*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be equal.";
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr());
1116*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1117*cdf0e10cSrcweir             }
1118*cdf0e10cSrcweir 
1119*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_WithLength_003()
1120*cdf0e10cSrcweir             {
1121*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
1122*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be differ and longer.";
1123*cdf0e10cSrcweir 
1124*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr());
1125*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
1126*cdf0e10cSrcweir             }
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
1129*cdf0e10cSrcweir         // member functions of the current class,
1130*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(ascii_compareIgnoreAsciiCase_WithLength);
1133*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000);
1134*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000_1);
1135*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000_2);
1136*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_001);
1137*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_002);
1138*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_003);
1139*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
1140*cdf0e10cSrcweir     }; // class ascii_compareIgnoreAsciiCase_WithLength
1141*cdf0e10cSrcweir 
1142*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir     class ascii_compare : public CppUnit::TestFixture
1145*cdf0e10cSrcweir     {
1146*cdf0e10cSrcweir     public:
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir         void ascii_compare_000()
1149*cdf0e10cSrcweir             {
1150*cdf0e10cSrcweir                 rtl_ustr_ascii_compare( NULL, NULL);
1151*cdf0e10cSrcweir                 // should not GPF
1152*cdf0e10cSrcweir             }
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir         void ascii_compare_000_1()
1155*cdf0e10cSrcweir             {
1156*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1157*cdf0e10cSrcweir                 rtl_ustr_ascii_compare( aStr1.getStr(), NULL);
1158*cdf0e10cSrcweir                 // should not GPF
1159*cdf0e10cSrcweir             }
1160*cdf0e10cSrcweir         void ascii_compare_001()
1161*cdf0e10cSrcweir             {
1162*cdf0e10cSrcweir                 rtl::OUString suStr1;
1163*cdf0e10cSrcweir                 rtl::OString sStr2;
1164*cdf0e10cSrcweir 
1165*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1, sStr2.getStr());
1166*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1167*cdf0e10cSrcweir             }
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir         void ascii_compare_002()
1170*cdf0e10cSrcweir             {
1171*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1172*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be equal.";
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1.getStr(), sStr2.getStr());
1175*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1176*cdf0e10cSrcweir             }
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir         void ascii_compare_003()
1179*cdf0e10cSrcweir             {
1180*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
1181*cdf0e10cSrcweir                 rtl::OString sStr2 = "Line foo bar, ok, differ.";
1182*cdf0e10cSrcweir 
1183*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1.getStr(), sStr2.getStr());
1184*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
1185*cdf0e10cSrcweir             }
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
1188*cdf0e10cSrcweir         // member functions of the current class,
1189*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(ascii_compare);
1192*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compare_000);
1193*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compare_000_1);
1194*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compare_001);
1195*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compare_002);
1196*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compare_003);
1197*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
1198*cdf0e10cSrcweir     }; // class ascii_compare
1199*cdf0e10cSrcweir 
1200*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1201*cdf0e10cSrcweir 
1202*cdf0e10cSrcweir     class ascii_compareIgnoreAsciiCase : public CppUnit::TestFixture
1203*cdf0e10cSrcweir     {
1204*cdf0e10cSrcweir     public:
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_000()
1207*cdf0e10cSrcweir             {
1208*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase( NULL, NULL);
1209*cdf0e10cSrcweir                 // should not GPF
1210*cdf0e10cSrcweir             }
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_000_1()
1213*cdf0e10cSrcweir             {
1214*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1215*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
1216*cdf0e10cSrcweir                 // should not GPF
1217*cdf0e10cSrcweir             }
1218*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_001()
1219*cdf0e10cSrcweir             {
1220*cdf0e10cSrcweir                 rtl::OUString suStr1;
1221*cdf0e10cSrcweir                 rtl::OString sStr2;
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1, sStr2.getStr());
1224*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1225*cdf0e10cSrcweir             }
1226*cdf0e10cSrcweir 
1227*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_002()
1228*cdf0e10cSrcweir             {
1229*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1230*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be equal.";
1231*cdf0e10cSrcweir 
1232*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
1233*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1234*cdf0e10cSrcweir             }
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_002_1()
1237*cdf0e10cSrcweir             {
1238*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal, when ignore case.");
1239*cdf0e10cSrcweir                 rtl::OString sStr2 =                                 "LINE MUST BE EQUAL, WHEN IGNORE CASE.";
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
1242*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
1243*cdf0e10cSrcweir             }
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_003()
1246*cdf0e10cSrcweir             {
1247*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
1248*cdf0e10cSrcweir                 rtl::OString sStr2 = "Line foo bar, ok, differ.";
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
1251*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
1252*cdf0e10cSrcweir             }
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir         //! LLA: some more tests with some high level strings
1255*cdf0e10cSrcweir 
1256*cdf0e10cSrcweir         // void ascii_compareIgnoreAsciiCase_001()
1257*cdf0e10cSrcweir         //     {
1258*cdf0e10cSrcweir         //         rtl::OUString suStr1 = rtl::OUString::createFromAscii("change this to ascii upper case.");
1259*cdf0e10cSrcweir         //         rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII UPPER CASE.");
1260*cdf0e10cSrcweir         //
1261*cdf0e10cSrcweir         //         sal_uInt32 nLength = suStr1.getLength() * sizeof(sal_Unicode);
1262*cdf0e10cSrcweir         //         sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
1263*cdf0e10cSrcweir         //         CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
1264*cdf0e10cSrcweir         //         memset(pStr, 0, nLength + sizeof(sal_Unicode));
1265*cdf0e10cSrcweir         //         memcpy(pStr, suStr1.getStr(), nLength);
1266*cdf0e10cSrcweir         //
1267*cdf0e10cSrcweir         //         rtl_ustr_ascii_compareIgnoreAsciiCase( pStr );
1268*cdf0e10cSrcweir         //         rtl::OUString suStr(pStr, suStr1.getLength());
1269*cdf0e10cSrcweir         //
1270*cdf0e10cSrcweir         //         CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
1271*cdf0e10cSrcweir         //         free(pStr);
1272*cdf0e10cSrcweir         //     }
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
1275*cdf0e10cSrcweir         // member functions of the current class,
1276*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(ascii_compareIgnoreAsciiCase);
1279*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000);
1280*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000_1);
1281*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_001);
1282*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002);
1283*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002_1);
1284*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_003);
1285*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
1286*cdf0e10cSrcweir     }; // class ascii_compareIgnoreAsciiCase
1287*cdf0e10cSrcweir 
1288*cdf0e10cSrcweir 
1289*cdf0e10cSrcweir     // sample out of inc/rtl/ustring.hxx
1290*cdf0e10cSrcweir     // rtl_uString * pToken = NULL;
1291*cdf0e10cSrcweir     // sal_Int32 nIndex = 0;
1292*cdf0e10cSrcweir     // do
1293*cdf0e10cSrcweir     // {
1294*cdf0e10cSrcweir     //       ...
1295*cdf0e10cSrcweir     //       nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
1296*cdf0e10cSrcweir     //       ...
1297*cdf0e10cSrcweir     // }
1298*cdf0e10cSrcweir     // while (nIndex >= 0);
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir     class getToken : public CppUnit::TestFixture
1301*cdf0e10cSrcweir     {
1302*cdf0e10cSrcweir     public:
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir         void getToken_000()
1305*cdf0e10cSrcweir             {
1306*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase( NULL, NULL);
1307*cdf0e10cSrcweir                 // should not GPF
1308*cdf0e10cSrcweir             }
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_000_1()
1311*cdf0e10cSrcweir             {
1312*cdf0e10cSrcweir                 rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1313*cdf0e10cSrcweir                 rtl_ustr_ascii_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
1314*cdf0e10cSrcweir                 // should not GPF
1315*cdf0e10cSrcweir             }
1316*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_001()
1317*cdf0e10cSrcweir             {
1318*cdf0e10cSrcweir                 rtl::OUString suStr1;
1319*cdf0e10cSrcweir                 rtl::OString sStr2;
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1, sStr2.getStr());
1322*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1323*cdf0e10cSrcweir             }
1324*cdf0e10cSrcweir 
1325*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_002()
1326*cdf0e10cSrcweir             {
1327*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
1328*cdf0e10cSrcweir                 rtl::OString sStr2 =                                  "Line must be equal.";
1329*cdf0e10cSrcweir 
1330*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
1331*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
1332*cdf0e10cSrcweir             }
1333*cdf0e10cSrcweir 
1334*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_002_1()
1335*cdf0e10cSrcweir             {
1336*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal, when ignore case.");
1337*cdf0e10cSrcweir                 rtl::OString sStr2 =                                 "LINE MUST BE EQUAL, WHEN IGNORE CASE.";
1338*cdf0e10cSrcweir 
1339*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
1340*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
1341*cdf0e10cSrcweir             }
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir         void ascii_compareIgnoreAsciiCase_003()
1344*cdf0e10cSrcweir             {
1345*cdf0e10cSrcweir                 rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
1346*cdf0e10cSrcweir                 rtl::OString sStr2 = "Line foo bar, ok, differ.";
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir                 sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
1349*cdf0e10cSrcweir                 CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
1350*cdf0e10cSrcweir             }
1351*cdf0e10cSrcweir 
1352*cdf0e10cSrcweir         //! LLA: some more tests with some high level strings
1353*cdf0e10cSrcweir 
1354*cdf0e10cSrcweir         // void ascii_compareIgnoreAsciiCase_001()
1355*cdf0e10cSrcweir         //     {
1356*cdf0e10cSrcweir         //         rtl::OUString suStr1 = rtl::OUString::createFromAscii("change this to ascii upper case.");
1357*cdf0e10cSrcweir         //         rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII UPPER CASE.");
1358*cdf0e10cSrcweir         //
1359*cdf0e10cSrcweir         //         sal_uInt32 nLength = suStr1.getLength() * sizeof(sal_Unicode);
1360*cdf0e10cSrcweir         //         sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
1361*cdf0e10cSrcweir         //         CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
1362*cdf0e10cSrcweir         //         memset(pStr, 0, nLength + sizeof(sal_Unicode));
1363*cdf0e10cSrcweir         //         memcpy(pStr, suStr1.getStr(), nLength);
1364*cdf0e10cSrcweir         //
1365*cdf0e10cSrcweir         //         rtl_ustr_ascii_compareIgnoreAsciiCase( pStr );
1366*cdf0e10cSrcweir         //         rtl::OUString suStr(pStr, suStr1.getLength());
1367*cdf0e10cSrcweir         //
1368*cdf0e10cSrcweir         //         CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
1369*cdf0e10cSrcweir         //         free(pStr);
1370*cdf0e10cSrcweir         //     }
1371*cdf0e10cSrcweir 
1372*cdf0e10cSrcweir         // Change the following lines only, if you add, remove or rename
1373*cdf0e10cSrcweir         // member functions of the current class,
1374*cdf0e10cSrcweir         // because these macros are need by auto register mechanism.
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE(ascii_compareIgnoreAsciiCase);
1377*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000);
1378*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000_1);
1379*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_001);
1380*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002);
1381*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002_1);
1382*cdf0e10cSrcweir         CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_003);
1383*cdf0e10cSrcweir         CPPUNIT_TEST_SUITE_END();
1384*cdf0e10cSrcweir     }; // class ascii_compareIgnoreAsciiCase
1385*cdf0e10cSrcweir 
1386*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1387*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::compare, "rtl_ustr");
1388*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::compareIgnoreAsciiCase, "rtl_ustr");
1389*cdf0e10cSrcweir 
1390*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compare_WithLength, "rtl_ustr");
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::shortenedCompareIgnoreAsciiCase_WithLength, "rtl_ustr");
1393*cdf0e10cSrcweir // CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::hashCode, "rtl_ustr");
1394*cdf0e10cSrcweir 
1395*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::indexOfChar, "rtl_ustr");
1396*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::lastIndexOfChar, "rtl_ustr");
1397*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::indexOfStr, "rtl_ustr");
1398*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::lastIndexOfStr, "rtl_ustr");
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::replaceChar, "rtl_ustr");
1401*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::replaceChar_WithLength, "rtl_ustr");
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiLowerCase, "rtl_ustr");
1404*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiLowerCase_WithLength, "rtl_ustr");
1405*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiUpperCase, "rtl_ustr");
1406*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiUpperCase_WithLength, "rtl_ustr");
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::trim_WithLength, "rtl_ustr");
1409*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::valueOfChar, "rtl_ustr");
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compare, "rtl_ustr");
1412*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compareIgnoreAsciiCase, "rtl_ustr");
1413*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compareIgnoreAsciiCase_WithLength, "rtl_ustr");
1414*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_shortenedCompareIgnoreAsciiCase_WithLength, "rtl_ustr");
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir } // namespace rtl_ustr
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir // -----------------------------------------------------------------------------
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir // this macro creates an empty function, which will called by the RegisterAllFunctions()
1421*cdf0e10cSrcweir // to let the user the possibility to also register some functions by hand.
1422*cdf0e10cSrcweir NOADDITIONAL;
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir 
1425