diff options
author | Yi-Soo An <yisooan@gmail.com> | 2018-07-12 16:52:12 +0900 |
---|---|---|
committer | Victor Toso <me@victortoso.com> | 2018-07-13 11:46:36 +0200 |
commit | e2c649364b0e1c05e1177417d16c4374f6b6a5d3 (patch) | |
tree | 207cdb8953d9dead5525d4ea7b3d6e35e691f716 | |
parent | 18ae3196dff76711f30c131d25ede2b5ccee4bb1 (diff) | |
download | grilo-e2c649364b0e1c05e1177417d16c4374f6b6a5d3.tar.gz |
tests: Add g_autoptr tests
The tests are for the classes
- GrlNetWc
- GrlData
- GrlMedia
- GrlRelatedKeys
- GrlCaps
- GrlOperationOptions
- GrlPlugin
https://gitlab.gnome.org/GNOME/grilo/merge_requests/10
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/autoptr.c | 101 |
2 files changed, 105 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 01f01b3..4df8cbc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,6 +20,10 @@ TEST_PROGS = registry registry_SOURCES = registry.c registry_LDADD = $(progs_ldadd) +TEST_PROGS += autoptr +autoptr_SOURCES = autoptr.c +autoptr_LDADD = $(progs_ldadd) + if BUILD_GRILO_NET TEST_PROGS += lib-net lib_net_SOURCES = lib-net.c diff --git a/tests/autoptr.c b/tests/autoptr.c new file mode 100644 index 0000000..faef432 --- /dev/null +++ b/tests/autoptr.c @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2018 Yi-Soo An <yisooan@gmail.com> + * + * This library 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; version 2.1 of + * the License, or (at your option) any later version. + * + * This library 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/* + * This code is based on glib/tests/autoptr.c + */ + +#include <glib.h> + +#include <grilo.h> +#include <net/grl-net.h> + +static void +test_grl_net_wc (void) +{ + g_autoptr (GrlNetWc) val = grl_net_wc_new (); + g_assert_nonnull (val); +} + +static void +test_grl_data (void) +{ + g_autoptr (GrlData) val = grl_data_new (); + g_assert_nonnull (val); +} + +static void +test_grl_related_keys (void) +{ + g_autoptr (GrlRelatedKeys) val = grl_related_keys_new (); + g_assert_nonnull (val); +} + +static void +test_grl_media (void) +{ + g_autoptr (GrlMedia) val = grl_media_new (); + g_assert_nonnull (val); +} + +static void +test_grl_caps (void) +{ + g_autoptr (GrlCaps) val = grl_caps_new (); + g_assert_nonnull (val); +} + +static void +test_grl_operation_options (void) +{ + g_autoptr (GrlOperationOptions) val = grl_operation_options_new (NULL); + g_assert_nonnull (val); +} + +static void +test_grl_plugin (void) +{ + g_autoptr (GrlPlugin) val = NULL; + + val = GRL_PLUGIN (g_object_new (GRL_TYPE_PLUGIN, NULL)); + + g_assert_nonnull (val); +} + +int +main (int argc, + char *argv[]) +{ + g_test_init (&argc, &argv, NULL); + + grl_init (&argc, &argv); + + g_test_add_func ("/autoptr/grl_net_wc", test_grl_net_wc); + + g_test_add_func ("/autoptr/grl_data", test_grl_data); + g_test_add_func ("/autoptr/grl_media", test_grl_media); + g_test_add_func ("/autoptr/grl_related_keys", test_grl_related_keys); + + g_test_add_func ("/autoptr/grl_caps", test_grl_caps); + g_test_add_func ("/autoptr/grl_operation_options", test_grl_operation_options); + g_test_add_func ("/autoptr/grl_plugin", test_grl_plugin); + + return g_test_run (); +} |