diff options
author | Peter Eisenmann <p3732@getgoogleoff.me> | 2023-04-16 21:20:59 +0200 |
---|---|---|
committer | Peter Eisenmann <peter.eisenmann@vigem.de> | 2023-05-02 13:42:54 +0200 |
commit | 3abf23b2a7958bbbed44da519bee681651053f9d (patch) | |
tree | d84a0a1ace2138f1e31ec208774c4fab9a7a9758 /glib/tests/timeout.c | |
parent | c86fde7e02bb942af2165fb7e7a1947469ed45bc (diff) | |
download | glib-3abf23b2a7958bbbed44da519bee681651053f9d.tar.gz |
add g_timeout_add_seconds_once
Add a new call combing behaviors of g_timeout_add_seconds and
g_timeout_add_once.
Diffstat (limited to 'glib/tests/timeout.c')
-rw-r--r-- | glib/tests/timeout.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/glib/tests/timeout.c b/glib/tests/timeout.c index acbb8f3e1..1ae3f3a34 100644 --- a/glib/tests/timeout.c +++ b/glib/tests/timeout.c @@ -20,6 +20,12 @@ unreachable_callback (gpointer data) } static void +unreachable_void_callback (gpointer data) +{ + g_assert_not_reached (); +} + +static void test_seconds (void) { guint id; @@ -52,6 +58,19 @@ test_seconds (void) } static void +test_seconds_once (void) +{ + /* Use the same principle as in test_seconds() */ + loop = g_main_loop_new (NULL, FALSE); + + g_timeout_add_once (2100, stop_waiting, NULL); + g_timeout_add_seconds_once (21475, unreachable_void_callback, NULL); + + g_main_loop_run (loop); + g_main_loop_unref (loop); +} + +static void test_weeks_overflow (void) { guint id; @@ -192,6 +211,7 @@ main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); g_test_add_func ("/timeout/seconds", test_seconds); + g_test_add_func ("/timeout/seconds-once", test_seconds_once); g_test_add_func ("/timeout/weeks-overflow", test_weeks_overflow); g_test_add_func ("/timeout/far-future-ready-time", test_far_future_ready_time); g_test_add_func ("/timeout/rounding", test_rounding); |