mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
A bit more tolerant check to return itself in String::substr().
This commit is contained in:
parent
7871afec37
commit
d3062f3af4
@ -447,7 +447,7 @@ bool String::startsWith(const String &s) const
|
||||
|
||||
String String::substr(unsigned int position, unsigned int n) const
|
||||
{
|
||||
if(position == 0 && n == size())
|
||||
if(position == 0 && n >= size())
|
||||
return *this;
|
||||
else
|
||||
return String(d->data.substr(position, n));
|
||||
|
@ -257,6 +257,8 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));
|
||||
CPPUNIT_ASSERT_EQUAL(String("12"), String("0123456").substr(1, 2));
|
||||
CPPUNIT_ASSERT_EQUAL(String("123456"), String("0123456").substr(1, 200));
|
||||
CPPUNIT_ASSERT_EQUAL(String("0123456"), String("0123456").substr(0, 7));
|
||||
CPPUNIT_ASSERT_EQUAL(String("0123456"), String("0123456").substr(0, 200));
|
||||
}
|
||||
|
||||
void testNewline()
|
||||
|
Loading…
x
Reference in New Issue
Block a user