libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit e5a0e66a91aeb5f174fce07eed9a3c638097ac1e
parent 0ea941c87e26e19c75b23292a9aeed1d89359d19
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue, 31 Jan 2017 14:43:46 +0100

Add(Tests): Test for files and categories

Diffstat:
Mtests/main.c | 2++
Mtests/test.h | 2++
Atests/test_categories.c | 16++++++++++++++++
Atests/test_files.c | 18++++++++++++++++++
4 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/tests/main.c b/tests/main.c @@ -5,6 +5,8 @@ int main(void) { register_flags_test(); register_test_database(); + register_test_files(); + register_test_category(); ret = test_all(); test_free(); return ret; diff --git a/tests/test.h b/tests/test.h @@ -12,6 +12,8 @@ void register_flags_test(void); void register_test_database(void); +void register_test_files(void); +void register_test_category(void); void clean_db(const char *name); int free_sql_results(void *ptr); diff --git a/tests/test_categories.c b/tests/test_categories.c @@ -0,0 +1,16 @@ +#include "test.h" + +TEST(category_init) { + category_t *ptr; + + ptr = malloc(sizeof(category_t)); + mpm_category_init(ptr); + TEST_ASSERT((ptr->name == NULL), "Init is wrong"); + mpm_category_free(ptr); + free(ptr); + return TEST_SUCCESS; +} + +void register_test_category(void) { + reg_test("category", category_init); +} diff --git a/tests/test_files.c b/tests/test_files.c @@ -0,0 +1,18 @@ +#include "test.h" + +TEST(files_init) { + file_t *ptr; + + ptr = malloc(sizeof(file_t)); + mpm_file_init(ptr); + TEST_ASSERT((ptr->path == NULL), "Init is wrong"); + TEST_ASSERT((ptr->parent == NULL), "Init is wrong"); + TEST_ASSERT((ptr->hash == NULL), "Init is wrong"); + mpm_file_free(ptr); + free(ptr); + return TEST_SUCCESS; +} + +void register_test_files(void) { + reg_test("files", files_init); +}