tests/core: Update file test to new testing framework

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-08-24 08:31:00 -04:00
parent 2276a44a07
commit da8131aa6d
4 changed files with 20 additions and 20 deletions

View File

@ -4,7 +4,7 @@
#include <core/file.h>
#include <glib.h>
#ifdef CONFIG_TEST
#ifdef CONFIG_TESTING
const std::string OCARINA_DIR = "ocarina-test";
#elif CONFIG_DEBUG
const std::string OCARINA_DIR = "ocarina-debug";

View File

@ -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

View File

@ -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" )

View File

@ -2,11 +2,13 @@
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/file.h>
#include <tests/test.h>
#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),
);