unit-tests: Pass stringyfied assertion statement as non-format string argument
If the assertion contains a modulo (%) operation, test_fail_msg() handles this as printf() format specifier. Pass the assertion string as argument for an explicit "%s" in the format string, instead.
This commit is contained in:
@@ -313,7 +313,7 @@ void test_fail_if_worker_failed();
|
||||
test_fail_if_worker_failed(); \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
test_fail_msg(__FILE__, __LINE__, #x); \
|
||||
test_fail_msg(__FILE__, __LINE__, "%s", #x); \
|
||||
} \
|
||||
})
|
||||
|
||||
@@ -329,7 +329,7 @@ void test_fail_if_worker_failed();
|
||||
test_fail_if_worker_failed(); \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
test_fail_msg(__FILE__, __LINE__, #x ": " fmt, ##__VA_ARGS__); \
|
||||
test_fail_msg(__FILE__, __LINE__, "%s: " fmt, #x, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@@ -349,7 +349,7 @@ void test_fail_if_worker_failed();
|
||||
test_fail_if_worker_failed(); \
|
||||
if (x) \
|
||||
{ \
|
||||
test_fail_msg(__FILE__, __LINE__, #x ": " fmt, ##__VA_ARGS__); \
|
||||
test_fail_msg(__FILE__, __LINE__, "%s : " fmt, #x, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
#define fail_unless test_assert_msg
|
||||
|
||||
Reference in New Issue
Block a user