2014-11-12 08:16:53 -05:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
|
2014-11-12 08:31:09 -05:00
|
|
|
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
2014-11-13 08:31:47 -05:00
|
|
|
test_equal(library.size(), (unsigned)0);
|
2014-11-13 08:14:29 -05:00
|
|
|
test_equal(library.enabled(), true);
|
2014-11-12 08:16:53 -05:00
|
|
|
|
2014-11-13 08:31:47 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2014-11-12 08:16:53 -05:00
|
|
|
|
|
|
|
f.open(OPEN_WRITE);
|
|
|
|
library.write(f);
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
library = Library();
|
2014-11-12 08:31:09 -05:00
|
|
|
test_equal(library.primary_key(), (std::string)"");
|
2014-11-13 08:31:47 -05:00
|
|
|
test_equal(library.size(), (unsigned)0);
|
2014-11-13 08:14:29 -05:00
|
|
|
test_equal(library.enabled(), false);
|
2014-11-12 08:16:53 -05:00
|
|
|
|
|
|
|
f.open(OPEN_READ);
|
|
|
|
library.read(f);
|
|
|
|
f.close();
|
|
|
|
|
2014-11-12 08:31:09 -05:00
|
|
|
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
2014-11-13 08:31:47 -05:00
|
|
|
test_equal(library.size(), (unsigned)0); /* _size is not saved to disk. */
|
2014-11-13 08:14:29 -05:00
|
|
|
test_equal(library.enabled(), true);
|
2014-11-12 08:16:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
run_test("Library Tag Test", test_library_tag);
|
|
|
|
return 0;
|
|
|
|
}
|