fix: close remaining PR review gaps
CI / lint (pull_request) Failing after 31s
CI / build-and-test (pull_request) Has been skipped
CI / sanitizers (address) (pull_request) Has been skipped
CI / sanitizers (undefined) (pull_request) Has been skipped
CI / fuzz-build (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / valgrind (pull_request) Has been skipped

This commit is contained in:
2026-08-16 09:35:26 +02:00
parent 78876b110e
commit d102622e28
27 changed files with 609 additions and 538 deletions
+6
View File
@@ -12,11 +12,15 @@ static void test_destroyer(void* item) {
void test_array_list() {
ArrayList* list = array_list_create(free);
EXPECT_NOT_NULL(list);
if (!list)
return;
EXPECT_EQ_INT(list->size, 0);
EXPECT_EQ_INT(list->capacity, 100);
// Test adding
int* val1 = malloc(sizeof(int));
if (!val1)
return;
*val1 = 42;
array_list_add(list, val1);
EXPECT_EQ_INT(list->size, 1);
@@ -26,6 +30,8 @@ void test_array_list() {
// Initial capacity is 100. Let's add 105 elements.
for (int i = 0; i < 105; i++) {
int* val = malloc(sizeof(int));
if (!val)
return;
*val = i;
array_list_add(list, val);
}
+2
View File
@@ -13,6 +13,8 @@ static void test_data_compress_decompress_roundtrip() {
size_t len = strlen(original);
char* buf = malloc(len);
if (!buf)
return;
memcpy(buf, original, len);
Data* original_data = data_create(buf, len);
EXPECT_NOT_NULL(original_data);
+10
View File
@@ -14,6 +14,8 @@
static Data* random_data(int min_size, int max_size) {
int size = min_size + rand() % (max_size - min_size + 1);
char* buf = malloc(size);
if (!buf)
return NULL;
for (int i = 0; i < size; i++)
buf[i] = (char)(rand() % 256);
return data_create(buf, size);
@@ -23,10 +25,16 @@ static void test_property_compress_roundtrip() {
for (int iter = 0; iter < 10; iter++) {
Data* original = random_data(1, 10000);
EXPECT_NOT_NULL(original);
if (!original)
return;
size_t orig_size = original->size;
void* orig_copy = malloc(orig_size);
EXPECT_NOT_NULL(orig_copy);
if (!orig_copy) {
data_destroy(original);
return;
}
memcpy(orig_copy, original->data, orig_size);
Data* compressed = data_compress(original, 3);
@@ -81,6 +89,8 @@ static void test_property_chunk_roundtrip() {
int content_len = 1 + rand() % 4096;
char* content = malloc(content_len);
if (!content)
return;
for (int i = 0; i < content_len; i++)
content[i] = (char)(rand() % 256);
+6
View File
@@ -119,9 +119,13 @@ static void test_queue_destroyer() {
destroyer_calls = 0;
Queue* q = queue_create(5, my_destroyer);
EXPECT_NOT_NULL(q);
if (!q)
return;
for (int i = 0; i < 3; i++) {
int* val = malloc(sizeof(int));
if (!val)
break;
*val = i;
queue_enqueue(q, val);
}
@@ -181,6 +185,8 @@ static void test_queue_multithreaded() {
for (int i = 1; i <= 100; i++) {
int* val = malloc(sizeof(int));
if (!val)
break;
*val = i;
queue_enqueue_multithreaded(q, val, &mutex, &cnd_empty, &cnd_full);
}
+8
View File
@@ -32,6 +32,8 @@ static int mpmc_producer_func(void* arg) {
ProducerCtx* ctx = (ProducerCtx*)arg;
for (int i = 1; i <= ITEMS_PER_PRODUCER; i++) {
int* val = malloc(sizeof(int));
if (!val)
return thrd_error;
*val = ctx->producer_id * ITEMS_PER_PRODUCER + i;
queue_enqueue_multithreaded(ctx->q, val, ctx->mutex, ctx->cnd_empty, ctx->cnd_full);
}
@@ -121,6 +123,8 @@ static int bp_producer_func(void* arg) {
BackpressureCtx* ctx = (BackpressureCtx*)arg;
for (int i = 0; i < 5; i++) {
int* val = malloc(sizeof(int));
if (!val)
return thrd_error;
*val = i + 1;
queue_enqueue_multithreaded(ctx->q, val, ctx->mutex, ctx->cnd_empty, ctx->cnd_full);
ctx->items_sent++;
@@ -191,9 +195,13 @@ static void test_queue_rapid_create_destroy() {
for (int i = 0; i < 100; i++) {
Queue* q = queue_create(4, free);
EXPECT_NOT_NULL(q);
if (!q)
return;
for (int j = 0; j < 3; j++) {
int* val = malloc(sizeof(int));
if (!val)
break;
*val = j;
queue_enqueue(q, val);
}