libmpm

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

commit ec48a967f130dfe3ffc2063a1f70a72b43ac207e
parent 1bb9d6349baac90612f961292198286ee7196066
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 31 Mar 2017 18:54:56 +0200

Fix(Tests): Add tests (WIP) for packer_read_dir, fix a typo in packer_init_archive test

Diffstat:
Mtests/test_packer.c | 26+++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -21,18 +21,38 @@ TEST(packer_init_archive) { set_strdup_fail(1); set_malloc_fail(1); - ptr = packer_init_dir("Test 123"); + ptr = packer_init_archive("Test 123"); TEST_ASSERT(ptr != NULL, "Function failed"); TEST_ASSERT(strcmp(ptr->str, "Test 123") == 0, "Directory name is wrong"); packer_free(ptr); - ptr = packer_init_dir("Test 123"); + ptr = packer_init_archive("Test 123"); TEST_ASSERT(ptr == NULL, "Error not raised"); - ptr = packer_init_dir("Test 123"); + ptr = packer_init_archive("Test 123"); TEST_ASSERT(ptr == NULL, "Error not raised"); return TEST_SUCCESS; } +TEST(packer_read_dir_wrong_type) { + packer_t *ptr; + + ptr = packer_init_archive("Test"); + TEST_ASSERT(packer_read_dir(ptr) == false, "Error not raised"); + packer_free(ptr); + return TEST_SUCCESS; +} + +TEST(packer_read_dir_wrong_dir) { + packer_t *ptr; + + ptr = packer_init_dir("Test/non/existing"); + TEST_ASSERT(packer_read_dir(ptr) == false, "Error not raised"); + packer_free(ptr); + return TEST_SUCCESS; +} + void register_test_packer(void) { reg_test("packer", packer_init_dir); reg_test("packer", packer_init_archive); + reg_test("packer", packer_read_dir_wrong_type); + reg_test("packer", packer_read_dir_wrong_dir); }