From d3a5f0f47d8874557e54486d3475a8dbcf451818 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Jun 2011 23:15:09 +0300 Subject: [PATCH] gobex: Add initial unit tests --- unit/test-gobex.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 unit/test-gobex.c diff --git a/unit/test-gobex.c b/unit/test-gobex.c new file mode 100644 index 000000000..76e70d41b --- /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 + +#include + +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; +} -- 2.47.3