} \
})
+#define ASSERT_OK_EQ(expr1, expr2) \
+ ({ \
+ typeof(expr1) _expr1 = (expr1); \
+ typeof(expr2) _expr2 = (expr2); \
+ if (_expr1 < 0) { \
+ log_error_errno(_expr1, "%s:%i: Assertion failed: expected \"%s\" to succeed but got the following error: %m", \
+ PROJECT_FILE, __LINE__, #expr1); \
+ abort(); \
+ } \
+ if (_expr1 != _expr2) { \
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
+ log_error("%s:%i: Assertion failed: expected \"%s == %s\", but %s != %s", \
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
+ abort(); \
+ } \
+ })
+
#define ASSERT_OK_ERRNO(expr) \
({ \
typeof(expr) _result = (expr); \
ASSERT_SIGNAL(ASSERT_OK_ZERO(-1), SIGABRT);
ASSERT_SIGNAL(ASSERT_OK_ZERO(-ENOANO), SIGABRT);
+ ASSERT_OK_EQ(0, 0);
+ ASSERT_SIGNAL(ASSERT_OK_EQ(1, 0), SIGABRT);
+ ASSERT_SIGNAL(ASSERT_OK_EQ(255, 5), SIGABRT);
+ ASSERT_SIGNAL(ASSERT_OK_EQ(-1, 0), SIGABRT);
+ ASSERT_SIGNAL(ASSERT_OK_EQ(-ENOANO, 0), SIGABRT);
+
ASSERT_OK_ERRNO(0 >= 0);
ASSERT_OK_ERRNO(255 >= 0);
ASSERT_OK_ERRNO(printf("Hello world\n"));