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
This commit is contained in:
Lukáš Lalinský 2010-07-10 09:22:53 +00:00
parent ab7e997bc6
commit 49631a3013
5 changed files with 53 additions and 0 deletions

2
NEWS
View File

@ -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)
===========================

View 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
////////////////////////////////////////////////////////////////////////////////

View 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:
/*!

View 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}

40
tests/test_apetag.cpp Normal file
View File

@ -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);