send_loc_info (file, line);
}
-void _ck_assert_msg (int result, const char *file,
+void _ck_assert_failed (const char *file,
int line, const char *expr, ...)
{
const char *msg;
-
+ va_list ap;
+ char buf[BUFSIZ];
+
send_loc_info (file, line);
- if (!result) {
- va_list ap;
- char buf[BUFSIZ];
-
- va_start(ap,expr);
- msg = (const char*)va_arg(ap, char *);
- if (msg == NULL)
- msg = expr;
- vsnprintf(buf, BUFSIZ, msg, ap);
- va_end(ap);
- send_failure_info (buf);
- if (cur_fork_status() == CK_FORK) {
-#ifdef HAVE_FORK
- exit(1);
-#endif /* HAVE_FORK */
- } else {
- longjmp(error_jmp_buffer, 1);
- }
+
+ va_start(ap,expr);
+ msg = (const char*)va_arg(ap, char *);
+ if (msg == NULL)
+ msg = expr;
+ vsnprintf(buf, BUFSIZ, msg, ap);
+ va_end(ap);
+ send_failure_info (buf);
+ if (cur_fork_status() == CK_FORK) {
+ #ifdef HAVE_FORK
+ exit(1);
+ #endif /* HAVE_FORK */
+ } else {
+ longjmp(error_jmp_buffer, 1);
}
}
FIXME: strcmp (str1, str2) due to excessive string length.
*/
#define fail_if(expr, ...)\
- _ck_assert_msg(!(expr), __FILE__, __LINE__,\
- "Failure '"#expr"' occured" , ## __VA_ARGS__, NULL)
+ (expr) ? \
+ _ck_assert_failed(__FILE__, __LINE__, "Failure '"#expr"' occured" , ## __VA_ARGS__, NULL) \
+ : _mark_point(__FILE__, __LINE__)
#define fail ck_abort_msg
-/* Non macro version of #ck_assert_msg, with more complicated interface */
-void CK_EXPORT _ck_assert_msg (int result, const char *file,
- int line, const char *expr, ...);
+/* This is called whenever an assertion fails */
+void CK_EXPORT _ck_assert_failed (const char *file, int line, const char *expr, ...) CK_ATTRIBUTE_NORETURN;
/* New check fail API. */
*/
#define ck_assert(C) ck_assert_msg(C, NULL)
#define ck_assert_msg(expr, ...) \
- _ck_assert_msg(expr, __FILE__, __LINE__,\
- "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
+ (expr) ? \
+ _mark_point(__FILE__, __LINE__) : \
+ _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
/* Always fail */
#define ck_abort() ck_abort_msg(NULL)
-#define ck_abort_msg(...) _ck_assert_msg(0, __FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL)
+#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL)
/* Signed and unsigned integer comparsion macros with improved output compared to ck_assert(). */
/* OP may be any comparion operator. */