mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-04 23:28:05 +02:00
marshal test: test dbus_message_demarshal_bytes_needed
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38120
This commit is contained in:
parent
bf421f5a30
commit
b92612945a
1 changed files with 38 additions and 0 deletions
|
|
@ -200,6 +200,40 @@ test_endian (Fixture *f,
|
|||
g_assert_cmpint (len, ==, BLOB_LENGTH + 4);
|
||||
}
|
||||
|
||||
static void
|
||||
test_needed (Fixture *f,
|
||||
gconstpointer arg)
|
||||
{
|
||||
const gchar *blob = arg;
|
||||
|
||||
/* We need at least 16 bytes to know how long the message is - that's just
|
||||
* a fact of the D-Bus protocol. */
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, 0), ==, 0);
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, 15), ==, 0);
|
||||
/* This is enough that we should be able to tell how much we need. */
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, 16), ==, BLOB_LENGTH);
|
||||
/* The header is 32 bytes long (here), so that's another interesting
|
||||
* boundary. */
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, 31), ==, BLOB_LENGTH);
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, 32), ==, BLOB_LENGTH);
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, 33), ==, BLOB_LENGTH);
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, BLOB_LENGTH - 1), ==,
|
||||
BLOB_LENGTH);
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, BLOB_LENGTH), ==,
|
||||
BLOB_LENGTH);
|
||||
g_assert_cmpint (
|
||||
dbus_message_demarshal_bytes_needed (blob, sizeof (be_blob)), ==,
|
||||
BLOB_LENGTH);
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (Fixture *f,
|
||||
gconstpointer arg G_GNUC_UNUSED)
|
||||
|
|
@ -215,6 +249,10 @@ main (int argc,
|
|||
|
||||
g_test_add ("/demarshal/le", Fixture, le_blob, setup, test_endian, teardown);
|
||||
g_test_add ("/demarshal/be", Fixture, be_blob, setup, test_endian, teardown);
|
||||
g_test_add ("/demarshal/needed/le", Fixture, le_blob, setup, test_needed,
|
||||
teardown);
|
||||
g_test_add ("/demarshal/needed/be", Fixture, be_blob, setup, test_needed,
|
||||
teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue