]> granicus.if.org Git - taglib/commitdiff
Implemented a specialized version of APE::Tag::isEmpty()
authorLukáš Lalinský <lalinsky@gmail.com>
Sat, 10 Jul 2010 09:22:53 +0000 (09:22 +0000)
committerLukáš Lalinský <lalinsky@gmail.com>
Sat, 10 Jul 2010 09:22:53 +0000 (09:22 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1148318 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

NEWS
taglib/ape/apetag.cpp
taglib/ape/apetag.h
tests/CMakeLists.txt
tests/test_apetag.cpp [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 48324e612fd90e34594db590a188462b5dd5b699..919641a1a34f8d3d5f454c828d1dbc0df54e140e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ TagLib 1.7
 ==========
 
  * Support for reading/writing tags from Monkey's Audio files.
+ * Implemented APE::Tag::isEmpty() to check for all APE tags, not just the
+   basic ones.
 
 TagLib 1.6.3 (Apr 17, 2010)
 ===========================
index 1c38d2bdd05a3e45762ad156053c84d1e1f0f6c9..d70b68b0818d849af9e613f535f2e7a3c2993073 100644 (file)
@@ -208,6 +208,11 @@ void APE::Tag::setItem(const String &key, const Item &item)
   d->itemListMap.insert(key.upper(), item);
 }
 
+bool APE::Tag::isEmpty() const
+{
+  return d->itemListMap.isEmpty();
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // protected methods
 ////////////////////////////////////////////////////////////////////////////////
index 253f8a864acea100809a2a0dbbe406811454adb0..0c24155d235dc8ad30a9c95869f9af44e7e27501 100644 (file)
@@ -137,6 +137,11 @@ namespace TagLib {
        */
       void setItem(const String &key, const Item &item);
 
+      /*!
+       * Returns true if the tag does not contain any data.
+       */
+      bool isEmpty() const;
+
     protected:
 
       /*!
index 21820d75dbd41610b2a2b59da8f527a1304030d0..136f9b63ec12a4ad4a5b319b3f0d8a2613f5c968 100644 (file)
@@ -39,6 +39,7 @@ SET(test_runner_SRCS
   test_oggflac.cpp
   test_flac.cpp
   test_ape.cpp
+  test_apetag.cpp
 )
 IF(WITH_MP4)
    SET(test_runner_SRCS ${test_runner_SRCS}
diff --git a/tests/test_apetag.cpp b/tests/test_apetag.cpp
new file mode 100644 (file)
index 0000000..901a2aa
--- /dev/null
@@ -0,0 +1,40 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <string>
+#include <stdio.h>
+#include <tag.h>
+#include <tstringlist.h>
+#include <tbytevectorlist.h>
+#include <apetag.h>
+#include "utils.h"
+
+using namespace std;
+using namespace TagLib;
+
+class TestAPETag : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE(TestAPETag);
+  CPPUNIT_TEST(testIsEmpty);
+  CPPUNIT_TEST(testIsEmpty2);
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+
+  void testIsEmpty()
+  {
+    APE::Tag tag;
+    CPPUNIT_ASSERT(tag.isEmpty());
+    tag.addValue("COMPOSER", "Mike Oldfield");
+    CPPUNIT_ASSERT(!tag.isEmpty());
+  }
+
+  void testIsEmpty2()
+  {
+    APE::Tag tag;
+    CPPUNIT_ASSERT(tag.isEmpty());
+    tag.setArtist("Mike Oldfield");
+    CPPUNIT_ASSERT(!tag.isEmpty());
+  }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestAPETag);