63769c9c0b
I commented out most of the file and directory modification code while I was at it. I'll re-add these as I convert more files to C. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
106 lines
2.8 KiB
C
106 lines
2.8 KiB
C
/*
|
|
* Copyright 2015 (c) Anna Schumaker.
|
|
*/
|
|
#include <tests/test.h>
|
|
#include <stdlib.h>
|
|
|
|
#ifdef CONFIG_TESTING
|
|
static const char *str = "Enabled";
|
|
#else /* CONFIG_TESTING */
|
|
static const char *str = "Disabled";
|
|
#endif /* CONFIG_TESTING */
|
|
|
|
static unsigned int counter = 0;
|
|
static unsigned int inc_counter() { return counter++; }
|
|
|
|
static void test_passing_tests()
|
|
{
|
|
unsigned int i;
|
|
|
|
test_equal(0, 0);
|
|
test_equal("2", "2");
|
|
test_equal((void *)4, (void *)4);
|
|
test_equal(str, "Enabled");
|
|
test_equal(inc_counter(), 0);
|
|
test_equal((bool)true, (bool)true);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
test_loop_equal(i, i, i);
|
|
test_loop_passed();
|
|
|
|
test_not_equal(0, 1);
|
|
test_not_equal("2", "3");
|
|
test_not_equal((void *)4, (void *)5);
|
|
test_not_equal(str, "Disabled");
|
|
test_not_equal(inc_counter(), 2);
|
|
test_not_equal((bool)true, (bool)false);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
test_loop_not_equal(i, i + 1, i);
|
|
test_loop_passed();
|
|
}
|
|
|
|
static void test_failing_tests()
|
|
{
|
|
unsigned int i;
|
|
|
|
test_equal(0, 1);
|
|
test_equal("2", "3");
|
|
test_equal((void *)4, (void *)5);
|
|
test_equal(str, "Disabled");
|
|
test_equal(inc_counter(), 3);
|
|
test_equal((bool)true, (bool)false);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
test_loop_equal(i, i + 1, i);
|
|
test_loop_passed();
|
|
|
|
test_not_equal(0, 0);
|
|
test_not_equal("2", "2");
|
|
test_not_equal((void *)4, (void *)4);
|
|
test_not_equal(str, "Enabled");
|
|
test_not_equal(inc_counter(), 3);
|
|
test_not_equal((bool)true, (bool)true);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
test_loop_not_equal(i, i, i);
|
|
test_loop_passed();
|
|
tests_failed = 0;
|
|
}
|
|
|
|
static void test_utilities()
|
|
{
|
|
gchar *dir = test_data_file(NULL);
|
|
gchar *file = test_data_file("sanity");
|
|
const gchar *data = g_get_user_data_dir();
|
|
gchar *ddata = g_strjoin("/", data, "ocarina-test", NULL);
|
|
gchar *fdata = g_strjoin("/", data, "ocarina-test", "sanity", NULL);
|
|
|
|
test_equal(dir, ddata);
|
|
test_equal(file, fdata);
|
|
test_equal(test_data_file_exists(NULL), (bool)false);
|
|
test_equal(test_data_file_exists("sanity"), (bool)false);
|
|
|
|
test_cp_data_dir();
|
|
test_equal(test_data_file_exists(NULL), (bool)true);
|
|
test_equal(test_data_file_exists("artist.db"), (bool)true);
|
|
test_equal(test_data_file_exists("cur_track"), (bool)true);
|
|
test_equal(test_data_file_exists("library.db"), (bool)true);
|
|
test_equal(test_data_file_exists("genre.db"), (bool)true);
|
|
test_equal(test_data_file_exists("playlist.db"), (bool)true);
|
|
test_equal(test_data_file_exists("track.db"), (bool)true);
|
|
test_equal(test_data_file_exists("album.db"), (bool)true);
|
|
test_equal(test_data_file_exists("deck"), (bool)true);
|
|
|
|
g_free(dir);
|
|
g_free(file);
|
|
g_free(ddata);
|
|
g_free(fdata);
|
|
}
|
|
|
|
DECLARE_UNIT_TESTS(
|
|
UNIT_TEST("Sanity Check", test_passing_tests),
|
|
UNIT_TEST("Sanity Check (All should fail)", test_failing_tests),
|
|
UNIT_TEST("Sanity Check Utility Functions", test_utilities),
|
|
);
|