libmpm

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

commit c5139079351d096e740eebf4312d6cc992c18442
parent 697d3b646d0262e30db93b248b89a82f63ad4d1f
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 26 Jun 2017 19:37:39 +0200

Fix(Tests): New test for read_conf_opt

Diffstat:
Mtests/test_packer.c | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -604,6 +604,20 @@ TEST(get_file_information) { return TEST_SUCCESS; } +MPX_STATIC bool read_conf_opt(char *file, mlist_t **list, int *ret); +TEST(read_conf_opt) { + char file[250]; + int ptr = 0; + mlist_t *head = NULL; + u32_t size = htonl(1); + + memcpy(file, &size, sizeof(size)); + memcpy(file + sizeof(size), "test:something", sizeof("test:something")); + set_malloc_fail(0); + TEST_ASSERT(read_conf_opt(file, &head, &ptr) == false, "Error did not raise"); + return TEST_SUCCESS; +} + TEST(packer_inlines_frees) { vector_string_t *str = NULL, *str2 = NULL; @@ -685,6 +699,7 @@ void register_test_packer(void) { reg_test("packer", packer_read_archive_header); reg_test("packer", packer_file_from_binary_to_disk); reg_test("packer", get_file_information); + reg_test("packer", read_conf_opt); reg_test("packer", packer_inlines_frees); reg_test("packer", packer_create_archive_cleanup); }