Efficient lookup for the MP4/ASF field name and ID3v1 genre tables.

Linear lookup is much faster and memory efficient when an array is very small.
This commit is contained in:
Tsuda Kageyu
2015-11-19 16:35:55 +09:00
parent 72a807def1
commit a3564d8c68
5 changed files with 437 additions and 412 deletions

View File

@ -3,6 +3,7 @@
#include <tstring.h>
#include <mpegfile.h>
#include <id3v1tag.h>
#include <id3v1genres.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -13,6 +14,7 @@ class TestID3v1 : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestID3v1);
CPPUNIT_TEST(testStripWhiteSpace);
CPPUNIT_TEST(testGenres);
CPPUNIT_TEST_SUITE_END();
public:
@ -27,7 +29,7 @@ public:
f.ID3v1Tag(true)->setArtist("Artist ");
f.save();
}
{
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT(f.ID3v1Tag(false));
@ -35,6 +37,12 @@ public:
}
}
void testGenres()
{
CPPUNIT_ASSERT_EQUAL(String("Darkwave"), ID3v1::genre(50));
CPPUNIT_ASSERT_EQUAL(100, ID3v1::genreIndex("Humour"));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v1);