mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Merge pull request #231 from TsudaKageyu/containsat
Fixed behavior change of ByteVector::containsAt()
This commit is contained in:
commit
c4c5b06643
@ -601,11 +601,11 @@ bool ByteVector::containsAt(const ByteVector &pattern, uint offset, uint pattern
|
||||
patternLength = pattern.size();
|
||||
|
||||
// do some sanity checking -- all of these things are needed for the search to be valid
|
||||
|
||||
if(offset + patternLength > size() || patternOffset >= pattern.size() || patternLength == 0)
|
||||
const uint compareLength = patternLength - patternOffset;
|
||||
if(offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0)
|
||||
return false;
|
||||
|
||||
return (::memcmp(data() + offset, pattern.data() + patternOffset, patternLength - patternOffset) == 0);
|
||||
return (::memcmp(data() + offset, pattern.data() + patternOffset, compareLength) == 0);
|
||||
}
|
||||
|
||||
bool ByteVector::startsWith(const ByteVector &pattern) const
|
||||
|
@ -112,12 +112,17 @@ public:
|
||||
ByteVector s2("f");
|
||||
CPPUNIT_ASSERT(ByteVectorList::split(s2, " ").size() == 1);
|
||||
|
||||
|
||||
CPPUNIT_ASSERT(ByteVector().size() == 0);
|
||||
CPPUNIT_ASSERT(ByteVector("asdf").clear().size() == 0);
|
||||
CPPUNIT_ASSERT(ByteVector("asdf").clear() == ByteVector());
|
||||
}
|
||||
|
||||
ByteVector i("blah blah");
|
||||
ByteVector j("blah");
|
||||
CPPUNIT_ASSERT(i.containsAt(j, 5, 0));
|
||||
CPPUNIT_ASSERT(i.containsAt(j, 6, 1));
|
||||
CPPUNIT_ASSERT(i.containsAt(j, 6, 1, 3));
|
||||
}
|
||||
|
||||
void testFind1()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO"));
|
||||
|
Loading…
Reference in New Issue
Block a user