Add a test for the previous fix
authorMatthias Clasen <mclasen@redhat.com>
Wed, 17 Oct 2012 01:16:50 +0000 (21:16 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 17 Oct 2012 01:21:25 +0000 (21:21 -0400)
Running tests/bytes with G_SLICE=always-malloc MALLOC_CHECK_=2
was aborting before.

glib/tests/bytes.c

index 83589fe..044450d 100644 (file)
@@ -316,6 +316,21 @@ test_to_array_non_malloc (void)
   g_byte_array_unref (array);
 }
 
+static void
+test_null (void)
+{
+  GBytes *bytes;
+  gpointer data;
+  gsize size;
+
+  bytes = g_bytes_new (NULL, 0);
+
+  data = g_bytes_unref_to_data (bytes, &size);
+
+  g_assert (data == NULL);
+  g_assert (size == 0);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -337,6 +352,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/bytes/to-array/transfered", test_to_array_transferred);
   g_test_add_func ("/bytes/to-array/two-refs", test_to_array_two_refs);
   g_test_add_func ("/bytes/to-array/non-malloc", test_to_array_non_malloc);
+  g_test_add_func ("/bytes/null", test_null);
 
   return g_test_run ();
 }