test: Add test for serializing/deserializing NULL strings
authorOlivier Crête <olivier.crete@collabora.com>
Fri, 7 Apr 2017 17:49:29 +0000 (13:49 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Fri, 7 Apr 2017 17:49:55 +0000 (13:49 -0400)
tests/check/gst/gststructure.c

index a531717..7d3f2b4 100644 (file)
@@ -254,6 +254,24 @@ GST_START_TEST (test_to_from_string)
 
   gst_structure_free (st1);
   gst_structure_free (st2);
+
+  /* Test NULL strings */
+  st1 = gst_structure_new ("test", "mynullstr", G_TYPE_STRING, NULL, NULL);
+  fail_unless (st1 != NULL);
+  str = gst_structure_to_string (st1);
+  fail_unless (strcmp (str, "test, mynullstr=(string)NULL;") == 0,
+      "Failed to serialize to right string: %s", str);
+
+  st2 = gst_structure_from_string (str, NULL);
+  fail_unless (st2 != NULL);
+  g_free (str);
+
+  fail_unless (gst_structure_is_equal (st1, st2),
+      "Structures did not match:\n\tStructure 1: %" GST_PTR_FORMAT
+      "\n\tStructure 2: %" GST_PTR_FORMAT "\n", st1, st2);
+
+  gst_structure_free (st1);
+  gst_structure_free (st2);
 }
 
 GST_END_TEST;