]> granicus.if.org Git - taglib/commitdiff
Add String::clear() method to clear the string.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 17 Nov 2015 02:29:52 +0000 (11:29 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 17 Nov 2015 02:29:52 +0000 (11:29 +0900)
taglib/toolkit/tstring.cpp
taglib/toolkit/tstring.h
tests/test_string.cpp

index e21316b24dbaf89af38f43defc29fb8a6a667f25..d623d2376668d34c961baad973c0c802a265e74d 100644 (file)
@@ -358,6 +358,12 @@ String &String::append(const String &s)
   return *this;
 }
 
+String & String::clear()
+{
+  *this = String();
+  return *this;
+}
+
 String String::upper() const
 {
   String s;
index 8b73988231e7081fff746c4f72d7a0f707629d4b..68592f406197c81a4a0fb7040bee8313deba9b13 100644 (file)
@@ -299,6 +299,11 @@ namespace TagLib {
      */
     String &append(const String &s);
 
+    /*!
+     * Clears the string.
+     */
+    String &clear();
+
     /*!
      * Returns an upper case version of the string.
      *
index afb2aa2396befaee2be146ce1ff44316c04eed2b..24816af9d457e54765fb6d96e5fd80d54756189a 100644 (file)
@@ -67,6 +67,10 @@ public:
     CPPUNIT_ASSERT(s != L"taglib");
     CPPUNIT_ASSERT(s != L"taglib string taglib");
 
+    s.clear();
+    CPPUNIT_ASSERT(s.isEmpty());
+    CPPUNIT_ASSERT(!s.isNull());
+
     String unicode("José Carlos", String::UTF8);
     CPPUNIT_ASSERT(strcmp(unicode.toCString(), "Jos\xe9 Carlos") == 0);