mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
ByteVector::append() can't take the vector itself.
This commit is contained in:
parent
98a57744c3
commit
7d8aa7b8bd
@ -554,12 +554,16 @@ int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const
|
||||
|
||||
ByteVector &ByteVector::append(const ByteVector &v)
|
||||
{
|
||||
if(v.d->length != 0) {
|
||||
detach();
|
||||
unsigned int originalSize = size();
|
||||
resize(originalSize + v.size());
|
||||
::memcpy(data() + originalSize, v.data(), v.size());
|
||||
}
|
||||
if(v.isEmpty())
|
||||
return *this;
|
||||
|
||||
detach();
|
||||
|
||||
const unsigned int originalSize = size();
|
||||
const unsigned int appendSize = v.size();
|
||||
|
||||
resize(originalSize + v.size());
|
||||
::memcpy(data() + originalSize, v.data(), appendSize);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ class TestByteVector : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testReplace);
|
||||
CPPUNIT_TEST(testIterator);
|
||||
CPPUNIT_TEST(testResize);
|
||||
CPPUNIT_TEST(testAppend);
|
||||
CPPUNIT_TEST(testAppend1);
|
||||
CPPUNIT_TEST(testAppend2);
|
||||
CPPUNIT_TEST(testBase64);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
@ -403,7 +404,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(-1, c.find('C'));
|
||||
}
|
||||
|
||||
void testAppend()
|
||||
void testAppend1()
|
||||
{
|
||||
ByteVector v1("foo");
|
||||
v1.append("bar");
|
||||
@ -441,6 +442,13 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v8);
|
||||
}
|
||||
|
||||
void testAppend2()
|
||||
{
|
||||
ByteVector a("1234");
|
||||
a.append(a);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("12341234"), a);
|
||||
}
|
||||
|
||||
void testBase64()
|
||||
{
|
||||
ByteVector sempty;
|
||||
|
Loading…
x
Reference in New Issue
Block a user