mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-29 04:14:11 +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:
@@ -35,6 +35,14 @@ test_skip (void)
|
||||
g_test_skip ("not enough tea");
|
||||
}
|
||||
|
||||
static void
|
||||
test_skip_printf (void)
|
||||
{
|
||||
const char *beverage = "coffee";
|
||||
|
||||
g_test_skip_printf ("not enough %s", beverage);
|
||||
}
|
||||
|
||||
static void
|
||||
test_fail (void)
|
||||
{
|
||||
@@ -47,6 +55,14 @@ test_incomplete (void)
|
||||
g_test_incomplete ("mind reading not implemented yet");
|
||||
}
|
||||
|
||||
static void
|
||||
test_incomplete_printf (void)
|
||||
{
|
||||
const char *operation = "telekinesis";
|
||||
|
||||
g_test_incomplete_printf ("%s not implemented yet", operation);
|
||||
}
|
||||
|
||||
static void
|
||||
test_summary (void)
|
||||
{
|
||||
@@ -91,10 +107,18 @@ main (int argc,
|
||||
{
|
||||
g_test_add_func ("/skip", test_skip);
|
||||
}
|
||||
else if (g_strcmp0 (argv1, "skip-printf") == 0)
|
||||
{
|
||||
g_test_add_func ("/skip-printf", test_skip_printf);
|
||||
}
|
||||
else if (g_strcmp0 (argv1, "incomplete") == 0)
|
||||
{
|
||||
g_test_add_func ("/incomplete", test_incomplete);
|
||||
}
|
||||
else if (g_strcmp0 (argv1, "incomplete-printf") == 0)
|
||||
{
|
||||
g_test_add_func ("/incomplete-printf", test_incomplete_printf);
|
||||
}
|
||||
else if (g_strcmp0 (argv1, "fail") == 0)
|
||||
{
|
||||
g_test_add_func ("/fail", test_fail);
|
||||
|
Reference in New Issue
Block a user