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
10cdf0e10cSrcweir *
1187d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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*b3f397bdSDamjan Jovanovic #include "gtest/gtest.h"
28*b3f397bdSDamjan Jovanovic #include <rtl/string.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir namespace rtl_str
31cdf0e10cSrcweir {
32cdf0e10cSrcweir
33*b3f397bdSDamjan Jovanovic class compare : public ::testing::Test
34cdf0e10cSrcweir {
35cdf0e10cSrcweir public:
36*b3f397bdSDamjan Jovanovic }; // class compare
37cdf0e10cSrcweir
TEST_F(compare,compare_000)38*b3f397bdSDamjan Jovanovic TEST_F(compare, compare_000)
39cdf0e10cSrcweir {
40cdf0e10cSrcweir rtl_str_compare( NULL, NULL);
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
TEST_F(compare,compare_000_1)43*b3f397bdSDamjan Jovanovic TEST_F(compare, compare_000_1)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
46cdf0e10cSrcweir rtl_str_compare( aStr1.getStr(), NULL);
47cdf0e10cSrcweir }
TEST_F(compare,compare_001)48*b3f397bdSDamjan Jovanovic TEST_F(compare, compare_001)
49cdf0e10cSrcweir {
50cdf0e10cSrcweir rtl::OString aStr1 = "";
51cdf0e10cSrcweir rtl::OString aStr2 = "";
52cdf0e10cSrcweir
53cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compare( aStr1.getStr(), aStr2.getStr());
54*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal.";
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
TEST_F(compare,compare_002)57*b3f397bdSDamjan Jovanovic TEST_F(compare, compare_002)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
60cdf0e10cSrcweir rtl::OString aStr2 = "Line must be equal.";
61cdf0e10cSrcweir
62cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compare( aStr1.getStr(), aStr2.getStr());
63*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal.";
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
TEST_F(compare,compare_003)66*b3f397bdSDamjan Jovanovic TEST_F(compare, compare_003)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir rtl::OString aStr1 = "Line must differ.";
69cdf0e10cSrcweir rtl::OString aStr2 = "Line foo bar, ok, differ.";
70cdf0e10cSrcweir
71cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compare( aStr1.getStr(), aStr2.getStr());
72*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue != 0) << "compare failed, strings differ.";
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75*b3f397bdSDamjan Jovanovic class compareIgnoreAsciiCase : public ::testing::Test
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78*b3f397bdSDamjan Jovanovic }; // class compareIgnoreAsciiCase
79cdf0e10cSrcweir
TEST_F(compareIgnoreAsciiCase,compare_000)80*b3f397bdSDamjan Jovanovic TEST_F(compareIgnoreAsciiCase, compare_000)
81cdf0e10cSrcweir {
82cdf0e10cSrcweir rtl_str_compareIgnoreAsciiCase( NULL, NULL);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
TEST_F(compareIgnoreAsciiCase,compare_000_1)85*b3f397bdSDamjan Jovanovic TEST_F(compareIgnoreAsciiCase, compare_000_1)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
88cdf0e10cSrcweir rtl_str_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
89cdf0e10cSrcweir }
TEST_F(compareIgnoreAsciiCase,compare_001)90*b3f397bdSDamjan Jovanovic TEST_F(compareIgnoreAsciiCase, compare_001)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir rtl::OString aStr1 = "";
93cdf0e10cSrcweir rtl::OString aStr2 = "";
94cdf0e10cSrcweir
95cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
96*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal.";
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
TEST_F(compareIgnoreAsciiCase,compare_002)99*b3f397bdSDamjan Jovanovic TEST_F(compareIgnoreAsciiCase, compare_002)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
102cdf0e10cSrcweir rtl::OString aStr2 = "Line must be equal.";
103cdf0e10cSrcweir
104cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
105*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal.";
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
TEST_F(compareIgnoreAsciiCase,compare_002_1)108*b3f397bdSDamjan Jovanovic TEST_F(compareIgnoreAsciiCase, compare_002_1)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
111cdf0e10cSrcweir rtl::OString aStr2 = "LINE MUST BE EQUAL.";
112cdf0e10cSrcweir
113cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
114*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal (if case insensitve).";
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
TEST_F(compareIgnoreAsciiCase,compare_003)117*b3f397bdSDamjan Jovanovic TEST_F(compareIgnoreAsciiCase, compare_003)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir rtl::OString aStr1 = "Line must differ.";
120cdf0e10cSrcweir rtl::OString aStr2 = "Line foo bar, ok, differ.";
121cdf0e10cSrcweir
122cdf0e10cSrcweir sal_Int32 nValue = rtl_str_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
123*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue != 0) << "compare failed, strings differ.";
124cdf0e10cSrcweir }
125cdf0e10cSrcweir // -----------------------------------------------------------------------------
126cdf0e10cSrcweir
127*b3f397bdSDamjan Jovanovic class shortenedCompareIgnoreAsciiCase_WithLength : public ::testing::Test
128cdf0e10cSrcweir {
129cdf0e10cSrcweir public:
130*b3f397bdSDamjan Jovanovic }; // class compare
131cdf0e10cSrcweir
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_000)132*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_000)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( NULL, 0, NULL, 0, 0);
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_000_1)137*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_000_1)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
140cdf0e10cSrcweir rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), NULL, 0, 1);
141cdf0e10cSrcweir }
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_001)142*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_001)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir rtl::OString aStr1 = "";
145cdf0e10cSrcweir rtl::OString aStr2 = "";
146cdf0e10cSrcweir
147cdf0e10cSrcweir sal_Int32 nValue = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), aStr1.getLength());
148*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal.";
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_002)151*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_002)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
154cdf0e10cSrcweir rtl::OString aStr2 = "Line must be equal.";
155cdf0e10cSrcweir
156cdf0e10cSrcweir sal_Int32 nValue = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
157cdf0e10cSrcweir aStr2.getStr(), aStr2.getLength(),
158cdf0e10cSrcweir aStr1.getLength());
159*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal.";
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_002_1)162*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_002_1)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir rtl::OString aStr1 = "Line must be equal.";
165cdf0e10cSrcweir rtl::OString aStr2 = "LINE MUST BE EQUAL.";
166cdf0e10cSrcweir
167cdf0e10cSrcweir sal_Int32 nValue = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
168cdf0e10cSrcweir aStr2.getStr(), aStr2.getLength(),
169cdf0e10cSrcweir aStr1.getLength());
170*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal (if case insensitve).";
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_003)173*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_003)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir rtl::OString aStr1 = "Line must differ.";
176cdf0e10cSrcweir rtl::OString aStr2 = "Line foo bar, ok, differ.";
177cdf0e10cSrcweir
178cdf0e10cSrcweir sal_Int32 nValue = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
179cdf0e10cSrcweir aStr2.getStr(), aStr2.getLength(),
180cdf0e10cSrcweir 5);
181*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue == 0) << "compare failed, strings are equal first 5 characters.";
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
TEST_F(shortenedCompareIgnoreAsciiCase_WithLength,compare_004)184*b3f397bdSDamjan Jovanovic TEST_F(shortenedCompareIgnoreAsciiCase_WithLength, compare_004)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir rtl::OString aStr1 = "Line must differ.";
187cdf0e10cSrcweir rtl::OString aStr2 = "Line foo bar, ok, differ.";
188cdf0e10cSrcweir
189cdf0e10cSrcweir sal_Int32 nValue = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
190cdf0e10cSrcweir aStr2.getStr(), aStr2.getLength(),
191cdf0e10cSrcweir aStr1.getLength());
192*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nValue != 0) << "compare failed, strings differ.";
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir // -----------------------------------------------------------------------------
196cdf0e10cSrcweir
197*b3f397bdSDamjan Jovanovic class hashCode : public ::testing::Test
198cdf0e10cSrcweir {
199cdf0e10cSrcweir public:
200*b3f397bdSDamjan Jovanovic }; // class compare
201cdf0e10cSrcweir
TEST_F(hashCode,hashCode_000)202*b3f397bdSDamjan Jovanovic TEST_F(hashCode, hashCode_000)
203cdf0e10cSrcweir {
204cdf0e10cSrcweir rtl_str_hashCode( NULL );
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
TEST_F(hashCode,hashCode_001)207*b3f397bdSDamjan Jovanovic TEST_F(hashCode, hashCode_001)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir rtl::OString aStr1 = "Line for a hashCode.";
210cdf0e10cSrcweir sal_Int32 nHashCode = rtl_str_hashCode( aStr1.getStr() );
211*b3f397bdSDamjan Jovanovic printf("hashcode: %d\n", nHashCode);
212*b3f397bdSDamjan Jovanovic // ASSERT_TRUE(nValue == 0) << "failed.";
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
TEST_F(hashCode,hashCode_002)215*b3f397bdSDamjan Jovanovic TEST_F(hashCode, hashCode_002)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir rtl::OString aStr1 = "Line for a hashCode.";
218cdf0e10cSrcweir sal_Int32 nHashCode1 = rtl_str_hashCode( aStr1.getStr() );
219cdf0e10cSrcweir
220cdf0e10cSrcweir rtl::OString aStr2 = "Line for a hashCode.";
221cdf0e10cSrcweir sal_Int32 nHashCode2 = rtl_str_hashCode( aStr2.getStr() );
222cdf0e10cSrcweir
223*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nHashCode1 == nHashCode2) << "hashcodes must be equal.";
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
TEST_F(hashCode,hashCode_003)226*b3f397bdSDamjan Jovanovic TEST_F(hashCode, hashCode_003)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir rtl::OString aStr1 = "Line for a hashCode.";
229cdf0e10cSrcweir sal_Int32 nHashCode1 = rtl_str_hashCode( aStr1.getStr() );
230cdf0e10cSrcweir
231cdf0e10cSrcweir rtl::OString aStr2 = "Line for an other hashcode.";
232cdf0e10cSrcweir sal_Int32 nHashCode2 = rtl_str_hashCode( aStr2.getStr() );
233cdf0e10cSrcweir
234*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nHashCode1 != nHashCode2) << "hashcodes must differ.";
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir // -----------------------------------------------------------------------------
238cdf0e10cSrcweir
239*b3f397bdSDamjan Jovanovic class indexOfChar : public ::testing::Test
240cdf0e10cSrcweir {
241cdf0e10cSrcweir public:
242*b3f397bdSDamjan Jovanovic }; // class compare
243cdf0e10cSrcweir
TEST_F(indexOfChar,indexOfChar_000)244*b3f397bdSDamjan Jovanovic TEST_F(indexOfChar, indexOfChar_000)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir rtl_str_indexOfChar( NULL, 0 );
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
TEST_F(indexOfChar,indexOfChar_001)249*b3f397bdSDamjan Jovanovic TEST_F(indexOfChar, indexOfChar_001)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir rtl::OString aStr1 = "Line for a indexOfChar.";
252cdf0e10cSrcweir
253cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_indexOfChar( aStr1.getStr(), 'L' );
254*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 0) << "index is wrong.";
255cdf0e10cSrcweir
256cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_indexOfChar( aStr1.getStr(), 'i' );
257*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 1) << "index is wrong.";
258cdf0e10cSrcweir
259cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_indexOfChar( aStr1.getStr(), 'n' );
260*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 2) << "index is wrong.";
261cdf0e10cSrcweir
262cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_indexOfChar( aStr1.getStr(), 'e' );
263*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 3) << "index is wrong.";
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
TEST_F(indexOfChar,indexOfChar_002)266*b3f397bdSDamjan Jovanovic TEST_F(indexOfChar, indexOfChar_002)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir rtl::OString aStr1 = "Line for a indexOfChar.";
269cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_indexOfChar( aStr1.getStr(), 'y' );
270cdf0e10cSrcweir
271*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == -1) << "index is wrong.";
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir // -----------------------------------------------------------------------------
275*b3f397bdSDamjan Jovanovic class lastIndexOfChar : public ::testing::Test
276cdf0e10cSrcweir {
277cdf0e10cSrcweir public:
278*b3f397bdSDamjan Jovanovic }; // class lastIndexOfChar
279cdf0e10cSrcweir
TEST_F(lastIndexOfChar,lastIndexOfChar_000)280*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfChar, lastIndexOfChar_000)
281cdf0e10cSrcweir {
282cdf0e10cSrcweir rtl_str_lastIndexOfChar( NULL, 0 );
283cdf0e10cSrcweir }
284cdf0e10cSrcweir
TEST_F(lastIndexOfChar,lastIndexOfChar_001)285*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfChar, lastIndexOfChar_001)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir rtl::OString aStr1 = "Line for a lastIndexOfChar.";
288cdf0e10cSrcweir
289cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_lastIndexOfChar( aStr1.getStr(), 'C' );
290*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 22) << "index is wrong.";
291cdf0e10cSrcweir
292cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_lastIndexOfChar( aStr1.getStr(), 'h' );
293*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 23) << "index is wrong.";
294cdf0e10cSrcweir
295cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_lastIndexOfChar( aStr1.getStr(), 'a' );
296*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 24) << "index is wrong.";
297cdf0e10cSrcweir
298cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_lastIndexOfChar( aStr1.getStr(), 'r' );
299*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 25) << "index is wrong.";
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
TEST_F(lastIndexOfChar,lastIndexOfChar_002)302*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfChar, lastIndexOfChar_002)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir rtl::OString aStr1 = "Line for a lastIndexOfChar.";
305cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_lastIndexOfChar( aStr1.getStr(), 'y' );
306cdf0e10cSrcweir
307*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == -1) << "index is wrong.";
308cdf0e10cSrcweir }
309cdf0e10cSrcweir
310cdf0e10cSrcweir // -----------------------------------------------------------------------------
311cdf0e10cSrcweir
312*b3f397bdSDamjan Jovanovic class indexOfStr : public ::testing::Test
313cdf0e10cSrcweir {
314cdf0e10cSrcweir public:
315*b3f397bdSDamjan Jovanovic }; // class compare
316cdf0e10cSrcweir
TEST_F(indexOfStr,indexOfStr_000)317*b3f397bdSDamjan Jovanovic TEST_F(indexOfStr, indexOfStr_000)
318cdf0e10cSrcweir {
319cdf0e10cSrcweir rtl_str_indexOfStr( NULL, 0 );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
TEST_F(indexOfStr,indexOfStr_000_1)322*b3f397bdSDamjan Jovanovic TEST_F(indexOfStr, indexOfStr_000_1)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir rtl::OString aStr1 = "Line for a indexOfStr.";
325cdf0e10cSrcweir rtl_str_indexOfStr( aStr1.getStr(), 0 );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
TEST_F(indexOfStr,indexOfStr_001)328*b3f397bdSDamjan Jovanovic TEST_F(indexOfStr, indexOfStr_001)
329cdf0e10cSrcweir {
330cdf0e10cSrcweir rtl::OString aStr1 = "Line for a indexOfStr.";
331cdf0e10cSrcweir
332cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_indexOfStr( aStr1.getStr(), "Line" );
333*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 0) << "index is wrong.";
334cdf0e10cSrcweir
335cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_indexOfStr( aStr1.getStr(), "for" );
336*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 5) << "index is wrong.";
337cdf0e10cSrcweir
338cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_indexOfStr( aStr1.getStr(), "a" );
339*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 9) << "index is wrong.";
340cdf0e10cSrcweir
341cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_indexOfStr( aStr1.getStr(), "a index" );
342*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex ==9) << "index is wrong.";
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
TEST_F(indexOfStr,indexOfStr_002)345*b3f397bdSDamjan Jovanovic TEST_F(indexOfStr, indexOfStr_002)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir rtl::OString aStr1 = "Line for a indexOfStr.";
348cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_indexOfStr( aStr1.getStr(), "not exist" );
349cdf0e10cSrcweir
350*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == -1) << "index is wrong.";
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
353cdf0e10cSrcweir // -----------------------------------------------------------------------------
354cdf0e10cSrcweir
355cdf0e10cSrcweir
356*b3f397bdSDamjan Jovanovic class lastIndexOfStr : public ::testing::Test
357cdf0e10cSrcweir {
358cdf0e10cSrcweir public:
359*b3f397bdSDamjan Jovanovic }; // class lastIndexOfStr
360cdf0e10cSrcweir
TEST_F(lastIndexOfStr,lastIndexOfStr_000)361*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfStr, lastIndexOfStr_000)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir rtl_str_lastIndexOfStr( NULL, NULL );
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
TEST_F(lastIndexOfStr,lastIndexOfStr_000_1)366*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfStr, lastIndexOfStr_000_1)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir rtl::OString aStr1 = "Line for a lastIndexOfStr.";
369cdf0e10cSrcweir rtl_str_lastIndexOfStr( aStr1.getStr(), NULL );
370cdf0e10cSrcweir }
371cdf0e10cSrcweir
TEST_F(lastIndexOfStr,lastIndexOfStr_001)372*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfStr, lastIndexOfStr_001)
373cdf0e10cSrcweir {
374cdf0e10cSrcweir rtl::OString aStr1 = "Line for a lastIndexOfStr.";
375cdf0e10cSrcweir rtl::OString aSearchStr = "Index";
376cdf0e10cSrcweir
377cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
378*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 15) << "index is wrong.";
379cdf0e10cSrcweir
380cdf0e10cSrcweir /* rtl::OString */ aSearchStr = "Line";
381cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
382*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 0) << "index is wrong.";
383cdf0e10cSrcweir
384cdf0e10cSrcweir /* rtl::OString */ aSearchStr = "";
385cdf0e10cSrcweir /* sal_Int32 */ nIndex = rtl_str_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
386*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == -1) << "index is wrong.";
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
TEST_F(lastIndexOfStr,lastIndexOfStr_002)389*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfStr, lastIndexOfStr_002)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir rtl::OString aStr1 = "Line for a lastIndexOfStr.";
392cdf0e10cSrcweir rtl::OString aSearchStr = "foo";
393cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
394cdf0e10cSrcweir
395*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == -1) << "index is wrong.";
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
TEST_F(lastIndexOfStr,lastIndexOfStr_003)398*b3f397bdSDamjan Jovanovic TEST_F(lastIndexOfStr, lastIndexOfStr_003)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir rtl::OString aStr1 = "Line for a lastIndexOfStr.";
401cdf0e10cSrcweir rtl::OString aSearchStr = "O";
402cdf0e10cSrcweir sal_Int32 nIndex = rtl_str_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
403cdf0e10cSrcweir
404*b3f397bdSDamjan Jovanovic ASSERT_TRUE(nIndex == 20) << "index is wrong.";
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir // -----------------------------------------------------------------------------
408cdf0e10cSrcweir
409*b3f397bdSDamjan Jovanovic class replaceChar : public ::testing::Test
410cdf0e10cSrcweir {
411cdf0e10cSrcweir public:
412*b3f397bdSDamjan Jovanovic }; // class replaceChar
413cdf0e10cSrcweir
TEST_F(replaceChar,replaceChar_000)414*b3f397bdSDamjan Jovanovic TEST_F(replaceChar, replaceChar_000)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir rtl_str_replaceChar( NULL, 0, 0 );
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
TEST_F(replaceChar,replaceChar_001)419*b3f397bdSDamjan Jovanovic TEST_F(replaceChar, replaceChar_001)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir rtl::OString aStr1 = "replace char.";
422cdf0e10cSrcweir rtl::OString aShouldStr1 = "ruplacu char.";
423cdf0e10cSrcweir
424cdf0e10cSrcweir sal_Char* pStr = (sal_Char*) malloc(aStr1.getLength() + 1);
425*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr != NULL) << "can't get memory for test";
426cdf0e10cSrcweir strcpy(pStr, aStr1.getStr());
427cdf0e10cSrcweir
428cdf0e10cSrcweir rtl_str_replaceChar( pStr, 'e', 'u' );
429cdf0e10cSrcweir
430*b3f397bdSDamjan Jovanovic ASSERT_TRUE(aShouldStr1.equals(rtl::OString(pStr)) == sal_True) << "replace failed";
431cdf0e10cSrcweir free(pStr);
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir // -----------------------------------------------------------------------------
435cdf0e10cSrcweir
436*b3f397bdSDamjan Jovanovic class replaceChar_WithLength : public ::testing::Test
437cdf0e10cSrcweir {
438cdf0e10cSrcweir public:
439*b3f397bdSDamjan Jovanovic }; // class replaceChar
440cdf0e10cSrcweir
TEST_F(replaceChar_WithLength,replaceChar_WithLength_000)441*b3f397bdSDamjan Jovanovic TEST_F(replaceChar_WithLength, replaceChar_WithLength_000)
442cdf0e10cSrcweir {
443cdf0e10cSrcweir rtl_str_replaceChar_WithLength( NULL, 0, 0, 0 );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
TEST_F(replaceChar_WithLength,replaceChar_WithLength_000_1)446*b3f397bdSDamjan Jovanovic TEST_F(replaceChar_WithLength, replaceChar_WithLength_000_1)
447cdf0e10cSrcweir {
448cdf0e10cSrcweir rtl_str_replaceChar_WithLength( NULL, 1, 0, 0 );
449cdf0e10cSrcweir }
TEST_F(replaceChar_WithLength,replaceChar_WithLength_001)450*b3f397bdSDamjan Jovanovic TEST_F(replaceChar_WithLength, replaceChar_WithLength_001)
451cdf0e10cSrcweir {
452cdf0e10cSrcweir rtl::OString aStr1 = "replace char.";
453cdf0e10cSrcweir rtl::OString aShouldStr1 = "ruplace char.";
454cdf0e10cSrcweir
455cdf0e10cSrcweir sal_Char* pStr = (sal_Char*) malloc(aStr1.getLength() + 1);
456*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr != NULL) << "can't get memory for test";
457cdf0e10cSrcweir strcpy(pStr, aStr1.getStr());
458cdf0e10cSrcweir
459cdf0e10cSrcweir rtl_str_replaceChar_WithLength( pStr, 6, 'e', 'u' );
460cdf0e10cSrcweir
461*b3f397bdSDamjan Jovanovic ASSERT_TRUE(aShouldStr1.equals(rtl::OString(pStr)) == sal_True) << "replace failed";
462cdf0e10cSrcweir free(pStr);
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir // -----------------------------------------------------------------------------
466cdf0e10cSrcweir
467*b3f397bdSDamjan Jovanovic class toAsciiLowerCase : public ::testing::Test
468cdf0e10cSrcweir {
469cdf0e10cSrcweir public:
470*b3f397bdSDamjan Jovanovic }; // class replaceChar
471cdf0e10cSrcweir
TEST_F(toAsciiLowerCase,toAsciiLowerCase_000)472*b3f397bdSDamjan Jovanovic TEST_F(toAsciiLowerCase, toAsciiLowerCase_000)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir rtl_str_toAsciiLowerCase( NULL );
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
TEST_F(toAsciiLowerCase,toAsciiLowerCase_001)477*b3f397bdSDamjan Jovanovic TEST_F(toAsciiLowerCase, toAsciiLowerCase_001)
478cdf0e10cSrcweir {
479cdf0e10cSrcweir rtl::OString aStr1 = "CHANGE THIS TO ASCII LOWER CASE.";
480cdf0e10cSrcweir rtl::OString aShouldStr1 = "change this to ascii lower case.";
481cdf0e10cSrcweir
482cdf0e10cSrcweir sal_Char* pStr = (sal_Char*) malloc(aStr1.getLength() + 1);
483*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr != NULL) << "can't get memory for test";
484cdf0e10cSrcweir strcpy(pStr, aStr1.getStr());
485cdf0e10cSrcweir
486cdf0e10cSrcweir rtl_str_toAsciiLowerCase( pStr );
487cdf0e10cSrcweir
488*b3f397bdSDamjan Jovanovic ASSERT_TRUE(aShouldStr1.equals(rtl::OString(pStr)) == sal_True) << "failed";
489cdf0e10cSrcweir free(pStr);
490cdf0e10cSrcweir }
491cdf0e10cSrcweir
492*b3f397bdSDamjan Jovanovic class toAsciiLowerCase_WithLength : public ::testing::Test
493cdf0e10cSrcweir {
494cdf0e10cSrcweir public:
495*b3f397bdSDamjan Jovanovic }; // class replaceChar
496cdf0e10cSrcweir
TEST_F(toAsciiLowerCase_WithLength,toAsciiLowerCase_WithLength_000)497*b3f397bdSDamjan Jovanovic TEST_F(toAsciiLowerCase_WithLength, toAsciiLowerCase_WithLength_000)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir rtl_str_toAsciiLowerCase_WithLength( NULL, 0 );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
TEST_F(toAsciiLowerCase_WithLength,toAsciiLowerCase_WithLength_001)502*b3f397bdSDamjan Jovanovic TEST_F(toAsciiLowerCase_WithLength, toAsciiLowerCase_WithLength_001)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir rtl::OString aStr1 = "CHANGE THIS TO ASCII LOWER CASE.";
505cdf0e10cSrcweir rtl::OString aShouldStr1 = "change thiS TO ASCII LOWER CASE.";
506cdf0e10cSrcweir
507cdf0e10cSrcweir sal_Char* pStr = (sal_Char*) malloc(aStr1.getLength() + 1);
508*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr != NULL) << "can't get memory for test";
509cdf0e10cSrcweir strcpy(pStr, aStr1.getStr());
510cdf0e10cSrcweir
511cdf0e10cSrcweir rtl_str_toAsciiLowerCase_WithLength( pStr, 10 );
512cdf0e10cSrcweir
513*b3f397bdSDamjan Jovanovic printf("Lowercase with length: '%s'\n", pStr);
514*b3f397bdSDamjan Jovanovic ASSERT_TRUE(aShouldStr1.equals(rtl::OString(pStr)) == sal_True) << "failed";
515cdf0e10cSrcweir free(pStr);
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir // -----------------------------------------------------------------------------
519cdf0e10cSrcweir
520*b3f397bdSDamjan Jovanovic class toAsciiUpperCase : public ::testing::Test
521cdf0e10cSrcweir {
522cdf0e10cSrcweir public:
523*b3f397bdSDamjan Jovanovic }; // class replaceChar
524cdf0e10cSrcweir
TEST_F(toAsciiUpperCase,toAsciiUpperCase_000)525*b3f397bdSDamjan Jovanovic TEST_F(toAsciiUpperCase, toAsciiUpperCase_000)
526cdf0e10cSrcweir {
527cdf0e10cSrcweir rtl_str_toAsciiUpperCase( NULL );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir
TEST_F(toAsciiUpperCase,toAsciiUpperCase_001)530*b3f397bdSDamjan Jovanovic TEST_F(toAsciiUpperCase, toAsciiUpperCase_001)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir rtl::OString aStr1 = "change this to ascii upper case.";
533cdf0e10cSrcweir rtl::OString aShouldStr1 = "CHANGE THIS TO ASCII UPPER CASE.";
534cdf0e10cSrcweir
535cdf0e10cSrcweir sal_Char* pStr = (sal_Char*) malloc(aStr1.getLength() + 1);
536*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr != NULL) << "can't get memory for test";
537cdf0e10cSrcweir strcpy(pStr, aStr1.getStr());
538cdf0e10cSrcweir
539cdf0e10cSrcweir rtl_str_toAsciiUpperCase( pStr );
540cdf0e10cSrcweir
541*b3f397bdSDamjan Jovanovic ASSERT_TRUE(aShouldStr1.equals(rtl::OString(pStr)) == sal_True) << "failed";
542cdf0e10cSrcweir free(pStr);
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
545*b3f397bdSDamjan Jovanovic class toAsciiUpperCase_WithLength : public ::testing::Test
546cdf0e10cSrcweir {
547cdf0e10cSrcweir public:
548*b3f397bdSDamjan Jovanovic }; // class replaceChar
549cdf0e10cSrcweir
TEST_F(toAsciiUpperCase_WithLength,toAsciiUpperCase_WithLength_000)550*b3f397bdSDamjan Jovanovic TEST_F(toAsciiUpperCase_WithLength, toAsciiUpperCase_WithLength_000)
551cdf0e10cSrcweir {
552cdf0e10cSrcweir rtl_str_toAsciiUpperCase_WithLength( NULL, 0 );
553cdf0e10cSrcweir }
554cdf0e10cSrcweir
TEST_F(toAsciiUpperCase_WithLength,toAsciiUpperCase_WithLength_001)555*b3f397bdSDamjan Jovanovic TEST_F(toAsciiUpperCase_WithLength, toAsciiUpperCase_WithLength_001)
556cdf0e10cSrcweir {
557cdf0e10cSrcweir rtl::OString aStr1 = "change this to ascii lower case.";
558cdf0e10cSrcweir rtl::OString aShouldStr1 = "CHANGE THIs to ascii lower case.";
559cdf0e10cSrcweir
560cdf0e10cSrcweir sal_Char* pStr = (sal_Char*) malloc(aStr1.getLength() + 1);
561*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr != NULL) << "can't get memory for test";
562cdf0e10cSrcweir
563cdf0e10cSrcweir strcpy(pStr, aStr1.getStr());
564cdf0e10cSrcweir rtl_str_toAsciiUpperCase_WithLength( pStr, 10 );
565cdf0e10cSrcweir
566*b3f397bdSDamjan Jovanovic printf("Uppercase with length: '%s'\n", aStr1.getStr());
567*b3f397bdSDamjan Jovanovic ASSERT_TRUE(aShouldStr1.equals(rtl::OString(pStr)) == sal_True) << "failed";
568cdf0e10cSrcweir free(pStr);
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir // -----------------------------------------------------------------------------
572cdf0e10cSrcweir
573*b3f397bdSDamjan Jovanovic class trim_WithLength : public ::testing::Test
574cdf0e10cSrcweir {
575cdf0e10cSrcweir public:
576*b3f397bdSDamjan Jovanovic };
577*b3f397bdSDamjan Jovanovic
TEST_F(trim_WithLength,trim_WithLength_000)578*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_000)
579cdf0e10cSrcweir {
580cdf0e10cSrcweir rtl_str_trim_WithLength(NULL, 0);
581cdf0e10cSrcweir // should not GPF
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
TEST_F(trim_WithLength,trim_WithLength_000_1)584*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_000_1)
585cdf0e10cSrcweir {
586cdf0e10cSrcweir char pStr[] = { " trim this" };
587cdf0e10cSrcweir rtl_str_trim_WithLength( pStr, 0 );
588cdf0e10cSrcweir }
589cdf0e10cSrcweir
TEST_F(trim_WithLength,trim_WithLength_001)590*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_001)
591cdf0e10cSrcweir {
592cdf0e10cSrcweir char const *pStr = " trim this";
593cdf0e10cSrcweir sal_Char *pStr2 = (sal_Char*)malloc(strlen(pStr) + 1);
594cdf0e10cSrcweir if (pStr2)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir strcpy(pStr2, pStr);
597cdf0e10cSrcweir rtl_str_trim_WithLength( pStr2, 2 );
598cdf0e10cSrcweir
599*b3f397bdSDamjan Jovanovic ASSERT_TRUE(strlen(pStr2) == 0) << "string should be empty";
600cdf0e10cSrcweir free(pStr2);
601cdf0e10cSrcweir }
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
TEST_F(trim_WithLength,trim_WithLength_002)604*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_002)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir char const *pStr = "trim this";
607cdf0e10cSrcweir sal_Char *pStr2 = (sal_Char*)malloc(strlen(pStr) + 1);
608cdf0e10cSrcweir if (pStr2)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir strcpy(pStr2, pStr);
611cdf0e10cSrcweir rtl_str_trim_WithLength( pStr2, 5 );
612cdf0e10cSrcweir
613*b3f397bdSDamjan Jovanovic ASSERT_TRUE(strlen(pStr2) == 4) << "string should contain 'trim'";
614cdf0e10cSrcweir free(pStr2);
615cdf0e10cSrcweir }
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
TEST_F(trim_WithLength,trim_WithLength_003)618*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_003)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir char const *pStr = " trim this";
621cdf0e10cSrcweir sal_Char *pStr2 = (sal_Char*)malloc(strlen(pStr) + 1);
622cdf0e10cSrcweir if (pStr2)
623cdf0e10cSrcweir {
624cdf0e10cSrcweir strcpy(pStr2, pStr);
625cdf0e10cSrcweir rtl_str_trim_WithLength( pStr2, 11 );
626cdf0e10cSrcweir
627*b3f397bdSDamjan Jovanovic ASSERT_TRUE(strlen(pStr2) == 4) << "string should contain 'trim'";
628cdf0e10cSrcweir free(pStr2);
629cdf0e10cSrcweir }
630cdf0e10cSrcweir }
631cdf0e10cSrcweir
TEST_F(trim_WithLength,trim_WithLength_004)632*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_004)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir char const *pStr = "\r\n\t \n\r trim \n this";
635cdf0e10cSrcweir sal_Char *pStr2 = (sal_Char*)malloc(strlen(pStr) + 1);
636cdf0e10cSrcweir if (pStr2)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir strcpy(pStr2, pStr);
639cdf0e10cSrcweir rtl_str_trim_WithLength( pStr2, 17 );
640cdf0e10cSrcweir
641*b3f397bdSDamjan Jovanovic ASSERT_TRUE(strlen(pStr2) == 4) << "string should contain 'trim'";
642cdf0e10cSrcweir free(pStr2);
643cdf0e10cSrcweir }
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
TEST_F(trim_WithLength,trim_WithLength_005)646*b3f397bdSDamjan Jovanovic TEST_F(trim_WithLength, trim_WithLength_005)
647cdf0e10cSrcweir {
648cdf0e10cSrcweir char const *pStr = "\r\n\t \n\r trim \t this \n\r\t\t ";
649cdf0e10cSrcweir sal_Char *pStr2 = (sal_Char*)malloc(strlen(pStr) + 1);
650cdf0e10cSrcweir if (pStr2)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir strcpy(pStr2, pStr);
653cdf0e10cSrcweir rtl_str_trim_WithLength( pStr2, strlen(pStr2) );
654*b3f397bdSDamjan Jovanovic ASSERT_TRUE(strlen(pStr2) == 11) << "string should contain 'trim'";
655cdf0e10cSrcweir free(pStr2);
656cdf0e10cSrcweir }
657cdf0e10cSrcweir }
658cdf0e10cSrcweir
659cdf0e10cSrcweir // -----------------------------------------------------------------------------
660cdf0e10cSrcweir
661*b3f397bdSDamjan Jovanovic class valueOfChar : public ::testing::Test
662cdf0e10cSrcweir {
663cdf0e10cSrcweir public:
664*b3f397bdSDamjan Jovanovic };
665*b3f397bdSDamjan Jovanovic
TEST_F(valueOfChar,valueOfChar_000)666*b3f397bdSDamjan Jovanovic TEST_F(valueOfChar, valueOfChar_000)
667cdf0e10cSrcweir {
668cdf0e10cSrcweir rtl_str_valueOfChar(NULL, 0);
669cdf0e10cSrcweir // should not GPF
670cdf0e10cSrcweir }
TEST_F(valueOfChar,valueOfChar_001)671*b3f397bdSDamjan Jovanovic TEST_F(valueOfChar, valueOfChar_001)
672cdf0e10cSrcweir {
673cdf0e10cSrcweir sal_Char *pStr = (sal_Char*)malloc(RTL_STR_MAX_VALUEOFCHAR);
674cdf0e10cSrcweir if (pStr)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir rtl_str_valueOfChar(pStr, 'A');
677cdf0e10cSrcweir
678*b3f397bdSDamjan Jovanovic ASSERT_TRUE(pStr[0] == 'A') << "string should contain 'A'";
679cdf0e10cSrcweir free(pStr);
680cdf0e10cSrcweir }
681cdf0e10cSrcweir }
682cdf0e10cSrcweir
683cdf0e10cSrcweir } // namespace rtl_str
684cdf0e10cSrcweir
main(int argc,char ** argv)685*b3f397bdSDamjan Jovanovic int main(int argc, char **argv)
686*b3f397bdSDamjan Jovanovic {
687*b3f397bdSDamjan Jovanovic ::testing::InitGoogleTest(&argc, argv);
688*b3f397bdSDamjan Jovanovic return RUN_ALL_TESTS();
689*b3f397bdSDamjan Jovanovic }
690