@@ -42,6 +42,27 @@ struct mock_param_matcher *kunit_any(struct kunit *test)
matcher); \
}
+#define TYPE_FRMT(type_name) FORMAT_##type_name
+#define FORMAT_u8 "%hu"
+#define FORMAT_u16 "%hu"
+#define FORMAT_u32 "%u"
+#define FORMAT_u64 "%llu"
+#define FORMAT_char "%c"
+#define FORMAT_uchar "%c"
+#define FORMAT_schar "%c"
+#define FORMAT_short "%hd"
+#define FORMAT_ushort "%hu"
+#define FORMAT_int "%d"
+#define FORMAT_uint "%u"
+#define FORMAT_long "%ld"
+#define FORMAT_ulong "%lu"
+#define FORMAT_longlong "%lld"
+#define FORMAT_ulonglong "%llu"
+#define FORMAT_ptr "%p"
+
+#define CMP_FORMAT(type_name, msg, op) \
+ TYPE_FRMT(type_name) msg " " #op " " TYPE_FRMT(type_name)
+
#define DEFINE_MATCH_FUNC(type_name, type, op_name, op) \
bool match_##type_name##_##op_name( \
struct mock_param_matcher *pmatcher, \
@@ -55,12 +76,12 @@ struct mock_param_matcher *kunit_any(struct kunit *test)
\
if (matches) \
kunit_stream_add(stream, \
- "%d "#op" %d", \
+ CMP_FORMAT(type_name, "", op),\
actual, \
matcher->expected); \
else \
kunit_stream_add(stream, \
- "%d not "#op" %d", \
+ CMP_FORMAT(type_name, " not", op), \
actual, \
matcher->expected); \
\