]> git.ipfire.org Git - pakfire.git/commitdiff
tests: compress: Tidy up the code to get better assertion messages
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Jan 2025 14:00:59 +0000 (14:00 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Jan 2025 14:00:59 +0000 (14:00 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/compress.c

index 7823e5860944d1a3660513f523cd2adbfffecf28..557f743a0b0dbdabccea6216b57080193e77f73d 100644 (file)
@@ -37,6 +37,7 @@ static int read_test(const struct test* t,
        FILE* f = NULL;
        char path[PATH_MAX];
        char buffer[1024];
+       size_t bytes_read;
 
        ASSERT_SUCCESS(pakfire_string_format(path, "%s/%s", TEST_SRC_PATH, file));
 
@@ -44,12 +45,10 @@ static int read_test(const struct test* t,
        ASSERT(f = fopen(path, "r"));
 
        // Engage decompressor
-       f = function(f, "r");
-       ASSERT(f);
+       ASSERT(f = function(f, "r"));
 
        // Read into buffer
-       size_t bytes_read = fread(buffer, 1, sizeof(buffer), f);
-       ASSERT(bytes_read);
+       ASSERT(bytes_read = fread(buffer, 1, sizeof(buffer), f));
 
        // Buffer should equal the test data
        ASSERT(bytes_read >= sizeof(TEST_DATA) - 1);