gtestutils: add g_assert_cmpmem()

Add a test macro to compare two buffers (which are not already known
to be the same length) for equality.

https://bugzilla.gnome.org/show_bug.cgi?id=754283
This commit is contained in:
Dan Winship
2014-12-03 05:57:29 -05:00
parent 367f36d630
commit 9f2e3f6b72
17 changed files with 120 additions and 103 deletions

View File

@@ -100,15 +100,10 @@ compare_output (SetupData *data)
gsize size;
gpointer written;
written = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->data_stream));
size = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (data->data_stream));
/* compare the size of the data */
g_assert_cmpint (size, ==, data->expected_size);
written = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->data_stream));
/* compare the data itself */
g_assert (memcmp (written, data->expected_output, size) == 0);
g_assert_cmpmem (written, size, data->expected_output, data->expected_size);
}
static void