mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Fixed a bug in creating String from ByteVector
This commit is contained in:
parent
c12b6697f9
commit
cf892f2cb8
@ -268,6 +268,9 @@ String::String(const ByteVector &v, Type t)
|
||||
copyFromUTF8(v.data(), v.size());
|
||||
else
|
||||
copyFromUTF16(v.data(), v.size(), t);
|
||||
|
||||
// If we hit a null in the ByteVector, shrink the string again.
|
||||
d->data.resize(::wcslen(d->data.c_str()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tstring.h>
|
||||
#include <mpegfile.h>
|
||||
#include <id3v1tag.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
@ -16,8 +19,20 @@ public:
|
||||
|
||||
void testStripWhiteSpace()
|
||||
{
|
||||
ID3v1::StringHandler h;
|
||||
CPPUNIT_ASSERT_EQUAL(String("Foo"), h.parse(ByteVector("Foo ")));
|
||||
ScopedFileCopy copy("xing", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
MPEG::File f(newname.c_str());
|
||||
f.ID3v1Tag(true)->setArtist("Artist ");
|
||||
f.save();
|
||||
}
|
||||
|
||||
{
|
||||
MPEG::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.ID3v1Tag(false));
|
||||
CPPUNIT_ASSERT_EQUAL(String("Artist"), f.ID3v1Tag(false)->artist());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user