summaryrefslogtreecommitdiff
path: root/gio/tests
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-02-23 08:32:36 -0500
committerColin Walters <walters@verbum.org>2015-02-23 10:40:40 -0500
commit0550708ca7b615ab9e0df96ded43d18653f33ac2 (patch)
treed0105fa1d2e958429531a381a9708798acb975d7 /gio/tests
parent1b348a876f84342bb3a197fadd249f8ce95abfeb (diff)
downloadglib-0550708ca7b615ab9e0df96ded43d18653f33ac2.tar.gz
glib-0550708ca7b615ab9e0df96ded43d18653f33ac2.tar.bz2
glib-0550708ca7b615ab9e0df96ded43d18653f33ac2.zip
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.
Diffstat (limited to 'gio/tests')
-rw-r--r--gio/tests/Makefile.am6
-rw-r--r--gio/tests/autoptr.c23
2 files changed, 29 insertions, 0 deletions
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index f958ef9c5..5817d182f 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -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...
diff --git a/gio/tests/autoptr.c b/gio/tests/autoptr.c
new file mode 100644
index 000000000..9ff1428ea
--- /dev/null
+++ b/gio/tests/autoptr.c
@@ -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 ();
+}