testsuite: Add tests for sections to filterlistmodel
authorBenjamin Otte <otte@redhat.com>
Sat, 26 Feb 2022 20:46:42 +0000 (21:46 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 9 May 2023 15:00:39 +0000 (17:00 +0200)
testsuite/gtk/filterlistmodel-exhaustive.c

index 084f1d301d9c055e30155bca9309f5a83da10be4..2af32072f58e507d56dfb036afb2283ff21a246b 100644 (file)
     } \
 }G_STMT_END
 
+#define assert_sections_equal(model1, model2) G_STMT_START{ \
+  guint _i, _n, _start1, _end1, _start2, _end2; \
+  g_assert_cmpint (g_list_model_get_n_items (G_LIST_MODEL (model1)), ==, g_list_model_get_n_items (G_LIST_MODEL (model2))); \
+  _n = g_list_model_get_n_items (G_LIST_MODEL (model1)); \
+  for (_i = 0; _i < _n; _i = _end1) \
+    { \
+      gtk_section_model_get_section (model1, _i, &_start1, &_end1); \
+      gtk_section_model_get_section (model2, _i, &_start2, &_end2); \
+      g_assert_cmpint (_start1, <, _end1); \
+      g_assert_cmpint (_start2, <, _end2); \
+      g_assert_cmpint (_start1, ==, _start2); \
+      g_assert_cmpint (_end1, ==, _end2); \
+      g_assert_cmpint (_i, ==, _start1); \
+      g_assert_cmpint (_end1, <=, _n); \
+    } \
+}G_STMT_END
+
 G_GNUC_UNUSED static char *
 model_to_string (GListModel *model)
 {
@@ -469,6 +486,7 @@ test_model_changes (gconstpointer model_id)
         {
           ensure_updated ();
           assert_model_equal (G_LIST_MODEL (flatten1), G_LIST_MODEL (model2));
+          assert_sections_equal (GTK_SECTION_MODEL (flatten1), GTK_SECTION_MODEL (model2));
         }
     }