mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-26 02:48:54 +02:00
gtestutils: Allow skipping tests with a printf-style message
Forming the g_test_skip() message from printf-style arguments seems common enough to deserve a convenience function. g_test_incomplete() is mechanically almost equivalent to g_test_skip() (the semantics are different but the implementation is very similar), so give it a similar mechanism for symmetry. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
@@ -2434,6 +2434,29 @@ g_test_incomplete (const gchar *msg)
|
||||
test_run_msg = g_strdup (msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_test_incomplete_printf:
|
||||
* @format: the format string
|
||||
* @...: printf-like arguments to @format
|
||||
*
|
||||
* Equivalent to g_test_incomplete(), but the explanation is formatted
|
||||
* as if by g_strdup_printf().
|
||||
*
|
||||
* Since: 2.70
|
||||
*/
|
||||
void
|
||||
g_test_incomplete_printf (const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
test_run_success = G_TEST_RUN_INCOMPLETE;
|
||||
va_start (args, format);
|
||||
g_free (test_run_msg);
|
||||
test_run_msg = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_test_skip:
|
||||
* @msg: (nullable): explanation
|
||||
@@ -2457,6 +2480,29 @@ g_test_skip (const gchar *msg)
|
||||
test_run_msg = g_strdup (msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_test_skip_printf:
|
||||
* @format: the format string
|
||||
* @...: printf-like arguments to @format
|
||||
*
|
||||
* Equivalent to g_test_skip(), but the explanation is formatted
|
||||
* as if by g_strdup_printf().
|
||||
*
|
||||
* Since: 2.70
|
||||
*/
|
||||
void
|
||||
g_test_skip_printf (const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
test_run_success = G_TEST_RUN_SKIPPED;
|
||||
va_start (args, format);
|
||||
g_free (test_run_msg);
|
||||
test_run_msg = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_test_failed:
|
||||
*
|
||||
|
Reference in New Issue
Block a user