From b6c1d696a98b7fc4e691e8acc9f88b7bc8d57e9d Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 22 Jul 2014 21:13:50 +0200 Subject: [PATCH] gio: Add regression test for double array encoding https://bugzilla.gnome.org/show_bug.cgi?id=732754 --- gio/tests/gdbus-serialization.c | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c index f1b02144e..e31dbe41c 100644 --- a/gio/tests/gdbus-serialization.c +++ b/gio/tests/gdbus-serialization.c @@ -1048,6 +1048,39 @@ message_parse_empty_arrays_of_arrays (void) /* ---------------------------------------------------------------------------------------------------- */ +static void +test_double_array (void) +{ + GDBusConnection *conn; + GError *error = NULL; + GVariantBuilder builder; + + g_test_bug ("732754"); + + conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + g_assert_no_error (error); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ad")); + g_variant_builder_add (&builder, "d", (gdouble)0.0); + g_variant_builder_add (&builder, "d", (gdouble)8.0); + g_variant_builder_add (&builder, "d", (gdouble)22.0); + g_variant_builder_add (&builder, "d", (gdouble)0.0); + + /* + * Some versions of glib encoded arrays of doubles wrong. Here we send such + * a message and check that we didn't get bumped from the connection. + */ + g_dbus_connection_call_sync (conn, "org.freedesktop.DBus", "/path", + "org.freedesktop.DBus", "InvalidNonExistantMethod", + g_variant_new ("(@ad)", g_variant_builder_end (&builder)), + NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &error); + g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); + + g_object_unref (conn); +} + +/* ---------------------------------------------------------------------------------------------------- */ + int main (int argc, char *argv[]) @@ -1065,6 +1098,8 @@ main (int argc, g_test_add_func ("/gdbus/message-parse-empty-arrays-of-arrays", message_parse_empty_arrays_of_arrays); + g_test_add_func ("/gdbus/message-serialize/double-array", test_double_array); + return g_test_run(); }