From ced5f262ba66541c54685eeb1d58b3b7acf82cca Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 30 Oct 2013 19:37:44 +0900 Subject: [PATCH 1/2] String::upper() no longer modifies the String itself --- taglib/toolkit/tstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 25d8db1c..52f176b2 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -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; From 0acdd2379e3729021068799f5dd5f70d4428fb43 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 30 Oct 2013 22:40:21 +0900 Subject: [PATCH 2/2] Added a test for String::upper() --- tests/test_string.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 0e2807ef..779ada67 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -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); + } };