mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
tests: Add many autoptr tests
I love Emacs keyboard macros, used them to convert the list of defines cleverly into a list of tests, then iterated and filled in the necessary constructor arguments.
This commit is contained in:
@@ -489,6 +489,12 @@ gdbus_serialization_SOURCES = \
|
||||
gdbus-tests.c
|
||||
endif
|
||||
|
||||
if HAVE_GCC
|
||||
test_programs += \
|
||||
autoptr \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# The resources test is a bit more complicated...
|
||||
|
||||
|
23
gio/tests/autoptr.c
Normal file
23
gio/tests/autoptr.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <gio/gio.h>
|
||||
|
||||
static void
|
||||
test_autoptr (void)
|
||||
{
|
||||
g_autoptr(GFile) p = g_file_new_for_path ("/blah");
|
||||
g_autoptr(GInetAddress) a = g_inet_address_new_from_string ("127.0.0.1");
|
||||
g_autofree gchar *path = g_file_get_path (p);
|
||||
g_autofree gchar *istr = g_inet_address_to_string (a);
|
||||
|
||||
g_assert_cmpstr (path, ==, "/blah");
|
||||
g_assert_cmpstr (istr, ==, "127.0.0.1");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/autoptr/autoptr", test_autoptr);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
Reference in New Issue
Block a user