+/** @brief Check that a function calls fatal()
+ * @param WHAT Expression to evaluate
+ *
+ * Evaluates WHAT and if it does not call fatal(), logs an error. In any case,
+ * continues. Modifies exitfn() so that fatal() isn't actually fatal.
+ */
+#define check_fatal(WHAT) do { \
+ void (*const save_exitfn)(int) attribute((noreturn)) = exitfn; \
+ \
+ exitfn = test_exitfn; \
+ if(setjmp(fatal_env) == 0) { \
+ fprintf(stderr, "Expect an error:\n "); \
+ (void)(WHAT); \
+ fprintf(stderr, "\n%s:%d: %s unexpectedly returned\n", \
+ __FILE__, __LINE__, #WHAT); \
+ count_error(); \
+ } \
+ ++tests; \
+ exitfn = save_exitfn; \
+} while(0)
+