const char TEST_DATA[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
-static int test_xzfopen_read(const struct test* t) {
+static int read_test(const struct test* t,
+ FILE* (function)(FILE* f, const char* mode), const char* file) {
char buffer[1024];
- char* path = pakfire_path_join(TEST_SRC_PATH, "data/compress/data.xz");
+ char* path = pakfire_path_join(TEST_SRC_PATH, file);
ASSERT(path);
FILE* f = fopen(path, "r");
ASSERT(f);
// Engage decompressor
- f = pakfire_xzfopen(f, "r");
+ f = function(f, "r");
ASSERT(f);
// Read into buffer
return EXIT_SUCCESS;
}
+static int test_xzfopen_read(const struct test* t) {
+ return read_test(t, pakfire_xzfopen, "data/compress/data.xz");
+}
+
static int test_xzfopen_write(const struct test* t) {
// Create a backend storage file
FILE* f = test_mktemp();
return EXIT_SUCCESS;
}
+static int test_xfopen(const struct test* t) {
+ return read_test(t, pakfire_xfopen, "data/compress/data.xz");
+}
+
int main(int argc, char** argv) {
testsuite_add_test(test_xzfopen_read);
testsuite_add_test(test_xzfopen_write);
+ testsuite_add_test(test_xfopen);
+
return testsuite_run();
}