structure: add tests of deserializing strings with escapes

Shows the issue described in
<https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/303#note_272629>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/303>
This commit is contained in:
Chris White 2020-12-24 14:06:29 -05:00 committed by Thibault Saunier
parent 5eba2b83b7
commit 9d2825ccff

View file

@ -223,6 +223,21 @@ GST_START_TEST (test_from_string)
ASSERT_CRITICAL (structure = gst_structure_from_string (s, NULL)); ASSERT_CRITICAL (structure = gst_structure_from_string (s, NULL));
fail_unless (structure == NULL, "Could not get structure from string %s", s); fail_unless (structure == NULL, "Could not get structure from string %s", s);
/* Test that escaping works both with and without a type */
s = "foo/bar, value=\"raven \\\"nevermore\\\"\"";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (G_VALUE_HOLDS_STRING (val));
gst_structure_free (structure);
s = "foo/bar, value=(string)\"raven \\\"nevermore\\\"\"";
structure = gst_structure_from_string (s, NULL);
fail_if (structure == NULL, "Could not get structure from string %s", s);
fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL);
fail_unless (G_VALUE_HOLDS_STRING (val));
gst_structure_free (structure);
/* make sure we bail out correctly in case of an error or if parsing fails */ /* make sure we bail out correctly in case of an error or if parsing fails */
s = "***foo***, abc=(boolean)false"; s = "***foo***, abc=(boolean)false";
structure = gst_structure_from_string (s, NULL); structure = gst_structure_from_string (s, NULL);