mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Detach before appending a character
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@944552 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
98d2808c17
commit
1eace99153
@ -560,6 +560,8 @@ String &String::operator+=(wchar_t c)
|
||||
|
||||
String &String::operator+=(char c)
|
||||
{
|
||||
detach();
|
||||
|
||||
d->data += uchar(c);
|
||||
return *this;
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ class TestString : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testUTF16Decode);
|
||||
CPPUNIT_TEST(testUTF16DecodeInvalidBOM);
|
||||
CPPUNIT_TEST(testUTF16DecodeEmptyWithBOM);
|
||||
CPPUNIT_TEST(testAppendCharDetach);
|
||||
CPPUNIT_TEST(testAppendStringDetach);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -131,6 +133,24 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String(), String(b, String::UTF16));
|
||||
}
|
||||
|
||||
void testAppendStringDetach()
|
||||
{
|
||||
String a("a");
|
||||
String b = a;
|
||||
a += "b";
|
||||
CPPUNIT_ASSERT_EQUAL(String("ab"), a);
|
||||
CPPUNIT_ASSERT_EQUAL(String("a"), b);
|
||||
}
|
||||
|
||||
void testAppendCharDetach()
|
||||
{
|
||||
String a("a");
|
||||
String b = a;
|
||||
a += 'b';
|
||||
CPPUNIT_ASSERT_EQUAL(String("ab"), a);
|
||||
CPPUNIT_ASSERT_EQUAL(String("a"), b);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);
|
||||
|
Loading…
x
Reference in New Issue
Block a user