[glib: 3/4] tests: Port various tests to use g_assert_cmpvariant()



commit d289ef449b9cb25a09c31d8c8e51c90bfbe0b687
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Dec 14 15:04:11 2018 +0000

    tests: Port various tests to use g_assert_cmpvariant()
    
    This should improve test error reporting a little.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gio/tests/actions.c             |  2 +-
 gio/tests/gdbus-message.c       |  2 +-
 gio/tests/gdbus-serialization.c | 13 +------------
 gio/tests/gdbus-test-codegen.c  |  2 +-
 glib/tests/gvariant.c           | 30 +++++++++++++++---------------
 5 files changed, 19 insertions(+), 30 deletions(-)
---
diff --git a/gio/tests/actions.c b/gio/tests/actions.c
index 4c7cd3a05..1e175c625 100644
--- a/gio/tests/actions.c
+++ b/gio/tests/actions.c
@@ -515,7 +515,7 @@ test_parse_detailed (void)
           expected = g_variant_parse (NULL, testcases[i].expected_target, NULL, NULL, NULL);
           g_assert (expected);
 
-          g_assert (g_variant_equal (expected, target));
+          g_assert_cmpvariant (expected, target);
           g_variant_unref (expected);
           g_variant_unref (target);
         }
diff --git a/gio/tests/gdbus-message.c b/gio/tests/gdbus-message.c
index 88a9c5d86..278ccc474 100644
--- a/gio/tests/gdbus-message.c
+++ b/gio/tests/gdbus-message.c
@@ -128,7 +128,7 @@ message_copy (void)
       copy_val = g_dbus_message_get_header (m, m_headers[n]);
       g_assert (m_val != NULL);
       g_assert (copy_val != NULL);
-      g_assert (g_variant_equal (m_val, copy_val));
+      g_assert_cmpvariant (m_val, copy_val);
     }
   g_assert_cmpint (n, >, 0); /* make sure we actually compared headers etc. */
   g_assert_cmpint (copy_headers[n], ==, 0);
diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c
index 6446d940a..89a2e97d5 100644
--- a/gio/tests/gdbus-serialization.c
+++ b/gio/tests/gdbus-serialization.c
@@ -526,7 +526,6 @@ check_serialization (GVariant *value,
   GError *error;
   DBusError dbus_error;
   gchar *s;
-  gchar *s1;
   guint n;
 
   message = g_dbus_message_new ();
@@ -618,17 +617,7 @@ check_serialization (GVariant *value,
       else
         {
           g_assert (g_dbus_message_get_body (recovered_message) != NULL);
-          if (!g_variant_equal (g_dbus_message_get_body (recovered_message), value))
-            {
-              s = g_variant_print (g_dbus_message_get_body (recovered_message), TRUE);
-              s1 = g_variant_print (value, TRUE);
-              g_printerr ("Recovered value:\n%s\ndoes not match given value\n%s\n",
-                          s,
-                          s1);
-              g_free (s);
-              g_free (s1);
-              g_assert_not_reached ();
-            }
+          g_assert_cmpvariant (g_dbus_message_get_body (recovered_message), value);
         }
       g_object_unref (recovered_message);
       g_free (blob);
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index dfc40ad32..e2207f504 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -933,7 +933,7 @@ check_bar_proxy (FooiGenBar *proxy,
   g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_objpaths), ==,
                     g_strv_length ((gchar **) array_of_objpaths));
   g_assert_nonnull (ret_array_of_signatures);
-  g_assert_true (g_variant_equal (ret_array_of_signatures, array_of_signatures));
+  g_assert_cmpvariant (ret_array_of_signatures, array_of_signatures);
   g_assert_nonnull (ret_array_of_bytestrings);
   g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_bytestrings), ==,
                     g_strv_length ((gchar **) array_of_bytestrings));
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index bf86b3c88..33caaf04a 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -4406,67 +4406,67 @@ test_equal (void)
 
   a = untrusted (g_variant_new_byte (5));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_int16 (G_MININT16));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_uint16 (0));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_int32 (G_MININT32));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_uint32 (0));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_int64 (G_MININT64));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_uint64 (0));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_double (G_MINDOUBLE));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_string ("abc"));
-  g_assert_true (g_variant_equal (a, a));
+  g_assert_cmpvariant (a, a);
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_object_path ("/abc"));
-  g_assert_true (g_variant_equal (a, a));
+  g_assert_cmpvariant (a, a);
   b = g_variant_get_normal_form (a);
   a = untrusted (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_signature ("g"));
-  g_assert_true (g_variant_equal (a, a));
+  g_assert_cmpvariant (a, a);
   b = g_variant_get_normal_form (a);
   a = untrusted (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
   a = untrusted (g_variant_new_boolean (FALSE));
   b = g_variant_get_normal_form (a);
-  g_assert_true (g_variant_equal (a, b));
+  g_assert_cmpvariant (a, b);
   g_variant_unref (a);
   g_variant_unref (b);
 }


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