Diff between e1892e63c2e74fa997a99cbc3a26a9c60d652025 and d3a5f0f47d8874557e54486d3475a8dbcf451818

Changed Files

File Additions Deletions Status
unit/test-gobex.c +79 -0 added

Full Patch

diff --git a/unit/test-gobex.c b/unit/test-gobex.c
new file mode 100644
index 0000000..76e70d4
--- /dev/null
+++ b/unit/test-gobex.c
@@ -0,0 +1,79 @@
+/*
+ *
+ *  OBEX library with GLib integration
+ *
+ *  Copyright (C) 2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <unistd.h>
+
+#include <gobex/gobex.h>
+
+static void test_ref_unref(void)
+{
+	GObex *obex;
+	GIOChannel *io;
+
+	io = g_io_channel_unix_new(STDIN_FILENO);
+	g_assert(io != NULL);
+
+	obex = g_obex_new(io);
+
+	g_assert(obex != NULL);
+
+	obex = g_obex_ref(obex);
+
+	g_obex_unref(obex);
+	g_obex_unref(obex);
+}
+
+static void test_basic(void)
+{
+	GObex *obex;
+	GIOChannel *io;
+
+	io = g_io_channel_unix_new(STDIN_FILENO);
+	g_assert(io != NULL);
+
+	obex = g_obex_new(io);
+
+	g_assert(obex != NULL);
+
+	g_obex_unref(obex);
+}
+
+static void test_null_io(void)
+{
+	GObex *obex;
+
+	obex = g_obex_new(NULL);
+
+	g_assert(obex == NULL);
+}
+
+int main(int argc, char *argv[])
+{
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/gobex/null_io", test_null_io);
+	g_test_add_func("/gobex/basic", test_basic);
+	g_test_add_func("/gobex/ref_unref", test_ref_unref);
+
+	g_test_run();
+
+	return 0;
+}