From c08d58d778138fc07ffab4bc1d59c8d3d5e43abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 27 Nov 2019 17:07:06 +0100 Subject: [PATCH 1/2] glib-autocleanups: Define the cleanup function for GDate Add an autoptr test as well. --- glib/glib-autocleanups.h | 1 + glib/tests/autoptr.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/glib/glib-autocleanups.h b/glib/glib-autocleanups.h index b71101f2d..acd38a7ab 100644 --- a/glib/glib-autocleanups.h +++ b/glib/glib-autocleanups.h @@ -47,6 +47,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBytes, g_bytes_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GChecksum, g_checksum_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDateTime, g_date_time_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDate, g_date_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDir, g_dir_close) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GError, g_error_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHashTable, g_hash_table_unref) diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c index 14b95a9cc..788d05c5e 100644 --- a/glib/tests/autoptr.c +++ b/glib/tests/autoptr.c @@ -69,6 +69,13 @@ test_g_checksum (void) g_assert_nonnull (val); } +static void +test_g_date (void) +{ + g_autoptr(GDate) val = g_date_new (); + g_assert_nonnull (val); +} + static void test_g_date_time (void) { @@ -704,6 +711,7 @@ main (int argc, gchar *argv[]) g_test_add_func ("/autoptr/g_bookmark_file", test_g_bookmark_file); g_test_add_func ("/autoptr/g_bytes", test_g_bytes); g_test_add_func ("/autoptr/g_checksum", test_g_checksum); + g_test_add_func ("/autoptr/g_date", test_g_date); g_test_add_func ("/autoptr/g_date_time", test_g_date_time); g_test_add_func ("/autoptr/g_dir", test_g_dir); g_test_add_func ("/autoptr/g_error", test_g_error); From d407b9e70560db0fd34ef2c2c760b1c9b7119d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 27 Nov 2019 17:09:09 +0100 Subject: [PATCH 2/2] testgdate: Exit with failure if there are not passed tests --- tests/testgdate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testgdate.c b/tests/testgdate.c index 18022bc74..9e2ace22f 100644 --- a/tests/testgdate.c +++ b/tests/testgdate.c @@ -8,6 +8,7 @@ #include "glib.h" #include +#include #include #include #include @@ -506,7 +507,7 @@ g_print ("testing %d years\n", n_check_years); g_print("\n%u tests passed, %u failed\n",passed, notpassed); - return 0; + return (notpassed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }