diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2021-01-25 14:43:00 +0100 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2021-01-25 16:34:12 +0100 |
commit | 657d18fdbba4de3778d5a85fbe80852bcd60e719 (patch) | |
tree | bf2bc74e3142fb29cf1e36bcb6c6a23967263cdc /glib/tests/testing.c | |
parent | 3791add329c51f414be13cad3b52da43e94ca36f (diff) | |
download | glib-657d18fdbba4de3778d5a85fbe80852bcd60e719.tar.gz |
gtestutils: Add g_test_get_path() API
I found myself wanting to know the test that is currently being run,
where e.g. __func__ would be inconvenient to use, because e.g. the place
the string was needed was not in the test case function. Using __func__
also relies on the test function itself containing the whole path, while
loosing the "/" information that is part of the test path.
Diffstat (limited to 'glib/tests/testing.c')
-rw-r--r-- | glib/tests/testing.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/glib/tests/testing.c b/glib/tests/testing.c index 29551b9d2..7faa7b5ec 100644 --- a/glib/tests/testing.c +++ b/glib/tests/testing.c @@ -843,6 +843,18 @@ test_subprocess_timed_out (void) g_assert_true (g_test_trap_reached_timeout ()); } +static void +test_path_first (void) +{ + g_assert_cmpstr (g_test_get_path (), ==, "/misc/path/first"); +} + +static void +test_path_second (void) +{ + g_assert_cmpstr (g_test_get_path (), ==, "/misc/path/second"); +} + static const char *argv0; static void @@ -1595,6 +1607,9 @@ main (int argc, g_test_add_func ("/misc/incomplete", test_incomplete); g_test_add_func ("/misc/timeout", test_subprocess_timed_out); + g_test_add_func ("/misc/path/first", test_path_first); + g_test_add_func ("/misc/path/second", test_path_second); + g_test_add_func ("/tap", test_tap); g_test_add_func ("/tap/summary", test_tap_summary); |