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