Files
RedBear-OS/tests/test_helpers.h
T

28 lines
878 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef _TEST_HELPERS
#define _TEST_HELPERS
#include <stdlib.h>
#include <string.h>
#include <errno.h>
// Throws an error on a well-defined error value.
#define ERROR_IF(func, status, condition) { \
if (status condition) { \
fprintf(stderr, "%s:%d: %s returned an error in function %s: %s (%d)\n", \
__FILE__, __LINE__, #func, __func__, strerror(errno), errno); \
exit(EXIT_FAILURE); \
}\
}
// Throws an error on an return value not defined by the standards.
// Used for sanity checking the return values.
#define UNEXP_IF(func, status, condition) { \
if (status condition) { \
fprintf(stderr, "%s:%d: %s returned a value not defined by the standards in function %s: %d\n", \
__FILE__, __LINE__, #func, __func__, status); \
exit(EXIT_FAILURE); \
}\
}
#endif /* _TEST_HELPERS */