[gtk/wip/baedert/for-master: 168/180] listbox test: Only compare values for rows we have




commit 30712c01bea94a869aae204273d4b14fc0506474
Author: Timm Bäder <mail baedert org>
Date:   Thu Oct 15 06:07:12 2020 +0200

    listbox test: Only compare values for rows we have
    
    This shouldn't happen, but don't compare 100 values if we didnt' get 100
    values from the listbox.

 testsuite/gtk/listbox.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/testsuite/gtk/listbox.c b/testsuite/gtk/listbox.c
index a5c895235c..815cf4b031 100644
--- a/testsuite/gtk/listbox.c
+++ b/testsuite/gtk/listbox.c
@@ -26,6 +26,7 @@ check_sorted (GtkListBox *list)
   GtkWidget *row, *label;
   int res[100];
   int index, value;
+  int n_rows = 0;
   int i;
 
   for (row = gtk_widget_get_first_child (GTK_WIDGET (list));
@@ -39,10 +40,11 @@ check_sorted (GtkListBox *list)
       label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
       value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "data"));
       res[index] = value;
+      n_rows++;
     }
 
-  for (i = 1; i < 100; i++)
-    g_assert (res[i - 1] <= res[i]);
+  for (i = 1; i < n_rows; i++)
+    g_assert_cmpint (res[i - 1], <=, res[i]);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]