[gtk/fix-maplistmodel: 2/2] Add more maplistmodel tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-maplistmodel: 2/2] Add more maplistmodel tests
- Date: Thu, 14 Jul 2022 20:53:33 +0000 (UTC)
commit 6024c712f9ec593941d390c5d0e29d5c7b227ce0
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 14 16:52:30 2022 -0400
Add more maplistmodel tests
Add some tests for adding and removing items.
testsuite/gtk/maplistmodel.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
---
diff --git a/testsuite/gtk/maplistmodel.c b/testsuite/gtk/maplistmodel.c
index 2ee0c4cc64..ac51ca12c9 100644
--- a/testsuite/gtk/maplistmodel.c
+++ b/testsuite/gtk/maplistmodel.c
@@ -295,6 +295,38 @@ test_set_map_func (void)
g_object_unref (map);
}
+static void
+test_add_items (void)
+{
+ GtkMapListModel *map;
+ GListStore *store;
+
+ store = new_store (1, 5, 1);
+ map = new_model (store);
+ assert_model (map, "2 4 6 8 10");
+ assert_changes (map, "");
+
+ add (store, 6);
+ assert_model (map, "2 4 6 8 10 12");
+ assert_changes (map, "+5*");
+}
+
+static void
+test_remove_items (void)
+{
+ GtkMapListModel *map;
+ GListStore *store;
+
+ store = new_store (1, 5, 1);
+ map = new_model (store);
+ assert_model (map, "2 4 6 8 10");
+ assert_changes (map, "");
+
+ g_list_store_remove (store, 2);
+ assert_model (map, "2 4 8 10");
+ assert_changes (map, "-2*");
+}
+
int
main (int argc, char *argv[])
{
@@ -308,6 +340,8 @@ main (int argc, char *argv[])
g_test_add_func ("/maplistmodel/create", test_create);
g_test_add_func ("/maplistmodel/set-model", test_set_model);
g_test_add_func ("/maplistmodel/set-map-func", test_set_map_func);
+ g_test_add_func ("/maplistmodel/add_items", test_add_items);
+ g_test_add_func ("/maplistmodel/remove_items", test_remove_items);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]