ce8b3ada03
Also make it private and provide accessor functions. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
/**
|
|
* @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.primary_key(), (std::string)"/home/Zelda/Music");
|
|
test_equal(library.size(), (unsigned)0);
|
|
test_equal(library.enabled(), true);
|
|
|
|
|
|
for (unsigned int i = 0; i < 42; i++)
|
|
library.inc_size();
|
|
test_equal(library.size(), (unsigned)42);
|
|
|
|
for (unsigned int i = 0; i < 21; i++)
|
|
library.dec_size();
|
|
test_equal(library.size(), (unsigned)21);
|
|
|
|
|
|
f.open(OPEN_WRITE);
|
|
library.write(f);
|
|
f.close();
|
|
|
|
library = Library();
|
|
test_equal(library.primary_key(), (std::string)"");
|
|
test_equal(library.size(), (unsigned)0);
|
|
test_equal(library.enabled(), false);
|
|
|
|
f.open(OPEN_READ);
|
|
library.read(f);
|
|
f.close();
|
|
|
|
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
|
test_equal(library.size(), (unsigned)0); /* _size is not saved to disk. */
|
|
test_equal(library.enabled(), true);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
run_test("Library Tag Test", test_library_tag);
|
|
return 0;
|
|
}
|