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