[Libosinfo] [libosinfo PATCH 14/31] tests: Add basic test for FeatureLink

Fabiano Fidêncio fidencio at redhat.com
Fri Nov 23 10:15:03 UTC 2018


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 .gitignore               |  1 +
 tests/Makefile.am        |  5 +++
 tests/test-featurelink.c | 71 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 tests/test-featurelink.c

diff --git a/.gitignore b/.gitignore
index 47f15db..0f36a99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ tests/test-db
 tests/test-devicelist
 tests/test-devicelinklist
 tests/test-feature
+tests/test-featurelink
 tests/test-featurelist
 tests/test-filter
 tests/test-hypervisorlist
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3f7f14c..b603b02 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,6 +9,7 @@ check_PROGRAMS = \
 	test-devicelist \
 	test-devicelinklist \
 	test-feature \
+	test-featurelink \
 	test-featurelist \
 	test-filter \
 	test-product \
@@ -57,6 +58,10 @@ test_feature_LDADD = $(COMMON_LDADD)
 test_feature_CFLAGS = $(COMMON_CFLAGS)
 test_feature_SOURCES = test-feature.c
 
+test_featurelink_LDADD = $(COMMON_LDADD)
+test_featurelink_CFLAGS = $(COMMON_CFLAGS)
+test_featurelink_SOURCES = test-featurelink.c
+
 test_featurelist_LDADD = $(COMMON_LDADD)
 test_featurelist_CFLAGS = $(COMMON_CFLAGS)
 test_featurelist_SOURCES = test-featurelist.c
diff --git a/tests/test-featurelink.c b/tests/test-featurelink.c
new file mode 100644
index 0000000..af2679d
--- /dev/null
+++ b/tests/test-featurelink.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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, see <http://www.gnu.org/licenses/>
+ *
+ * Authors:
+ *   Fabiano Fidêncio <fidencio at redhat.com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+
+
+static void
+test_featurelink_basic(void)
+{
+    OsinfoFeatureLink *featurelink;
+    OsinfoFeature *feature;
+    OsinfoEntity *entity;
+
+    feature = osinfo_feature_new("foo");
+
+    featurelink = osinfo_featurelink_new(feature);
+    g_assert_true(OSINFO_IS_FEATURELINK(featurelink));
+    g_assert_true(OSINFO_IS_LINK(featurelink));
+
+    entity = osinfo_link_get_target(OSINFO_LINK(featurelink));
+    g_assert_true(OSINFO_IS_FEATURE(entity));
+    g_assert_true(OSINFO_IS_ENTITY(entity));
+
+    g_assert_true(feature == OSINFO_FEATURE(entity));
+
+    g_object_unref(feature);
+    g_object_unref(featurelink);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+    g_test_init(&argc, &argv, NULL);
+
+    g_test_add_func("/featurelink/basic", test_featurelink_basic);
+
+    /* Upfront so we don't confuse valgrind */
+    osinfo_entity_get_type();
+    osinfo_feature_get_type();
+    osinfo_featurelink_get_type();
+    osinfo_link_get_type();
+
+    return g_test_run();
+}
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
2.19.1




More information about the Libosinfo mailing list