From ac658859aa6a0cb63e7799ddb4186ed098a368f7 Mon Sep 17 00:00:00 2001 From: atxr Date: Tue, 6 Feb 2024 16:18:22 +0100 Subject: [PATCH] Add cdh test --- tests/CMakeLists.txt | 2 ++ tests/test_get_cdh.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/test_get_cdh.c diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..49afc36 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(get_cdh ${CMAKE_CURRENT_SOURCE_DIR}/test_get_cdh.c) +target_link_libraries(get_cdh PUBLIC libmineziper) diff --git a/tests/test_get_cdh.c b/tests/test_get_cdh.c new file mode 100644 index 0000000..6c75724 --- /dev/null +++ b/tests/test_get_cdh.c @@ -0,0 +1,26 @@ +#include +#include "libmineziper_zip.h" + +#define BUF_SIZE 10000 + +int main(int argc, char** argv) +{ + FILE* stream = fopen(argv[1], "r"); + if (stream == NULL) + { + fprintf(stderr, "Cannot open file for writing\n"); + return -1; + } + + char buf[BUF_SIZE + 1]; + zip zip; + raw raw; + + raw.size = fread(buf, BUF_SIZE, 1, stream); + buf[BUF_SIZE] = '\0'; + raw.buf = buf; + + find_cdh(&raw, &zip); + + return 0; +} \ No newline at end of file