[Libosinfo] [libosinfo PATCH 03/31] tests: Add basic test for OsinfoFeature
Fabiano Fidêncio
fidencio at redhat.com
Fri Nov 23 10:14:52 UTC 2018
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
.gitignore | 1 +
tests/Makefile.am | 5 ++++
tests/test-feature.c | 58 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 tests/test-feature.c
diff --git a/.gitignore b/.gitignore
index 951c8a4..1fb00d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ tests/test-list
tests/test-db
tests/test-devicelist
tests/test-devicelinklist
+tests/test-feature
tests/test-filter
tests/test-hypervisorlist
tests/test-install-script
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 00dcc9c..aa71e77 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,6 +7,7 @@ check_PROGRAMS = \
test-list \
test-devicelist \
test-devicelinklist \
+ test-feature \
test-filter \
test-product \
test-os \
@@ -50,6 +51,10 @@ test_device_LDADD = $(COMMON_LDADD)
test_device_CFLAGS = $(COMMON_CFLAGS)
test_device_SOURCES = test-device.c
+test_feature_LDADD = $(COMMON_LDADD)
+test_feature_CFLAGS = $(COMMON_CFLAGS)
+test_feature_SOURCES = test-feature.c
+
test_filter_LDADD = $(COMMON_LDADD)
test_filter_CFLAGS = $(COMMON_CFLAGS)
test_filter_SOURCES = test-filter.c
diff --git a/tests/test-feature.c b/tests/test-feature.c
new file mode 100644
index 0000000..e509a0a
--- /dev/null
+++ b/tests/test-feature.c
@@ -0,0 +1,58 @@
+/*
+ * 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_basic(void)
+{
+ OsinfoFeature *feature = osinfo_feature_new("foo");
+
+ g_assert_true(OSINFO_IS_FEATURE(feature));
+ g_assert_cmpstr(osinfo_entity_get_id(OSINFO_ENTITY(feature)), ==, "foo");
+ g_assert_cmpstr(osinfo_feature_get_name(feature), ==, "foo");
+
+ g_object_unref(feature);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/feature/basic", test_basic);
+
+ /* Upfront so we don't confuse valgrind */
+ osinfo_feature_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