mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-15 08:46:18 +01:00
Add a testcase for g_markup_collect cleanup
Taken from https://bugzilla.gnome.org/show_bug.cgi?id=644428. The test is currently failing.
This commit is contained in:
parent
fccaadcdab
commit
949b7c3428
@ -9,6 +9,7 @@
|
|||||||
* See the included COPYING file for more information.
|
* See the included COPYING file for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -169,6 +170,48 @@ test_collect (gconstpointer d)
|
|||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define XML "<element a='1' b='2' c='3'/>"
|
||||||
|
|
||||||
|
static void
|
||||||
|
start_element (GMarkupParseContext *context,
|
||||||
|
const gchar *element_name,
|
||||||
|
const gchar **attribute_names,
|
||||||
|
const gchar **attribute_values,
|
||||||
|
gpointer user_data,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
/* Omitting "c" attribute intentionally to trigger crash. */
|
||||||
|
g_markup_collect_attributes (element_name,
|
||||||
|
attribute_names,
|
||||||
|
attribute_values,
|
||||||
|
error,
|
||||||
|
G_MARKUP_COLLECT_STRING, "a", NULL,
|
||||||
|
G_MARKUP_COLLECT_STRING, "b", NULL,
|
||||||
|
G_MARKUP_COLLECT_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GMarkupParser cleanup_parser = {
|
||||||
|
start_element
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_cleanup (void)
|
||||||
|
{
|
||||||
|
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
||||||
|
{
|
||||||
|
GMarkupParseContext *context;
|
||||||
|
|
||||||
|
context = g_markup_parse_context_new (&cleanup_parser, 0, NULL, NULL);
|
||||||
|
g_markup_parse_context_parse (context, XML, -1, NULL);
|
||||||
|
g_markup_parse_context_end_parse (context, NULL);
|
||||||
|
g_markup_parse_context_free (context);
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*assertion `context->state != STATE_ERROR' failed*");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -184,5 +227,7 @@ main (int argc, char **argv)
|
|||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_test_add_func ("/markup/collect/cleanup", test_cleanup);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user