Implement assert_str and assert_not_null and update tests
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user