From 49631a30130edf94bb313852d0bd4f9184a96041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Sat, 10 Jul 2010 09:22:53 +0000 Subject: [PATCH] Implemented a specialized version of APE::Tag::isEmpty() git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1148318 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- NEWS | 2 ++ taglib/ape/apetag.cpp | 5 +++++ taglib/ape/apetag.h | 5 +++++ tests/CMakeLists.txt | 1 + tests/test_apetag.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 tests/test_apetag.cpp diff --git a/NEWS b/NEWS index 48324e61..919641a1 100644 --- 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) =========================== diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 1c38d2bd..d70b68b0 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -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 //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/ape/apetag.h b/taglib/ape/apetag.h index 253f8a86..0c24155d 100644 --- a/taglib/ape/apetag.h +++ b/taglib/ape/apetag.h @@ -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: /*! diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 21820d75..136f9b63 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 index 00000000..901a2aaf --- /dev/null +++ b/tests/test_apetag.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include +#include +#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);