Debian Codegraph @

tests/test_string.cpp

raw symbols SCIP
1 /***************************************************************************
2 copyright : (C) 2007 by Lukas Lalinsky
3 email : [email protected]
4 ***************************************************************************/
5
6 /***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26 #include <string>
27 #include <cstring>
28
29 #include "tstring.h"
30 #include "tstringlist.h"
31 #include "tbytevector.h"
32 #include "tutils.h"
33 #include <cppunit/extensions/HelperMacros.h>
34
35 using namespace std;
36 using namespace TagLib;
37
38 class TestString : public CppUnit::TestFixture
39 {
40 CPPUNIT_TEST_SUITE(TestString);
41 CPPUNIT_TEST(testString);
42 CPPUNIT_TEST(testRfind);
43 CPPUNIT_TEST(testUTF16Encode);
44 CPPUNIT_TEST(testUTF16Decode);
45 CPPUNIT_TEST(testUTF16DecodeInvalidBOM);
46 CPPUNIT_TEST(testUTF16DecodeEmptyWithBOM);
47 CPPUNIT_TEST(testSurrogatePair);
48 CPPUNIT_TEST(testAppendCharDetach);
49 CPPUNIT_TEST(testAppendStringDetach);
50 CPPUNIT_TEST(testToInt);
51 CPPUNIT_TEST(testFromInt);
52 CPPUNIT_TEST(testSubstr);
53 CPPUNIT_TEST(testNewline);
54 CPPUNIT_TEST(testUpper);
55 CPPUNIT_TEST(testEncodeNonLatin1);
56 CPPUNIT_TEST(testEncodeEmpty);
57 CPPUNIT_TEST(testEncodeNonBMP);
58 CPPUNIT_TEST(testIterator);
59 CPPUNIT_TEST(testInvalidUTF8);
60 CPPUNIT_TEST(testEmpty);
61 CPPUNIT_TEST_SUITE_END();
62
63 public:
64
65 void testString()
66 {
67 String s = "taglib string";
68 ByteVector v = "taglib string";
69 CPPUNIT_ASSERT(v == s.data(String::Latin1));
70
71 char str[] = "taglib string";
72 CPPUNIT_ASSERT(strcmp(s.toCString(), str) == 0);
73 CPPUNIT_ASSERT(s == "taglib string");
74 CPPUNIT_ASSERT(s != "taglib STRING");
75 CPPUNIT_ASSERT(s != "taglib");
76 CPPUNIT_ASSERT(s != "taglib string taglib");
77 CPPUNIT_ASSERT(s == L"taglib string");
78 CPPUNIT_ASSERT(s != L"taglib STRING");
79 CPPUNIT_ASSERT(s != L"taglib");
80 CPPUNIT_ASSERT(s != L"taglib string taglib");
81
82 s.clear();
83 CPPUNIT_ASSERT(s.isEmpty());
84
85 String unicode("José Carlos", String::UTF8);
86 CPPUNIT_ASSERT(strcmp(unicode.toCString(), "Jos\xe9 Carlos") == 0);
87
88 String latin = "Jos\xe9 Carlos";
89 CPPUNIT_ASSERT(strcmp(latin.toCString(true), "José Carlos") == 0);
90
91 String c = "1";
92 CPPUNIT_ASSERT(c == L"1");
93
94 c = L'\u4E00';
95 CPPUNIT_ASSERT(c == L"\u4E00");
96
97 String unicode2(unicode.to8Bit(true), String::UTF8);
98 CPPUNIT_ASSERT(unicode == unicode2);
99
100 String unicode3(L"\u65E5\u672C\u8A9E");
101 CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
102
103 constexpr wchar_t wcSystemOrder[] = {L'\u65E5', L'\u672C', L'\u8A9E', 0};
104 constexpr wchar_t wcSwappedOrder[] = {L'\uE565', L'\u2C67', L'\u9E8A', 0};
105 const std::wstring wsSystemOrder = L"\u65e5\u672c\u8a9e";
106 const std::wstring wsSwappedOrder = L"\ue565\u2c67\u9e8a";
107 const bool isLe = Utils::systemByteOrder() == Utils::LittleEndian;
108
109 String unicode4(isLe ? wcSwappedOrder : wcSystemOrder, String::UTF16BE);
110 CPPUNIT_ASSERT(unicode4[1] == L'\u672c');
111
112 String unicode5(isLe ? wcSystemOrder : wcSwappedOrder, String::UTF16LE);
113 CPPUNIT_ASSERT(unicode5[1] == L'\u672c');
114
115 String unicode6(isLe ? wsSwappedOrder : wsSystemOrder, String::UTF16BE);
116 CPPUNIT_ASSERT(unicode6[1] == L'\u672c');
117
118 String unicode7(isLe ? wsSystemOrder : wsSwappedOrder, String::UTF16LE);
119 CPPUNIT_ASSERT(unicode7[1] == L'\u672c');
120
121 CPPUNIT_ASSERT(String(" foo ").stripWhiteSpace() == String("foo"));
122 CPPUNIT_ASSERT(String("foo ").stripWhiteSpace() == String("foo"));
123 CPPUNIT_ASSERT(String(" foo").stripWhiteSpace() == String("foo"));
124 CPPUNIT_ASSERT(String("foo").stripWhiteSpace() == String("foo"));
125 CPPUNIT_ASSERT(String("f o o").stripWhiteSpace() == String("f o o"));
126 CPPUNIT_ASSERT(String(" f o o ").stripWhiteSpace() == String("f o o"));
127
128 CPPUNIT_ASSERT(memcmp(String("foo").data(String::Latin1).data(), "foo", 3) == 0);
129 CPPUNIT_ASSERT(memcmp(String("f").data(String::Latin1).data(), "f", 1) == 0);
130 }
131
132 void testUTF16Encode()
133 {
134 String a("foo");
135 ByteVector b("\0f\0o\0o", 6);
136 ByteVector c("f\0o\0o\0", 6);
137 ByteVector d("\377\376f\0o\0o\0", 8);
138 CPPUNIT_ASSERT(a.data(String::UTF16BE) != a.data(String::UTF16LE));
139 CPPUNIT_ASSERT(b == a.data(String::UTF16BE));
140 CPPUNIT_ASSERT(c == a.data(String::UTF16LE));
141 CPPUNIT_ASSERT_EQUAL(d, a.data(String::UTF16));
142 }
143
144 void testUTF16Decode()
145 {
146 String a("foo");
147 ByteVector b("\0f\0o\0o", 6);
148 ByteVector c("f\0o\0o\0", 6);
149 ByteVector d("\377\376f\0o\0o\0", 8);
150 CPPUNIT_ASSERT_EQUAL(a, String(b, String::UTF16BE));
151 CPPUNIT_ASSERT_EQUAL(a, String(c, String::UTF16LE));
152 CPPUNIT_ASSERT_EQUAL(a, String(d, String::UTF16));
153 }
154
155 // this test is expected to print "TagLib: String::prepare() -
156 // Invalid UTF16 string." on the console 3 times
157 void testUTF16DecodeInvalidBOM()
158 {
159 ByteVector b(" ", 1);
160 ByteVector c(" ", 2);
161 ByteVector d(" \0f\0o\0o", 8);
162 CPPUNIT_ASSERT_EQUAL(String(), String(b, String::UTF16));
163 CPPUNIT_ASSERT_EQUAL(String(), String(c, String::UTF16));
164 CPPUNIT_ASSERT_EQUAL(String(), String(d, String::UTF16));
165 }
166
167 void testUTF16DecodeEmptyWithBOM()
168 {
169 ByteVector a("\377\376", 2);
170 ByteVector b("\376\377", 2);
171 CPPUNIT_ASSERT_EQUAL(String(), String(a, String::UTF16));
172 CPPUNIT_ASSERT_EQUAL(String(), String(b, String::UTF16));
173 }
174
175 void testSurrogatePair()
176 {
177 // Make sure that a surrogate pair is converted into single UTF-8 char
178 // and vice versa.
179
180 const ByteVector v1("\xff\xfe\x42\xd8\xb7\xdf\xce\x91\x4b\x5c");
181 const ByteVector v2("\xf0\xa0\xae\xb7\xe9\x87\x8e\xe5\xb1\x8b");
182
183 const String s1(v1, String::UTF16);
184 CPPUNIT_ASSERT_EQUAL(s1.data(String::UTF8), v2);
185
186 const String s2(v2, String::UTF8);
187 CPPUNIT_ASSERT_EQUAL(s2.data(String::UTF16), v1);
188
189 const ByteVector v3("\xfe\xff\xd8\x01\x30\x42");
190 CPPUNIT_ASSERT(String(v3, String::UTF16).data(String::UTF8).isEmpty());
191
192 const ByteVector v4("\xfe\xff\x30\x42\xdc\x01");
193 CPPUNIT_ASSERT(String(v4, String::UTF16).data(String::UTF8).isEmpty());
194
195 const ByteVector v5("\xfe\xff\xdc\x01\xd8\x01");
196 CPPUNIT_ASSERT(String(v5, String::UTF16).data(String::UTF8).isEmpty());
197 }
198
199 void testAppendStringDetach()
200 {
201 String a("a");
202 String b = a;
203 a += "b";
204 CPPUNIT_ASSERT_EQUAL(String("ab"), a);
205 CPPUNIT_ASSERT_EQUAL(String("a"), b);
206 }
207
208 void testAppendCharDetach()
209 {
210 String a("a");
211 String b = a;
212 a += 'b';
213 CPPUNIT_ASSERT_EQUAL(String("ab"), a);
214 CPPUNIT_ASSERT_EQUAL(String("a"), b);
215 }
216
217 void testRfind()
218 {
219 CPPUNIT_ASSERT_EQUAL(-1, String("foo.bar").rfind(".", 0));
220 CPPUNIT_ASSERT_EQUAL(-1, String("foo.bar").rfind(".", 1));
221 CPPUNIT_ASSERT_EQUAL(-1, String("foo.bar").rfind(".", 2));
222 CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 3));
223 CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 4));
224 CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 5));
225 CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 6));
226 CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 7));
227 CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind("."));
228 }
229
230 void testToInt()
231 {
232 bool ok;
233 CPPUNIT_ASSERT_EQUAL(String("123").toInt(&ok), 123);
234 CPPUNIT_ASSERT_EQUAL(ok, true);
235
236 CPPUNIT_ASSERT_EQUAL(String("-123").toInt(&ok), -123);
237 CPPUNIT_ASSERT_EQUAL(ok, true);
238
239 CPPUNIT_ASSERT_EQUAL(String("abc").toInt(&ok), 0);
240 CPPUNIT_ASSERT_EQUAL(ok, false);
241
242 CPPUNIT_ASSERT_EQUAL(String("1x").toInt(&ok), 1);
243 CPPUNIT_ASSERT_EQUAL(ok, false);
244
245 CPPUNIT_ASSERT_EQUAL(String("").toInt(&ok), 0);
246 CPPUNIT_ASSERT_EQUAL(ok, false);
247
248 CPPUNIT_ASSERT_EQUAL(String("-").toInt(&ok), 0);
249 CPPUNIT_ASSERT_EQUAL(ok, false);
250
251 CPPUNIT_ASSERT_EQUAL(String("123").toInt(), 123);
252 CPPUNIT_ASSERT_EQUAL(String("-123").toInt(), -123);
253 CPPUNIT_ASSERT_EQUAL(String("123aa").toInt(), 123);
254 CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
255
256 CPPUNIT_ASSERT_EQUAL(String("0000").toInt(), 0);
257 CPPUNIT_ASSERT_EQUAL(String("0001").toInt(), 1);
258
259 String("2147483648").toInt(&ok);
260 CPPUNIT_ASSERT_EQUAL(ok, false);
261
262 String("-2147483649").toInt(&ok);
263 CPPUNIT_ASSERT_EQUAL(ok, false);
264 }
265
266 void testFromInt()
267 {
268 CPPUNIT_ASSERT_EQUAL(String::number(0), String("0"));
269 CPPUNIT_ASSERT_EQUAL(String::number(12345678), String("12345678"));
270 CPPUNIT_ASSERT_EQUAL(String::number(-12345678), String("-12345678"));
271 }
272
273 void testSubstr()
274 {
275 CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));
276 CPPUNIT_ASSERT_EQUAL(String("12"), String("0123456").substr(1, 2));
277 CPPUNIT_ASSERT_EQUAL(String("123456"), String("0123456").substr(1, 200));
278 CPPUNIT_ASSERT_EQUAL(String("0123456"), String("0123456").substr(0, 7));
279 CPPUNIT_ASSERT_EQUAL(String("0123456"), String("0123456").substr(0, 200));
280 }
281
282 void testNewline()
283 {
284 ByteVector cr("abc\x0dxyz", 7);
285 ByteVector lf("abc\x0axyz", 7);
286 ByteVector crlf("abc\x0d\x0axyz", 8);
287
288 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(7), String(cr).size());
289 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(7), String(lf).size());
290 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(8), String(crlf).size());
291
292 CPPUNIT_ASSERT(L'\x0d' == String(cr)[3]);
293 CPPUNIT_ASSERT(L'\x0a' == String(lf)[3]);
294 CPPUNIT_ASSERT(L'\x0d' == String(crlf)[3]);
295 CPPUNIT_ASSERT(L'\x0a' == String(crlf)[4]);
296 }
297
298 void testUpper()
299 {
300 String s1 = "tagLIB 012 strING";
301 String s2 = s1.upper();
302 CPPUNIT_ASSERT_EQUAL(String("tagLIB 012 strING"), s1);
303 CPPUNIT_ASSERT_EQUAL(String("TAGLIB 012 STRING"), s2);
304 }
305
306 void testEncodeNonLatin1()
307 {
308 const String jpn(L"\u65E5\u672C\u8A9E");
309 CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x2C\x9E"), jpn.data(String::Latin1));
310 CPPUNIT_ASSERT_EQUAL(ByteVector("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn.data(String::UTF8));
311 CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE\xE5\x65\x2C\x67\x9E\x8A"), jpn.data(String::UTF16));
312 CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x65\x2C\x67\x9E\x8A"), jpn.data(String::UTF16LE));
313 CPPUNIT_ASSERT_EQUAL(ByteVector("\x65\xE5\x67\x2C\x8A\x9E"), jpn.data(String::UTF16BE));
314 CPPUNIT_ASSERT_EQUAL(std::string("\xE5\x2C\x9E"), jpn.to8Bit(false));
315 CPPUNIT_ASSERT_EQUAL(std::string("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn.to8Bit(true));
316 }
317
318 void testEncodeEmpty()
319 {
320 const String empty;
321 CPPUNIT_ASSERT(empty.data(String::Latin1).isEmpty());
322 CPPUNIT_ASSERT(empty.data(String::UTF8).isEmpty());
323 CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE"), empty.data(String::UTF16));
324 CPPUNIT_ASSERT(empty.data(String::UTF16LE).isEmpty());
325 CPPUNIT_ASSERT(empty.data(String::UTF16BE).isEmpty());
326 CPPUNIT_ASSERT(empty.to8Bit(false).empty());
327 CPPUNIT_ASSERT(empty.to8Bit(true).empty());
328 }
329
330 void testEncodeNonBMP()
331 {
332 const ByteVector a("\xFF\xFE\x3C\xD8\x50\xDD\x40\xD8\xF5\xDC\x3C\xD8\x00\xDE", 14);
333 const ByteVector b("\xF0\x9F\x85\x90\xF0\xA0\x83\xB5\xF0\x9F\x88\x80");
334 CPPUNIT_ASSERT_EQUAL(b, String(a, String::UTF16).data(String::UTF8));
335 }
336
337 void testIterator()
338 {
339 String s1 = "taglib string";
340 String s2 = s1;
341
342 String::Iterator it1 = s1.begin();
343 String::Iterator it2 = s2.begin();
344
345 CPPUNIT_ASSERT(L't' == *it1);
346 CPPUNIT_ASSERT(L't' == *it2);
347
348 std::advance(it1, 4);
349 std::advance(it2, 4);
350 *it2 = L'I';
351 CPPUNIT_ASSERT(L'i' == *it1);
352 CPPUNIT_ASSERT(L'I' == *it2);
353 }
354
355 void testInvalidUTF8()
356 {
357 CPPUNIT_ASSERT_EQUAL(String("/"), String(ByteVector("\x2F"), String::UTF8));
358 CPPUNIT_ASSERT(String(ByteVector("\xC0\xAF"), String::UTF8).isEmpty());
359 CPPUNIT_ASSERT(String(ByteVector("\xE0\x80\xAF"), String::UTF8).isEmpty());
360 CPPUNIT_ASSERT(String(ByteVector("\xF0\x80\x80\xAF"), String::UTF8).isEmpty());
361
362 CPPUNIT_ASSERT(String(ByteVector("\xF8\x80\x80\x80\x80"), String::UTF8).isEmpty());
363 CPPUNIT_ASSERT(String(ByteVector("\xFC\x80\x80\x80\x80\x80"), String::UTF8).isEmpty());
364
365 CPPUNIT_ASSERT(String(ByteVector("\xC2"), String::UTF8).isEmpty());
366 CPPUNIT_ASSERT(String(ByteVector("\xE0\x80"), String::UTF8).isEmpty());
367 CPPUNIT_ASSERT(String(ByteVector("\xF0\x80\x80"), String::UTF8).isEmpty());
368 CPPUNIT_ASSERT(String(ByteVector("\xF8\x80\x80\x80"), String::UTF8).isEmpty());
369 CPPUNIT_ASSERT(String(ByteVector("\xFC\x80\x80\x80\x80"), String::UTF8).isEmpty());
370
371 CPPUNIT_ASSERT(String('\x80', String::UTF8).isEmpty());
372
373 CPPUNIT_ASSERT(String(ByteVector("\xED\xA0\x80\xED\xB0\x80"), String::UTF8).isEmpty());
374 CPPUNIT_ASSERT(String(ByteVector("\xED\xB0\x80\xED\xA0\x80"), String::UTF8).isEmpty());
375 }
376
377 void testEmpty()
378 {
379 const String empty;
380 const String notEmpty("A");
381 String mutEmpty;
382
383 CPPUNIT_ASSERT_EQUAL(empty, String(""));
384 CPPUNIT_ASSERT_EQUAL(empty, String(std::wstring()));
385 CPPUNIT_ASSERT_EQUAL(empty, String(static_cast<const wchar_t *>(nullptr)));
386 CPPUNIT_ASSERT(empty != String('\0'));
387 CPPUNIT_ASSERT_EQUAL(empty, String(L'\0'));
388 CPPUNIT_ASSERT_EQUAL(empty, String(static_cast<const char *>(nullptr)));
389 CPPUNIT_ASSERT_EQUAL(empty, String(ByteVector()));
390 CPPUNIT_ASSERT_EQUAL(empty.to8Bit(), std::string());
391 CPPUNIT_ASSERT_EQUAL(empty.toWString(), std::wstring());
392 CPPUNIT_ASSERT_EQUAL(::strlen(empty.toCString()), (size_t)0);
393 CPPUNIT_ASSERT_EQUAL(::wcslen(empty.toCWString()), (size_t)0);
394 CPPUNIT_ASSERT(empty.begin() == empty.end());
395 CPPUNIT_ASSERT(empty.cbegin() == empty.cend());
396 CPPUNIT_ASSERT(mutEmpty.begin() == mutEmpty.end());
397 CPPUNIT_ASSERT_EQUAL(empty.find(mutEmpty), 0);
398 CPPUNIT_ASSERT_EQUAL(empty.find(notEmpty), -1);
399 CPPUNIT_ASSERT_EQUAL(notEmpty.find(empty), 0);
400 CPPUNIT_ASSERT_EQUAL(empty.rfind(mutEmpty), 0);
401 CPPUNIT_ASSERT_EQUAL(empty.rfind(notEmpty), -1);
402 CPPUNIT_ASSERT_EQUAL(notEmpty.rfind(empty), 1);
403 CPPUNIT_ASSERT_EQUAL(empty.split(), StringList(empty));
404 CPPUNIT_ASSERT_EQUAL(empty.startsWith(mutEmpty), true);
405 CPPUNIT_ASSERT_EQUAL(empty.startsWith(notEmpty), false);
406 CPPUNIT_ASSERT_EQUAL(notEmpty.startsWith(empty), true);
407 CPPUNIT_ASSERT_EQUAL(empty.substr(0), empty);
408 CPPUNIT_ASSERT_EQUAL(mutEmpty.append(empty), empty);
409 CPPUNIT_ASSERT_EQUAL(mutEmpty.append(notEmpty), notEmpty);
410 mutEmpty.clear();
411 CPPUNIT_ASSERT_EQUAL(mutEmpty, empty);
412 CPPUNIT_ASSERT_EQUAL(String(notEmpty).append(empty), notEmpty);
413 CPPUNIT_ASSERT_EQUAL(empty.upper(), empty);
414 CPPUNIT_ASSERT_EQUAL(empty.size(), 0U);
415 CPPUNIT_ASSERT_EQUAL(empty.length(), 0U);
416 CPPUNIT_ASSERT_EQUAL(empty.isEmpty(), true);
417 CPPUNIT_ASSERT_EQUAL(empty.data(String::Latin1), ByteVector());
418 CPPUNIT_ASSERT_EQUAL(empty.data(String::UTF16LE), ByteVector());
419 bool ok;
420 empty.toInt(&ok);
421 CPPUNIT_ASSERT(!ok);
422 CPPUNIT_ASSERT_EQUAL(empty.stripWhiteSpace(), empty);
423 CPPUNIT_ASSERT_EQUAL(empty.isLatin1(), true);
424 CPPUNIT_ASSERT_EQUAL(empty.isAscii(), true);
425 CPPUNIT_ASSERT(empty == mutEmpty);
426 CPPUNIT_ASSERT(empty != notEmpty);
427 CPPUNIT_ASSERT(empty == "");
428 CPPUNIT_ASSERT(empty != " ");
429 CPPUNIT_ASSERT(empty == L"");
430 CPPUNIT_ASSERT(empty != L" ");
431 CPPUNIT_ASSERT(empty == static_cast<const char *>(nullptr));
432 CPPUNIT_ASSERT(!(empty != static_cast<const char *>(nullptr)));
433 CPPUNIT_ASSERT(empty == static_cast<const wchar_t *>(nullptr));
434 CPPUNIT_ASSERT(!(empty != static_cast<const wchar_t *>(nullptr)));
435 CPPUNIT_ASSERT_EQUAL(mutEmpty += empty, empty);
436 CPPUNIT_ASSERT_EQUAL(mutEmpty += notEmpty, notEmpty);
437 mutEmpty.clear();
438 CPPUNIT_ASSERT_EQUAL(mutEmpty += static_cast<const char *>(nullptr), empty);
439 CPPUNIT_ASSERT_EQUAL(mutEmpty += static_cast<const wchar_t *>(nullptr), empty);
440 CPPUNIT_ASSERT_EQUAL(mutEmpty = static_cast<const char *>(nullptr), empty);
441 CPPUNIT_ASSERT_EQUAL(mutEmpty = static_cast<const wchar_t *>(nullptr), empty);
442 String tmp;
443 mutEmpty.swap(tmp);
444 CPPUNIT_ASSERT_EQUAL(mutEmpty, empty);
445 CPPUNIT_ASSERT_EQUAL(empty < notEmpty, true);
446 CPPUNIT_ASSERT_EQUAL(empty + mutEmpty, empty);
447 CPPUNIT_ASSERT_EQUAL(empty + notEmpty, notEmpty);
448 CPPUNIT_ASSERT_EQUAL(empty + static_cast<const char *>(nullptr), empty);
449 }
450
451 };
452
453 CPPUNIT_TEST_SUITE_REGISTRATION(TestString);