[at-spi2-core: 4/10] atk_test_document_get_attributes: do not assume the ordering of keys in a GHashTable




commit 0704d6710ba5626ed5bea9761f82ca697d78a773
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jul 4 18:07:56 2022 -0500

    atk_test_document_get_attributes: do not assume the ordering of keys in a GHashTable

 tests/at-spi2-atk/atk_test_document.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/tests/at-spi2-atk/atk_test_document.c b/tests/at-spi2-atk/atk_test_document.c
index afe8f99a..af219b4b 100644
--- a/tests/at-spi2-atk/atk_test_document.c
+++ b/tests/at-spi2-atk/atk_test_document.c
@@ -76,15 +76,24 @@ atk_test_document_get_attributes (gpointer fixture, gconstpointer user_data)
   gpointer key, value;
   g_hash_table_iter_init (&iter, attr);
 
-  gchar *valid_keys[] = {"atspi1", "atspi2"};
-  gchar *valid_values[] = {"test1", "test2"};
+  while (g_hash_table_iter_next (&iter, &key, &value))
+    {
+      const char *key_str = key;
+      const char *value_str = value;
 
-  int i=0;
-  while (g_hash_table_iter_next (&iter, &key, &value)) {
-    g_assert_cmpstr (valid_keys[i], ==, (gchar *)key);
-    g_assert_cmpstr (valid_values[i], ==, (gchar *)value);
-    ++i;
-  }
+      if (strcmp (key_str, "atspi1") == 0)
+        {
+          g_assert_cmpstr (value_str, ==, "test1");
+        }
+      else if (strcmp (key_str, "atspi2") == 0)
+        {
+          g_assert_cmpstr (value_str, ==, "test2");
+        }
+      else
+        {
+          g_assert_not_reached ();
+        }
+    }
 }
 
 void


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