Library: Add a unit test for the Library tag

This tests all the basic things that the tag does:  storing values and
reading / writing from file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-11-12 08:16:53 -05:00
parent 4d6cb81f77
commit f83765d11e
3 changed files with 43 additions and 1 deletions

View File

@ -18,7 +18,7 @@ test( "tags/generic" )
test( "tags/artist" )
test( "tags/album" )
test( "tags/genre" )
objs += [ get_test_obj("tags/library", "core") ]
test( "tags/library" )
test_env.UsePackage("taglib")
objs += [ get_test_obj("tags", "core") ]

View File

@ -2,3 +2,4 @@ album
artist
generic
genre
library

View File

@ -0,0 +1,41 @@
/**
* @file
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/tags/library.h>
#include <tests/test.h>
static void test_library_tag()
{
Library library("/home/Zelda/Music");
File f("library_tag", 0);
test_equal(library.root_path, (std::string)"/home/Zelda/Music");
test_equal(library.count, (unsigned)0);
test_equal(library.enabled, true);
library.count = 42; /* not saved to disk */
f.open(OPEN_WRITE);
library.write(f);
f.close();
library = Library();
test_equal(library.root_path, (std::string)"");
test_equal(library.count, (unsigned)0);
test_equal(library.enabled, false);
f.open(OPEN_READ);
library.read(f);
f.close();
test_equal(library.root_path, (std::string)"/home/Zelda/Music");
test_equal(library.count, (unsigned)0);
test_equal(library.enabled, true);
}
int main(int argc, char **argv)
{
run_test("Library Tag Test", test_library_tag);
return 0;
}