diff --git a/core/file.cpp b/core/file.cpp index 32593c15..cba7f73e 100644 --- a/core/file.cpp +++ b/core/file.cpp @@ -4,7 +4,7 @@ #include #include -#ifdef CONFIG_TEST +#ifdef CONFIG_TESTING const std::string OCARINA_DIR = "ocarina-test"; #elif CONFIG_DEBUG const std::string OCARINA_DIR = "ocarina-debug"; diff --git a/include/core/file.h b/include/core/file.h index 6b9bba3a..968d4fe1 100644 --- a/include/core/file.h +++ b/include/core/file.h @@ -25,11 +25,11 @@ enum OpenMode { * changes based on what configuration values the user has set when Ocarina * is compiled. * - * Config Value | Ocarina Directory - * -------------|-------------------- - * default | $XDG_DATA_HOME/ocarina/ - * CONFIG_DEBUG | $XDG_DATA_HOME/ocarina-debug/ - * CONFIG_TEST | $XDG_DATA_HOME/ocarina-test/ + * Config Value | Ocarina Directory + * ---------------|-------------------- + * default | $XDG_DATA_HOME/ocarina/ + * CONFIG_DEBUG | $XDG_DATA_HOME/ocarina-debug/ + * CONFIG_TESTING | $XDG_DATA_HOME/ocarina-test/ * * Data should be written to files using either a space or newline as a * delimiter. The beginning of every file is the current file version diff --git a/tests/core/Sconscript b/tests/core/Sconscript index 28e1d99a..2374717e 100644 --- a/tests/core/Sconscript +++ b/tests/core/Sconscript @@ -13,9 +13,9 @@ def CoreTest(name, source): res = [ CoreTest("version", "version.c") ] res += [ CoreTest("string", "string.cpp") ] +res += [ CoreTest("file", "file.cpp") ] Return("res") -#test( "file" ) #test( "database" ) #test( "index" ) #test( "filter" ) diff --git a/tests/core/file.cpp b/tests/core/file.cpp index 1a5aab6f..6ab9b320 100644 --- a/tests/core/file.cpp +++ b/tests/core/file.cpp @@ -2,11 +2,13 @@ * Copyright 2014 (c) Anna Schumaker. */ #include -#include +#include "test.h" static void test_filepath() { + gchar *filepath = test_data_file("file.txt"); + File a("", 0); File b("file.txt", 0); @@ -14,11 +16,13 @@ static void test_filepath() test_equal((std::string)a.get_filepath(), (std::string)""); test_equal(b.get_version(), (unsigned)0); - test_equal((std::string)b.get_filepath(), test :: data_file("file.txt")); + test_equal((std::string)b.get_filepath(), filepath); test_equal(a.exists(), false); test_equal(b.exists(), false); - test_equal(test :: data_dir_exists(), false); + test_equal(test_data_file_exists(NULL), false); + + g_free(filepath); } static void test_open() @@ -35,7 +39,7 @@ static void test_open() test_equal(b.open(OPEN_WRITE), false); b.close(); - test_equal(test :: data_file_exists("file.txt"), true); + test_equal(test_data_file_exists("file.txt"), true); } static void test_io() @@ -60,12 +64,8 @@ static void test_io() test_equal(res, (std::string)"KLMNO PQRST UVWXYZ"); } -int main(int argc, char **argv) -{ - test :: rm_data_dir(); - - test :: run("File Constructor Test", test_filepath); - test :: run("File Open Test", test_open); - test :: run("File I/O Test", test_io); - return 0; -} +DECLARE_UNIT_TESTS( + UNIT_TEST("File Constructor", test_filepath), + UNIT_TEST("File Opening", test_open), + UNIT_TEST("File I/O", test_io), +);