Implement assert_str and assert_not_null and update tests

This commit is contained in:
2026-04-24 14:57:24 +02:00
parent 594e33efd6
commit 0fa7b599ed
4 changed files with 46 additions and 6 deletions
+13
View File
@@ -1,6 +1,7 @@
#include "test.h"
#include <setjmp.h>
#include <stdio.h>
#include <string.h>
static jmp_buf s_testJmp;
static const char* s_failMsg;
@@ -10,6 +11,18 @@ void fail(const char* msg) {
longjmp(s_testJmp, 1);
}
void assert_not_null(void* ptr, const char* msg) {
if (ptr == NULL) {
fail(msg);
}
}
void assert_str(const char* expected, const char* actual, const char* msg) {
if (expected == NULL || actual == NULL || strcmp(expected, actual) != 0) {
fail(msg);
}
}
typedef struct {
const char* name;
Test func;