mirror of
https://github.com/taglib/taglib.git
synced 2025-07-22 23:14:33 -04:00
Merge pull request #305 from TsudaKageyu/fix-string-upper
String::upper() no longer modifies the String itself
This commit is contained in:
@ -390,7 +390,7 @@ String String::upper() const
|
||||
{
|
||||
static const int shift = 'A' - 'a';
|
||||
|
||||
String s(*this);
|
||||
String s(*d->data);
|
||||
for(Iterator it = s.begin(); it != s.end(); ++it) {
|
||||
if(*it >= 'a' && *it <= 'z')
|
||||
*it = *it + shift;
|
||||
|
@ -43,6 +43,7 @@ class TestString : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testToInt);
|
||||
CPPUNIT_TEST(testSubstr);
|
||||
CPPUNIT_TEST(testNewline);
|
||||
CPPUNIT_TEST(testUpper);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -237,6 +238,14 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(L'\x0d', String(crlf)[3]);
|
||||
CPPUNIT_ASSERT_EQUAL(L'\x0a', String(crlf)[4]);
|
||||
}
|
||||
|
||||
void testUpper()
|
||||
{
|
||||
String s1 = "tagLIB 012 strING";
|
||||
String s2 = s1.upper();
|
||||
CPPUNIT_ASSERT_EQUAL(String("tagLIB 012 strING"), s1);
|
||||
CPPUNIT_ASSERT_EQUAL(String("TAGLIB 012 STRING"), s2);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user