libmpm

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

commit 3816006ae960af40257a66cbc07a39f3ec4e597a
parent eb0e731c7a452269f0eba051b77aa980d33b72f9
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 10 May 2017 11:57:37 +0200

Add(Tests): Add test for read_package_header function

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

diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -569,6 +569,23 @@ TEST(packer_create_directory_name) { return TEST_SUCCESS; } +TEST(packer_read_archive_header) { + packer_t *ctx = NULL; + + ctx = packer_init_dir("test/"); + TEST_ASSERT(packer_read_archive_header(ctx) == NULL, "Error did not raise"); + packer_free(ctx); + + ctx = packer_init_archive(PACKAGE_OUTPUT_FN); + set_malloc_fail(0); + TEST_ASSERT(packer_read_archive_header(ctx) == NULL, "Error did not raise"); + + TEST_ASSERT(packer_read_archive_header(ctx) != NULL, "Something happend"); + TEST_ASSERT(strcmp(ctx->header->package->name, "test") == 0, "Name is wrong"); + TEST_ASSERT(strcmp(ctx->header->package->version, "2.0") == 0, "Name is wrong"); + return TEST_SUCCESS; +} + TEST(packer_create_archive_cleanup) { unlink(PACKAGE_OUTPUT_FN); return TEST_SUCCESS; @@ -624,5 +641,6 @@ void register_test_packer(void) { reg_test("packer", read_packer_file_from_binary); reg_test("packer", packer_file_to_disk); reg_test("packer", packer_create_directory_name); + reg_test("packer", packer_read_archive_header); reg_test("packer", packer_create_archive_cleanup); }