[libgfbgraph/wip/rishi/mr-1: 5/5] tests/autoptr: Add g_autoptr test



commit 4f381aaa7937c8d378dc8a7e93bbd999a8873373
Author: Yi-Soo An <yisooan gmail com>
Date:   Tue Jul 24 14:07:16 2018 +0900

    tests/autoptr: Add g_autoptr test
    
    https://gitlab.gnome.org/GNOME/libgfbgraph/merge_requests/1

 tests/Makefile.am |  4 ++-
 tests/autoptr.c   | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index efe441e..6bd4ea2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-TESTS = gtestutils
+TESTS = gtestutils autoptr
 
 AM_CPPFLAGS = -I$(top_srcdir) $(LIBGFBGRAPH_CFLAGS)
 AM_LDFLAGS = $(top_builddir)/gfbgraph/libgfbgraph-@API_VERSION@.la $(LIBGFBGRAPH_LIBS)
@@ -7,4 +7,6 @@ noinst_PROGRAMS = $(TESTS)
 
 gtestutils_SOURCES = gtestutils.c
 
+autoptr_SOURCES = autoptr.c
+
 -include $(top_srcdir)/git.mk
diff --git a/tests/autoptr.c b/tests/autoptr.c
new file mode 100644
index 0000000..182fc28
--- /dev/null
+++ b/tests/autoptr.c
@@ -0,0 +1,76 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-  */
+/*
+ * libgfbgraph - GObject library for Facebook Graph API
+ * Copyright (C) 2018 Yi-Soo An <yisooan gmail com>
+ *
+ * GFBGraph is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GFBGraph is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GFBGraph.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This code is based on glib/tests/autoptr.c
+ */
+
+#include <glib.h>
+
+#include <gfbgraph/gfbgraph.h>
+
+static void
+test_gfbgraph_album (void)
+{
+        g_autoptr (GFBGraphAlbum) val = NULL;
+
+        val = gfbgraph_album_new ();
+        g_assert_nonnull (val);
+}
+
+static void
+test_gfbgraph_node (void)
+{
+        g_autoptr (GFBGraphNode) val = NULL;
+
+        val = gfbgraph_node_new ();
+        g_assert_nonnull (val);
+}
+
+static void
+test_gfbgraph_photo (void)
+{
+        g_autoptr (GFBGraphPhoto) val = NULL;
+
+        val = gfbgraph_photo_new ();
+        g_assert_nonnull (val);
+}
+
+static void
+test_gfbgraph_user (void)
+{
+        g_autoptr (GFBGraphUser) val = NULL;
+
+        val = gfbgraph_user_new ();
+        g_assert_nonnull (val);
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+        g_test_init (&argc, &argv, NULL);
+
+        g_test_add_func ("/GFBGraph/autoptr/Album", test_gfbgraph_album);
+        g_test_add_func ("/GFBGraph/autoptr/Node", test_gfbgraph_node);
+        g_test_add_func ("/GFBGraph/autoptr/Photo", test_gfbgraph_photo);
+        g_test_add_func ("/GFBGraph/autoptr/User", test_gfbgraph_user);
+
+        return g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]