mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
tests: value: test buffer serialisation/deserialisation more thoroughly
Tests data/strings as well, not just that we received something non-NULL back.
This commit is contained in:
parent
433581c05a
commit
4e437a564d
1 changed files with 10 additions and 3 deletions
|
@ -28,6 +28,8 @@ GST_START_TEST (test_deserialize_buffer)
|
|||
{
|
||||
GValue value = { 0 };
|
||||
GstBuffer *buf;
|
||||
guint8 data[8];
|
||||
guint64 val;
|
||||
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
fail_unless (gst_value_deserialize (&value, "1234567890abcdef"));
|
||||
|
@ -39,6 +41,10 @@ GST_START_TEST (test_deserialize_buffer)
|
|||
buf = gst_value_get_buffer (&value);
|
||||
ASSERT_MINI_OBJECT_REFCOUNT (buf, "buffer", 1);
|
||||
|
||||
gst_buffer_extract (buf, 0, data, 8);
|
||||
val = GST_READ_UINT64_BE (data);
|
||||
fail_unless_equals_uint64 (val, G_GUINT64_CONSTANT (0x1234567890abcdef));
|
||||
|
||||
/* cleanup */
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
@ -51,13 +57,13 @@ GST_START_TEST (test_serialize_buffer)
|
|||
GValue value = { 0 };
|
||||
GstBuffer *buf;
|
||||
gchar *serialized;
|
||||
static const char *buf_data = "1234567890abcdef";
|
||||
const guint8 buf_data[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
|
||||
gint len;
|
||||
|
||||
len = strlen (buf_data);
|
||||
len = sizeof (buf_data);
|
||||
buf = gst_buffer_new_and_alloc (len);
|
||||
|
||||
gst_buffer_fill (buf, 0, buf_data, len);
|
||||
gst_buffer_fill (buf, 0, (gchar *) buf_data, len);
|
||||
|
||||
ASSERT_MINI_OBJECT_REFCOUNT (buf, "buffer", 1);
|
||||
|
||||
|
@ -70,6 +76,7 @@ GST_START_TEST (test_serialize_buffer)
|
|||
serialized = gst_value_serialize (&value);
|
||||
GST_DEBUG ("serialized buffer to %s", serialized);
|
||||
fail_unless (serialized != NULL);
|
||||
fail_unless_equals_string (serialized, "1234567890abcdef");
|
||||
|
||||
/* refcount should not change */
|
||||
ASSERT_MINI_OBJECT_REFCOUNT (buf, "buffer", 1);
|
||||
|
|
Loading…
Reference in a new issue