[glib: 3/5] tests: Add more GListStore tests to get it too 100% coverage
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 3/5] tests: Add more GListStore tests to get it too 100% coverage
- Date: Wed, 5 Sep 2018 11:12:28 +0000 (UTC)
commit 7e33c50dd3705e1b8f43d6f26f4eb7f687e9bd30
Author: Philip Withnall <withnall endlessm com>
Date: Wed Sep 5 11:27:06 2018 +0100
tests: Add more GListStore tests to get it too 100% coverage
Signed-off-by: Philip Withnall <withnall endlessm com>
gio/tests/glistmodel.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
---
diff --git a/gio/tests/glistmodel.c b/gio/tests/glistmodel.c
index dcf571f29..b12251b96 100644
--- a/gio/tests/glistmodel.c
+++ b/gio/tests/glistmodel.c
@@ -21,6 +21,38 @@
#include <string.h>
+/* Test that constructing/getting/setting properties on a #GListStore works. */
+static void
+test_store_properties (void)
+{
+ GListStore *store = NULL;
+ GType item_type;
+
+ store = g_list_store_new (G_TYPE_MENU_ITEM);
+ g_object_get (store, "item-type", &item_type, NULL);
+ g_assert_cmpint (item_type, ==, G_TYPE_MENU_ITEM);
+
+ g_clear_object (&store);
+}
+
+/* Test that #GListStore rejects non-GObject item types. */
+static void
+test_store_non_gobjects (void)
+{
+ if (g_test_subprocess ())
+ {
+ /* We have to use g_object_new() since g_list_store_new() checks the item
+ * type. We want to check the property setter code works properly. */
+ g_object_new (G_TYPE_LIST_STORE, "item-type", G_TYPE_LONG, NULL);
+ return;
+ }
+
+ g_test_trap_subprocess (NULL, 0, 0);
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*WARNING*value * of type 'GType' is invalid or "
+ "out of range for property 'item-type'*");
+}
+
static void
test_store_boundaries (void)
{
@@ -736,6 +768,8 @@ int main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_bug_base ("https://bugzilla.gnome.org/");
+ g_test_add_func ("/glistmodel/store/properties", test_store_properties);
+ g_test_add_func ("/glistmodel/store/non-gobjects", test_store_non_gobjects);
g_test_add_func ("/glistmodel/store/boundaries", test_store_boundaries);
g_test_add_func ("/glistmodel/store/refcounts", test_store_refcounts);
g_test_add_func ("/glistmodel/store/sorted", test_store_sorted);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]