bac54857fd
The artist_db should really be controlled from within the Artist tag, so this patch creates a new tags namespace containing functions that will find or create tags as they are requested. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
/**
|
|
* @file
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/tags/artist.h>
|
|
#include <tests/test.h>
|
|
|
|
static void test_artist_tag()
|
|
{
|
|
Artist artist;
|
|
test_equal(artist.name(), (std::string)"");
|
|
test_equal(artist.lowercase(), (std::string)"");
|
|
test_equal(artist.primary_key(), (std::string)"");
|
|
|
|
artist = Artist("Koji Kondo");
|
|
test_equal(artist.name(), (std::string)"Koji Kondo");
|
|
test_equal(artist.lowercase(), (std::string)"koji kondo");
|
|
test_equal(artist.primary_key(), (std::string)"Koji Kondo");
|
|
}
|
|
|
|
static void test_artist_tag_lookup()
|
|
{
|
|
Database<Artist> artist_db("artist.db", false);
|
|
Artist *artist = tags :: get_artist("Koji Kondo");
|
|
|
|
test_equal(artist->name(), (std::string)"Koji Kondo");
|
|
test_equal(artist->lowercase(), (std::string)"koji kondo");
|
|
test_equal(artist->primary_key(), (std::string)"Koji Kondo");
|
|
|
|
test_equal(tags :: get_artist("Koji Kondo"), artist);
|
|
test_equal(tags :: get_artist(0), artist);
|
|
test_equal(tags :: get_artist(1), (Artist *)NULL);
|
|
|
|
artist_db.load();
|
|
test_equal(artist_db.size(), (unsigned)1);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
run_test("Artist Tag Test", test_artist_tag);
|
|
run_test("Artist Tag Lookup Test", test_artist_tag_lookup);
|
|
return 0;
|
|
}
|