[libgdata/libgdata-0-7] tests: Convert all the tests to use the new XML tree comparison function



commit 666b66dfd30d3924847e264573aa79bc068aa895
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Dec 11 14:38:00 2010 +0000

    tests: Convert all the tests to use the new XML tree comparison function
    
    This fixes them to work correctly regardless of the GLib version.

 gdata/tests/calendar.c  |   15 +--
 gdata/tests/contacts.c  |   12 +--
 gdata/tests/general.c   |  260 +++++++++++-----------------------------------
 gdata/tests/picasaweb.c |   59 ++++++-----
 gdata/tests/youtube.c   |   15 +--
 5 files changed, 102 insertions(+), 259 deletions(-)
---
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index aef4a41..3e11e97 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -234,7 +234,6 @@ test_insert_simple (gconstpointer service)
 	GDataGDWho *who;
 	GDataGDWhen *when;
 	GTimeVal start_time, end_time;
-	gchar *xml;
 	GError *error = NULL;
 
 	event = gdata_calendar_event_new (NULL);
@@ -256,8 +255,7 @@ test_insert_simple (gconstpointer service)
 	g_object_unref (when);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (event,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 			 	"xmlns:gd='http://schemas.google.com/g/2005' "
@@ -278,7 +276,6 @@ test_insert_simple (gconstpointer service)
 			 		"valueString='John Smith\342\200\275'/>"
 			 	"<gd:where valueString='Rolling Lawn Courts'/>"
 			 "</entry>");
-	g_free (xml);
 
 	/* Insert the event */
 	new_event = gdata_calendar_service_insert_event (GDATA_CALENDAR_SERVICE (service), event, NULL, &error);
@@ -299,7 +296,6 @@ test_xml_dates (void)
 	GList *times, *i;
 	GDataGDWhen *when;
 	gint64 _time;
-	gchar *xml;
 	GError *error = NULL;
 
 	event = GDATA_CALENDAR_EVENT (gdata_parsable_new_from_xml (GDATA_TYPE_CALENDAR_EVENT,
@@ -357,8 +353,7 @@ test_xml_dates (void)
 	g_assert (gdata_gd_when_get_reminders (when) == NULL);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (event,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 			 	"xmlns:gd='http://schemas.google.com/g/2005' "
@@ -375,7 +370,6 @@ test_xml_dates (void)
 			 	"<gd:when startTime='2009-04-17T15:00:00Z'/>"
 			 	"<gd:when startTime='2009-04-27' endTime='2009-05-06'/>"
 			 "</entry>");
-	g_free (xml);
 
 	g_object_unref (event);
 }
@@ -570,7 +564,6 @@ test_acls_insert_rule (gconstpointer service)
 	GDataCategory *category;
 	GDataLink *_link;
 	GList *categories;
-	gchar *xml;
 	gint64 edited;
 	GError *error = NULL;
 
@@ -587,8 +580,7 @@ test_acls_insert_rule (gconstpointer service)
 	g_assert_cmpstr (scope_value, ==, "darcy gmail com");
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (rule));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (rule,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 			 	"xmlns:gd='http://schemas.google.com/g/2005' "
@@ -598,7 +590,6 @@ test_acls_insert_rule (gconstpointer service)
 				"<gAcl:role value='http://schemas.google.com/gCal/2005#editor'/>"
 				"<gAcl:scope type='user' value='darcy gmail com'/>"
 			 "</entry>");
-	g_free (xml);
 
 	/* Insert the rule */
 	_link = gdata_entry_look_up_link (GDATA_ENTRY (calendar), GDATA_LINK_ACCESS_CONTROL_LIST);
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index a257cfb..b58cac0 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -162,7 +162,7 @@ test_insert_simple (gconstpointer service)
 	GDataGContactCalendar *calendar;
 	GDataGContactExternalID *external_id;
 	GDataGContactLanguage *language;
-	gchar *xml, *nickname, *billing_information, *directory_server, *gender, *initials, *maiden_name, *mileage, *occupation;
+	gchar *nickname, *billing_information, *directory_server, *gender, *initials, *maiden_name, *mileage, *occupation;
 	gchar *priority, *sensitivity, *short_name, *subject;
 	GList *list;
 	GDate date, *date2;
@@ -336,8 +336,7 @@ test_insert_simple (gconstpointer service)
 	g_free (subject);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (contact));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (contact,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 				"xmlns:gd='http://schemas.google.com/g/2005' "
@@ -390,7 +389,6 @@ test_insert_simple (gconstpointer service)
 				"<gContact:shortName>Jon</gContact:shortName>"
 				"<gContact:subject>Charity work</gContact:subject>"
 			 "</entry>");
-	g_free (xml);
 
 	/* Insert the contact */
 	new_contact = gdata_contacts_service_insert_contact (GDATA_CONTACTS_SERVICE (service), contact, NULL, &error);
@@ -663,7 +661,7 @@ test_insert_group (gconstpointer service)
 	GHashTable *properties;
 	gint64 edited;
 	gboolean deleted;
-	gchar *system_group_id, *xml;
+	gchar *system_group_id;
 	GError *error = NULL;
 
 	group = gdata_contacts_group_new (NULL);
@@ -701,8 +699,7 @@ test_insert_group (gconstpointer service)
 	g_free (system_group_id);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (group));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (group,
 		"<?xml version='1.0' encoding='UTF-8'?>"
 		"<entry xmlns='http://www.w3.org/2005/Atom' "
 		       "xmlns:gd='http://schemas.google.com/g/2005' "
@@ -713,7 +710,6 @@ test_insert_group (gconstpointer service)
 			"<category term='http://schemas.google.com/contact/2008#group' scheme='http://schemas.google.com/g/2005#kind'/>"
 			"<gd:extendedProperty name='foobar'>barfoo</gd:extendedProperty>"
 		"</entry>");
-	g_free (xml);
 
 	/* Insert the group */
 	new_group = gdata_contacts_service_insert_group (GDATA_CONTACTS_SERVICE (service), group, NULL, &error);
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index d527886..82fb57b 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -237,14 +237,12 @@ test_entry_get_xml (void)
 	gdata_entry_set_content_uri (entry, "http://bar.com/";);
 
 	/* Check the generated XML's OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (entry));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (entry,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>"
 				 "<title type='text'>Testing title &amp; escaping</title>"
 				 "<content type='text/plain' src='http://bar.com/'/>"
 			 "</entry>");
-	g_free (xml);
 
 	/* Reset the content */
 	gdata_entry_set_content (entry, "This is some sample content testing, amongst other things, <markup> & odd charactersâ?½");
@@ -294,8 +292,7 @@ test_entry_get_xml (void)
 	g_object_unref (author);
 
 	/* Check the generated XML's OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (entry));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (entry,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>"
 				 "<title type='text'>Testing title &amp; escaping</title>"
@@ -314,6 +311,7 @@ test_entry_get_xml (void)
 			 "</entry>");
 
 	/* Check again by re-parsing the XML to a GDataEntry */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (entry));
 	entry2 = GDATA_ENTRY (gdata_parsable_new_from_xml (GDATA_TYPE_ENTRY, xml, -1, &error));
 	g_assert_no_error (error);
 	g_assert (GDATA_IS_ENTRY (entry2));
@@ -461,7 +459,6 @@ static void
 test_entry_parse_xml (void)
 {
 	GDataEntry *entry;
-	gchar *xml;
 	GError *error = NULL;
 
 	/* Create an entry from XML with unhandled elements */
@@ -480,8 +477,7 @@ test_entry_parse_xml (void)
 	g_clear_error (&error);
 
 	/* Now check the outputted XML from the entry still has the unhandled elements */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (entry));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (entry,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:ns='http://example.com/'>"
 				"<title type='text'>Testing unhandled XML</title>"
@@ -492,7 +488,6 @@ test_entry_parse_xml (void)
 				"<barfoo shizzle=\"zing\"/>"
 				"<ns:barfoo shizzle=\"zing\" fo=\"shizzle\">How about some charactersâ?½</ns:barfoo>"
 			 "</entry>");
-	g_free (xml);
 	g_object_unref (entry);
 }
 
@@ -960,8 +955,7 @@ test_access_rule_get_xml (void)
 	gdata_access_rule_set_scope (rule, GDATA_ACCESS_SCOPE_USER, "foo example com");
 
 	/* Check the generated XML's OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (rule));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (rule,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 			 "xmlns:gd='http://schemas.google.com/g/2005' "
@@ -974,6 +968,7 @@ test_access_rule_get_xml (void)
 			 "</entry>");
 
 	/* Check again by re-parsing the XML to a GDataAccessRule */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (rule));
 	rule2 = GDATA_ACCESS_RULE (gdata_parsable_new_from_xml (GDATA_TYPE_ACCESS_RULE, xml, -1, &error));
 	g_assert_no_error (error);
 	g_assert (GDATA_IS_ACCESS_RULE (rule2));
@@ -1125,7 +1120,7 @@ static void
 test_atom_author (void)
 {
 	GDataAuthor *author, *author2;
-	gchar *xml, *name, *uri, *email_address;
+	gchar *name, *uri, *email_address;
 	GError *error = NULL;
 
 	author = GDATA_AUTHOR (gdata_parsable_new_from_xml (GDATA_TYPE_AUTHOR,
@@ -1154,15 +1149,13 @@ test_atom_author (void)
 	g_object_unref (author2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (author));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (author,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<author xmlns='http://www.w3.org/2005/Atom'>"
 				"<name>John Smöth</name>"
 				"<uri>http://example.com/</uri>"
 				"<email>john example com</email>"
 			 "</author>");
-	g_free (xml);
 
 	/* Check the properties */
 	g_object_get (G_OBJECT (author),
@@ -1229,7 +1222,7 @@ static void
 test_atom_category (void)
 {
 	GDataCategory *category, *category2;
-	gchar *xml, *term, *scheme, *label;
+	gchar *term, *scheme, *label;
 	GError *error = NULL;
 
 	category = GDATA_CATEGORY (gdata_parsable_new_from_xml (GDATA_TYPE_CATEGORY,
@@ -1254,12 +1247,10 @@ test_atom_category (void)
 	g_object_unref (category2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (category,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<category xmlns='http://www.w3.org/2005/Atom' "
 				"term='jokes' scheme='http://foobar.com#categories' label='Jokes &amp; Trivia'/>");
-	g_free (xml);
 
 	/* Check the properties */
 	g_object_get (G_OBJECT (category),
@@ -1301,14 +1292,12 @@ test_atom_category (void)
 	g_clear_error (&error);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (category,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<category xmlns='http://www.w3.org/2005/Atom' term='documentary'>"
 				"<foobar/>"
 				"<shizzle/>"
 			 "</category>");
-	g_free (xml);
 	g_object_unref (category);
 }
 
@@ -1404,7 +1393,7 @@ static void
 test_atom_link (void)
 {
 	GDataLink *link1, *link2;
-	gchar *xml, *uri, *relation_type, *content_type, *language, *title;
+	gchar *uri, *relation_type, *content_type, *language, *title;
 	gint length;
 	GError *error = NULL;
 
@@ -1438,12 +1427,10 @@ test_atom_link (void)
 	g_object_unref (link2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (link1));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (link1,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<link xmlns='http://www.w3.org/2005/Atom' href='http://example.com/' title='All About Angle Brackets: &lt;, &gt;' "
 				"rel='http://test.com#link-type' type='text/plain' hreflang='de' length='2000'/>");
-	g_free (xml);
 
 	/* Set some of the properties */
 	g_object_set (G_OBJECT (link1),
@@ -1495,12 +1482,10 @@ test_atom_link (void)
 	g_assert (gdata_link_get_length (link1) == -1);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (link1));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (link1,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<link xmlns='http://www.w3.org/2005/Atom' href='http://shizzle.com' rel='http://www.iana.org/assignments/relation/alternate'>"
 				"Test Content<foobar/></link>");
-	g_free (xml);
 	g_object_unref (link1);
 }
 
@@ -1584,7 +1569,6 @@ static void
 test_gd_email_address (void)
 {
 	GDataGDEmailAddress *email, *email2;
-	gchar *xml;
 	GError *error = NULL;
 
 	email = GDATA_GD_EMAIL_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_EMAIL_ADDRESS,
@@ -1612,13 +1596,11 @@ test_gd_email_address (void)
 	g_object_unref (email2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (email));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (email,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:email xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' address='fubar gmail com' "
 				"rel='http://schemas.google.com/g/2005#home' label='Personal &amp; Private' displayName='&lt;John Smith&gt;' "
 				"primary='true'/>");
-	g_free (xml);
 	g_object_unref (email);
 
 	/* Now parse an address with less information available */
@@ -1636,12 +1618,10 @@ test_gd_email_address (void)
 	g_assert (gdata_gd_email_address_is_primary (email) == FALSE);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (email));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (email,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:email xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' address='test example com' "
 				"primary='false'/>");
-	g_free (xml);
 	g_object_unref (email);
 }
 
@@ -1649,7 +1629,6 @@ static void
 test_gd_email_address_escaping (void)
 {
 	GDataGDEmailAddress *email;
-	gchar *xml;
 
 	g_test_bug ("630350");
 
@@ -1657,13 +1636,11 @@ test_gd_email_address_escaping (void)
 	gdata_gd_email_address_set_display_name (email, "<John Smith>");
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (email));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (email,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:email xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                           "address='Fubar &lt;fubar gmail com&gt;' rel='http://schemas.google.com/g/2005#home?foo&amp;bar' "
 	                           "label='Personal &amp; Private' displayName='&lt;John Smith&gt;' primary='true'/>");
-	g_free (xml);
 	g_object_unref (email);
 }
 
@@ -1671,7 +1648,6 @@ static void
 test_gd_im_address (void)
 {
 	GDataGDIMAddress *im, *im2;
-	gchar *xml;
 	GError *error = NULL;
 
 	im = GDATA_GD_IM_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_IM_ADDRESS,
@@ -1698,13 +1674,11 @@ test_gd_im_address (void)
 	g_object_unref (im2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (im,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:im xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"address='foo bar msn com' protocol='http://schemas.google.com/g/2005#MSN' "
 				"rel='http://schemas.google.com/g/2005#home' primary='true'/>");
-	g_free (xml);
 	g_object_unref (im);
 
 	/* Now parse an address with less information available */
@@ -1722,12 +1696,10 @@ test_gd_im_address (void)
 	g_assert (gdata_gd_im_address_is_primary (im) == FALSE);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (im,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:im xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' address='foo baz example com' "
 				"label='Other &amp; Miscellaneous' primary='false'/>");
-	g_free (xml);
 	g_object_unref (im);
 }
 
@@ -1735,19 +1707,16 @@ static void
 test_gd_im_address_escaping (void)
 {
 	GDataGDIMAddress *im;
-	gchar *xml;
 
 	im = gdata_gd_im_address_new ("Fubar <fubar gmail com>", GDATA_GD_IM_PROTOCOL_GOOGLE_TALK "?foo&bar", GDATA_GD_IM_ADDRESS_HOME "?foo&bar",
 	                              "Personal & Private", TRUE);
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (im,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:im xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                        "address='Fubar &lt;fubar gmail com&gt;' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK?foo&amp;bar' "
 	                        "rel='http://schemas.google.com/g/2005#home?foo&amp;bar' label='Personal &amp; Private' primary='true'/>");
-	g_free (xml);
 	g_object_unref (im);
 }
 
@@ -1755,7 +1724,6 @@ static void
 test_gd_name (void)
 {
 	GDataGDName *name, *name2;
-	gchar *xml;
 	GError *error = NULL;
 
 	name = GDATA_GD_NAME (gdata_parsable_new_from_xml (GDATA_TYPE_GD_NAME,
@@ -1792,8 +1760,7 @@ test_gd_name (void)
 	g_object_unref (name2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (name));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (name,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:name xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>"
 				"<gd:givenName>Brian</gd:givenName>"
@@ -1803,7 +1770,6 @@ test_gd_name (void)
 				"<gd:nameSuffix>ABC</gd:nameSuffix>"
 				"<gd:fullName>Mr Brian Charles Blessed, ABC</gd:fullName>"
 			 "</gd:name>");
-	g_free (xml);
 	g_object_unref (name);
 
 	/* Now parse an address with less information available */
@@ -1822,13 +1788,11 @@ test_gd_name (void)
 	g_assert (gdata_gd_name_get_full_name (name) == NULL);
 
 	/* Check the outputted XML is still correct */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (name));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (name,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:name xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>"
 				"<gd:givenName>Bob</gd:givenName>"
 			 "</gd:name>");
-	g_free (xml);
 	g_object_unref (name);
 }
 
@@ -1837,7 +1801,6 @@ test_gd_organization (void)
 {
 	GDataGDOrganization *org, *org2;
 	GDataGDWhere *location;
-	gchar *xml;
 	GError *error = NULL;
 
 	org = GDATA_GD_ORGANIZATION (gdata_parsable_new_from_xml (GDATA_TYPE_GD_ORGANIZATION,
@@ -1878,8 +1841,7 @@ test_gd_organization (void)
 	g_object_unref (org2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (org,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:organization xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"rel='http://schemas.google.com/g/2005#work' label='Work &amp; Occupation' primary='true'>"
@@ -1890,7 +1852,6 @@ test_gd_organization (void)
 				"<gd:orgSymbol>FOO</gd:orgSymbol>"
 				"<gd:where valueString='Test location'/>"
 			 "</gd:organization>");
-	g_free (xml);
 	g_object_unref (org);
 
 	/* Now parse an organization with less information available */
@@ -1912,11 +1873,9 @@ test_gd_organization (void)
 	g_assert (gdata_gd_organization_get_location (org) == NULL);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (org,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:organization xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' primary='false'/>");
-	g_free (xml);
 	g_object_unref (org);
 }
 
@@ -1924,7 +1883,6 @@ static void
 test_gd_organization_escaping (void)
 {
 	GDataGDOrganization *org;
-	gchar *xml;
 
 	org = gdata_gd_organization_new ("Steptoe & Son", "Title & Stuff", GDATA_GD_ORGANIZATION_WORK "?foo&bar", "Personal & Private", TRUE);
 	gdata_gd_organization_set_department (org, "Department & Stuff");
@@ -1932,8 +1890,7 @@ test_gd_organization_escaping (void)
 	gdata_gd_organization_set_symbol (org, "<&>");
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (org,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:organization xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                                  "rel='http://schemas.google.com/g/2005#work?foo&amp;bar' label='Personal &amp; Private' primary='true'>"
@@ -1943,7 +1900,6 @@ test_gd_organization_escaping (void)
 	                         "<gd:orgJobDescription>Escaping &lt;brackets&gt;.</gd:orgJobDescription>"
 	                         "<gd:orgSymbol>&lt;&amp;&gt;</gd:orgSymbol>"
 	                 "</gd:organization>");
-	g_free (xml);
 	g_object_unref (org);
 }
 
@@ -1951,7 +1907,6 @@ static void
 test_gd_phone_number (void)
 {
 	GDataGDPhoneNumber *phone, *phone2;
-	gchar *xml;
 	GError *error = NULL;
 
 	phone = GDATA_GD_PHONE_NUMBER (gdata_parsable_new_from_xml (GDATA_TYPE_GD_PHONE_NUMBER,
@@ -1979,13 +1934,11 @@ test_gd_phone_number (void)
 	g_object_unref (phone2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (phone,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:phoneNumber xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"uri='tel:+12065551212' rel='http://schemas.google.com/g/2005#mobile' label='Personal &amp; business calls only' "
 				"primary='false'>+1 206 555 1212</gd:phoneNumber>");
-	g_free (xml);
 
 	/* Check we trim whitespace properly, and respect Unicode characters */
 	gdata_gd_phone_number_set_number (phone, "  	 0123456 (789) ëxt 300  ");
@@ -2007,12 +1960,10 @@ test_gd_phone_number (void)
 	g_assert (gdata_gd_phone_number_is_primary (phone) == FALSE);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (phone,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:phoneNumber xmlns='http://www.w3.org/2005/Atom' "
 				"xmlns:gd='http://schemas.google.com/g/2005' primary='false'>(425) 555-8080 ext. 72585</gd:phoneNumber>");
-	g_free (xml);
 	g_object_unref (phone);
 }
 
@@ -2020,19 +1971,16 @@ static void
 test_gd_phone_number_escaping (void)
 {
 	GDataGDPhoneNumber *phone;
-	gchar *xml;
 
 	phone = gdata_gd_phone_number_new ("0123456789 <54>", GDATA_GD_PHONE_NUMBER_WORK_MOBILE "?foo&bar", "Personal & Private",
 	                                   "tel:+012345678954?foo&bar", TRUE);
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (phone,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:phoneNumber xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                                 "uri='tel:+012345678954?foo&amp;bar' rel='http://schemas.google.com/g/2005#work_mobile?foo&amp;bar' "
 	                                 "label='Personal &amp; Private' primary='true'>0123456789 &lt;54&gt;</gd:phoneNumber>");
-	g_free (xml);
 	g_object_unref (phone);
 }
 
@@ -2040,7 +1988,6 @@ static void
 test_gd_postal_address (void)
 {
 	GDataGDPostalAddress *postal, *postal2;
-	gchar *xml;
 	GError *error = NULL;
 
 	postal = GDATA_GD_POSTAL_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_POSTAL_ADDRESS,
@@ -2079,8 +2026,7 @@ test_gd_postal_address (void)
 	g_object_unref (postal2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (postal));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (postal,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:structuredPostalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"rel='http://schemas.google.com/g/2005#home' label='Home &amp; Safe House' primary='true'>"
@@ -2089,7 +2035,6 @@ test_gd_postal_address (void)
 				"<gd:postcode>NY 10036</gd:postcode>"
 				"<gd:country code='US'>United States</gd:country>"
 			 "</gd:structuredPostalAddress>");
-	g_free (xml);
 
 	/* Check we trim whitespace properly, and respect Unicode characters */
 	gdata_gd_postal_address_set_address (postal, "  	 Schöne Grü�e Stra�e\nGermany  ");
@@ -2111,12 +2056,10 @@ test_gd_postal_address (void)
 	g_assert (gdata_gd_postal_address_is_primary (postal) == FALSE);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (postal));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (postal,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:structuredPostalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' primary='false'>"
 				 "<gd:street>f</gd:street></gd:structuredPostalAddress>");
-	g_free (xml);
 	g_object_unref (postal);
 }
 
@@ -2124,7 +2067,6 @@ static void
 test_gd_postal_address_escaping (void)
 {
 	GDataGDPostalAddress *address;
-	gchar *xml;
 
 	address = gdata_gd_postal_address_new (GDATA_GD_POSTAL_ADDRESS_WORK "?foo&bar", "Personal & Private", TRUE);
 	gdata_gd_postal_address_set_address (address, "<address>");
@@ -2142,8 +2084,7 @@ test_gd_postal_address_escaping (void)
 	gdata_gd_postal_address_set_country (address, "<foo>", "<bar>");
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (address));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (address,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:structuredPostalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                                             "rel='http://schemas.google.com/g/2005#work?foo&amp;bar' label='Personal &amp; Private' "
@@ -2161,7 +2102,6 @@ test_gd_postal_address_escaping (void)
 	                         "<gd:country code='&lt;bar&gt;'>&lt;foo&gt;</gd:country>"
 	                         "<gd:formattedAddress>&lt;address&gt;</gd:formattedAddress>"
 	                 "</gd:structuredPostalAddress>");
-	g_free (xml);
 	g_object_unref (address);
 }
 
@@ -2169,7 +2109,6 @@ static void
 test_gd_reminder (void)
 {
 	GDataGDReminder *reminder, *reminder2;
-	gchar *xml;
 	gint64 _time;
 	GError *error = NULL;
 
@@ -2185,11 +2124,9 @@ test_gd_reminder (void)
 	g_assert_cmpint (gdata_gd_reminder_get_relative_time (reminder), ==, 15 * 24 * 60);
 
 	/* Check the outputted XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (reminder));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (reminder,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:reminder xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' minutes='21600'/>");
-	g_free (xml);
 	g_object_unref (reminder);
 
 	/* Try again with a different property */
@@ -2242,12 +2179,10 @@ test_gd_reminder (void)
 	g_object_unref (reminder2);
 
 	/* Check the outputted XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (reminder));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (reminder,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:reminder xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"absoluteTime='2005-06-07T00:55:00Z' method='alert'/>");
-	g_free (xml);
 	g_object_unref (reminder);
 }
 
@@ -2255,17 +2190,14 @@ static void
 test_gd_reminder_escaping (void)
 {
 	GDataGDReminder *reminder;
-	gchar *xml;
 
 	reminder = gdata_gd_reminder_new (GDATA_GD_REMINDER_ALERT "?foo&bar", -1, 15);
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (reminder));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (reminder,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:reminder xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                              "minutes='15' method='alert?foo&amp;bar'/>");
-	g_free (xml);
 	g_object_unref (reminder);
 }
 
@@ -2274,7 +2206,6 @@ test_gd_when (void)
 {
 	GDataGDWhen *when, *when2;
 	GDataGDReminder *reminder;
-	gchar *xml;
 	GList *reminders;
 	gint64 _time, _time2;
 	GError *error = NULL;
@@ -2306,12 +2237,10 @@ test_gd_when (void)
 	g_object_unref (when2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (when,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:when xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' startTime='2005-06-07T01:00:00Z' "
 				"endTime='2005-06-07T02:00:00Z'/>");
-	g_free (xml);
 	g_object_unref (when);
 
 	/* Now parse a time with different information */
@@ -2345,8 +2274,7 @@ test_gd_when (void)
 	g_object_unref (reminder);
 
 	/* Check the outputted XML is correct */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (when,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:when xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' startTime='2005-06-06' "
 				"endTime='2005-06-08' valueString='This weekend'>"
@@ -2354,7 +2282,6 @@ test_gd_when (void)
 				"<gd:reminder absoluteTime='2005-06-06T00:00:00Z' method='alert'/>"
 				"<foobar/>"
 			 "</gd:when>");
-	g_free (xml);
 	g_object_unref (when);
 }
 
@@ -2362,7 +2289,6 @@ static void
 test_gd_when_escaping (void)
 {
 	GDataGDWhen *when;
-	gchar *xml;
 	GTimeVal start_time;
 
 	g_time_val_from_iso8601 ("2005-06-07T01:00:00Z", &start_time);
@@ -2370,12 +2296,10 @@ test_gd_when_escaping (void)
 	gdata_gd_when_set_value_string (when, "Value string & stuff!");
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (when,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:when xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                          "startTime='2005-06-07T01:00:00Z' valueString='Value string &amp; stuff!'/>");
-	g_free (xml);
 	g_object_unref (when);
 }
 
@@ -2383,7 +2307,6 @@ static void
 test_gd_where (void)
 {
 	GDataGDWhere *where, *where2;
-	gchar *xml;
 	GError *error = NULL;
 
 	where = GDATA_GD_WHERE (gdata_parsable_new_from_xml (GDATA_TYPE_GD_WHERE,
@@ -2408,13 +2331,11 @@ test_gd_where (void)
 	g_object_unref (where2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (where,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:where xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"label='New York Location &lt;videoconference&gt;' rel='http://schemas.google.com/g/2005#event.alternate' "
 				"valueString='Metropolis'/>");
-	g_free (xml);
 	g_object_unref (where);
 
 	/* Now parse a place with less information available */
@@ -2430,12 +2351,10 @@ test_gd_where (void)
 	g_assert (gdata_gd_where_get_label (where) == NULL);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (where,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:where xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 				"valueString='Google Cafeteria &lt;Building 40&gt;'/>");
-	g_free (xml);
 	g_object_unref (where);
 }
 
@@ -2443,18 +2362,15 @@ static void
 test_gd_where_escaping (void)
 {
 	GDataGDWhere *where;
-	gchar *xml;
 
 	where = gdata_gd_where_new (GDATA_GD_WHERE_EVENT "?foo&bar", "Value string & stuff!", "<label>");
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (where,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:where xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                           "label='&lt;label&gt;' rel='http://schemas.google.com/g/2005#event?foo&amp;bar' "
 	                           "valueString='Value string &amp; stuff!'/>");
-	g_free (xml);
 	g_object_unref (where);
 }
 
@@ -2462,7 +2378,6 @@ static void
 test_gd_who (void)
 {
 	GDataGDWho *who, *who2;
-	gchar *xml;
 	GError *error = NULL;
 
 	who = GDATA_GD_WHO (gdata_parsable_new_from_xml (GDATA_TYPE_GD_WHO,
@@ -2487,12 +2402,10 @@ test_gd_who (void)
 	g_object_unref (who2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (who));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (who,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:who xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' email='liz example com' "
 				"rel='http://schemas.google.com/g/2005#message.to' valueString='Elizabeth'/>");
-	g_free (xml);
 	g_object_unref (who);
 
 	/* Now parse a place with less information available */
@@ -2508,11 +2421,9 @@ test_gd_who (void)
 	g_assert (gdata_gd_who_get_email_address (who) == NULL);
 
 	/* Check the outputted XML contains the unknown XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (who));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (who,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gd:who xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'/>");
-	g_free (xml);
 	g_object_unref (who);
 }
 
@@ -2520,18 +2431,15 @@ static void
 test_gd_who_escaping (void)
 {
 	GDataGDWho *who;
-	gchar *xml;
 
 	who = gdata_gd_who_new (GDATA_GD_WHO_EVENT_ATTENDEE "?foo&bar", "Value string & stuff!", "John Smith <john smith gmail com>");
 
 	/* Check the outputted XML is escaped properly */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (who));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (who,
 	                 "<?xml version='1.0' encoding='UTF-8'?>"
 	                 "<gd:who xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 	                         "email='John Smith &lt;john smith gmail com&gt;' rel='http://schemas.google.com/g/2005#event.attendee?foo&amp;bar' "
 	                         "valueString='Value string &amp; stuff!'/>");
-	g_free (xml);
 	g_object_unref (who);
 }
 
@@ -2539,7 +2447,6 @@ static void
 test_media_category (void)
 {
 	GDataMediaCategory *category;
-	gchar *xml;
 	GError *error = NULL;
 
 	category = GDATA_MEDIA_CATEGORY (gdata_parsable_new_from_xml (GDATA_TYPE_MEDIA_CATEGORY,
@@ -2556,14 +2463,12 @@ test_media_category (void)
 	g_assert_cmpstr (gdata_media_category_get_label (category), ==, "Ace Ventura - Pet & Detective");
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (category,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<media:category xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' "
 				"scheme='http://dmoz.org' "
 				"label='Ace Ventura - Pet &amp; Detective'>Arts/Movies/Titles/A/Ace_Ventura_Series/Ace_Ventura_-_Pet_Detective"
 				"</media:category>");
-	g_free (xml);
 	g_object_unref (category);
 
 	/* Now parse one with less information available */
@@ -2579,12 +2484,10 @@ test_media_category (void)
 	g_assert (gdata_media_category_get_label (category) == NULL);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (category,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<media:category xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' "
 				"scheme='http://video.search.yahoo.com/mrss/category_schema'>foo</media:category>");
-	g_free (xml);
 	g_object_unref (category);
 }
 
@@ -2680,7 +2583,6 @@ test_media_group (void)
 {
 	GDataMediaGroup *group;
 	GList *contents, *thumbnails;
-	gchar *xml;
 	GError *error = NULL;
 
 	group = GDATA_MEDIA_GROUP (gdata_parsable_new_from_xml (GDATA_TYPE_MEDIA_GROUP,
@@ -2729,8 +2631,7 @@ test_media_group (void)
 	g_assert (GDATA_IS_MEDIA_THUMBNAIL (thumbnails->next->data));
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (group));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (group,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<media:group xmlns:media='http://search.yahoo.com/mrss/'>"
 				"<media:title>Foobar â?? shizzle!</media:title>"
@@ -2748,7 +2649,6 @@ test_media_group (void)
 				"<media:thumbnail url='http://www.foo.com/keyframe.jpg' width='75' height='50' time='12:05:01.123'/>"
 				"<media:thumbnail url='http://www.foo.com/keyframe0.jpg' time='00:00:00'/>"
 			 "</media:group>");
-	g_free (xml);
 
 	/* Check setting things works */
 	gdata_media_group_set_title (group, "Test title");
@@ -2794,10 +2694,9 @@ test_media_group (void)
 	g_assert (gdata_media_group_get_thumbnails (group) == NULL);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (group));
-	g_assert_cmpstr (xml, ==, "<?xml version='1.0' encoding='UTF-8'?>"
+	gdata_test_assert_xml (group,
+		"<?xml version='1.0' encoding='UTF-8'?>"
 	                          "<media:group xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/'></media:group>");
-	g_free (xml);
 	g_object_unref (group);
 }
 #endif
@@ -2844,7 +2743,6 @@ static void
 test_gcontact_calendar (void)
 {
 	GDataGContactCalendar *calendar, *calendar2;
-	gchar *xml;
 	GError *error = NULL;
 
 	calendar = GDATA_GCONTACT_CALENDAR (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_CALENDAR,
@@ -2870,12 +2768,10 @@ test_gcontact_calendar (void)
 	g_object_unref (calendar2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (calendar));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (calendar,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:calendarLink xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"href='http://calendar.com/' rel='work' primary='true'/>");
-	g_free (xml);
 	g_object_unref (calendar);
 
 	/* Now parse a calendar with less information available */
@@ -2893,12 +2789,10 @@ test_gcontact_calendar (void)
 	g_assert (gdata_gcontact_calendar_is_primary (calendar) == FALSE);
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (calendar));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (calendar,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:calendarLink xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"href='http://example.com/' label='&lt;a&gt;' primary='false'/>");
-	g_free (xml);
 	g_object_unref (calendar);
 }
 
@@ -2932,7 +2826,6 @@ test_gcontact_event (void)
 {
 	GDataGContactEvent *event, *event2;
 	GDate date;
-	gchar *xml;
 	GError *error = NULL;
 
 	event = GDATA_GCONTACT_EVENT (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_EVENT,
@@ -2958,14 +2851,12 @@ test_gcontact_event (void)
 	g_object_unref (event2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (event,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:event xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 			   "xmlns:gContact='http://schemas.google.com/contact/2008' rel='other'>"
 				"<gd:when startTime='2004-03-12'/>"
 			 "</gContact:event>");
-	g_free (xml);
 	g_object_unref (event);
 
 	/* Now parse an event with different information available */
@@ -2988,14 +2879,12 @@ test_gcontact_event (void)
 	g_assert_cmpstr (gdata_gcontact_event_get_label (event), ==, "<a>");
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (event,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:event xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
 			   "xmlns:gContact='http://schemas.google.com/contact/2008' label='&lt;a&gt;'>"
 				"<gd:when startTime='2000-01-01'/>"
 			 "</gContact:event>");
-	g_free (xml);
 	g_object_unref (event);
 }
 
@@ -3030,7 +2919,6 @@ static void
 test_gcontact_external_id (void)
 {
 	GDataGContactExternalID *id, *id2;
-	gchar *xml;
 	GError *error = NULL;
 
 	id = GDATA_GCONTACT_EXTERNAL_ID (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_EXTERNAL_ID,
@@ -3054,12 +2942,10 @@ test_gcontact_external_id (void)
 	g_object_unref (id2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (id));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (id,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:externalId xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"value='5' rel='account'/>");
-	g_free (xml);
 	g_object_unref (id);
 
 	/* Now parse an ID with less information available */
@@ -3075,12 +2961,10 @@ test_gcontact_external_id (void)
 	g_assert_cmpstr (gdata_gcontact_external_id_get_label (id), ==, "<a>");
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (id));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (id,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:externalId xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"value='' label='&lt;a&gt;'/>");
-	g_free (xml);
 	g_object_unref (id);
 }
 
@@ -3111,7 +2995,6 @@ static void
 test_gcontact_jot (void)
 {
 	GDataGContactJot *jot, *jot2;
-	gchar *xml;
 	GError *error = NULL;
 
 	jot = GDATA_GCONTACT_JOT (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_JOT,
@@ -3131,12 +3014,10 @@ test_gcontact_jot (void)
 	g_object_unref (jot2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (jot));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (jot,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:jot xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' rel='user'>"
 				"They like &lt;angles&gt;.</gContact:jot>");
-	g_free (xml);
 	g_object_unref (jot);
 
 	/* Now parse a jot with different information available */
@@ -3151,11 +3032,9 @@ test_gcontact_jot (void)
 	g_assert (gdata_gcontact_jot_get_content (jot) == NULL);
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (jot));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (jot,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:jot xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' rel='other'/>");
-	g_free (xml);
 	g_object_unref (jot);
 }
 
@@ -3183,7 +3062,6 @@ static void
 test_gcontact_language (void)
 {
 	GDataGContactLanguage *language, *language2;
-	gchar *xml;
 	GError *error = NULL;
 
 	language = GDATA_GCONTACT_LANGUAGE (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_LANGUAGE,
@@ -3206,12 +3084,10 @@ test_gcontact_language (void)
 	g_object_unref (language2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (language));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (language,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:language xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"code='en-GB'/>");
-	g_free (xml);
 	g_object_unref (language);
 
 	/* Now parse a language with less information available */
@@ -3227,12 +3103,10 @@ test_gcontact_language (void)
 	g_assert_cmpstr (gdata_gcontact_language_get_label (language), ==, "Gobbledegook");
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (language));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (language,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:language xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"label='Gobbledegook'/>");
-	g_free (xml);
 	g_object_unref (language);
 }
 
@@ -3262,7 +3136,6 @@ static void
 test_gcontact_relation (void)
 {
 	GDataGContactRelation *relation, *relation2;
-	gchar *xml;
 	GError *error = NULL;
 
 	relation = GDATA_GCONTACT_RELATION (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_RELATION,
@@ -3282,12 +3155,10 @@ test_gcontact_relation (void)
 	g_object_unref (relation2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (relation));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (relation,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:relation xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' rel='child'>"
 				"Fred</gContact:relation>");
-	g_free (xml);
 	g_object_unref (relation);
 
 	/* Now parse a relation with different information available */
@@ -3303,12 +3174,10 @@ test_gcontact_relation (void)
 	g_assert_cmpstr (gdata_gcontact_relation_get_label (relation), ==, "<a>");
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (relation));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (relation,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:relation xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 			   "label='&lt;a&gt;'>Sid</gContact:relation>");
-	g_free (xml);
 	g_object_unref (relation);
 }
 
@@ -3339,7 +3208,6 @@ static void
 test_gcontact_website (void)
 {
 	GDataGContactWebsite *website, *website2;
-	gchar *xml;
 	GError *error = NULL;
 
 	website = GDATA_GCONTACT_WEBSITE (gdata_parsable_new_from_xml (GDATA_TYPE_GCONTACT_WEBSITE,
@@ -3365,12 +3233,10 @@ test_gcontact_website (void)
 	g_object_unref (website2);
 
 	/* Check the outputted XML is the same */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (website));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (website,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:website xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"href='http://example.com/' rel='work' label='&lt;Markup&gt; blog' primary='true'/>");
-	g_free (xml);
 	g_object_unref (website);
 
 	/* Now parse a website with less information available */
@@ -3387,12 +3253,10 @@ test_gcontact_website (void)
 	g_assert (gdata_gcontact_website_is_primary (website) == FALSE);
 
 	/* Check the outputted XML is still OK */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (website));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (website,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<gContact:website xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
 				"href='http://test.com/' rel='ftp' primary='false'/>");
-	g_free (xml);
 	g_object_unref (website);
 }
 
diff --git a/gdata/tests/picasaweb.c b/gdata/tests/picasaweb.c
index e292c46..c2cb7b7 100644
--- a/gdata/tests/picasaweb.c
+++ b/gdata/tests/picasaweb.c
@@ -172,15 +172,15 @@ test_upload_async (gconstpointer service)
 	time_str = g_time_val_to_iso8601 (&timeval);
 	summary = g_strdup_printf ("Async Photo Summary (%s)", time_str);
 
-	expected_xml = g_strdup_printf ("<entry "
-						"xmlns='http://www.w3.org/2005/Atom' "
-						"xmlns:gphoto='http://schemas.google.com/photos/2007' "
-						"xmlns:media='http://search.yahoo.com/mrss/' "
-						"xmlns:gd='http://schemas.google.com/g/2005' "
-						"xmlns:exif='http://schemas.google.com/photos/exif/2007' "
-						"xmlns:app='http://www.w3.org/2007/app' "
-						"xmlns:georss='http://www.georss.org/georss' "
-						"xmlns:gml='http://www.opengis.net/gml'>"
+	expected_xml = g_strdup_printf ("<entry ("
+						"xmlns='http://www.w3.org/2005/Atom' ?|"
+						"xmlns:gphoto='http://schemas.google.com/photos/2007' ?|"
+						"xmlns:media='http://search.yahoo.com/mrss/' ?|"
+						"xmlns:gd='http://schemas.google.com/g/2005' ?|"
+						"xmlns:exif='http://schemas.google.com/photos/exif/2007' ?|"
+						"xmlns:app='http://www.w3.org/2007/app' ?|"
+						"xmlns:georss='http://www.georss.org/georss' ?|"
+						"xmlns:gml='http://www.opengis.net/gml' ?){8}>"
 						"<title type='text'>Async Photo Entry Title</title>"
 						"<summary type='text'>Async Photo Summary \\(%s\\)</summary>"
 						"<category term='http://schemas.google.com/photos/2007#photo' "
@@ -211,7 +211,7 @@ test_upload_async (gconstpointer service)
 	 * for the photo. */
 	xml = gdata_parsable_get_xml (GDATA_PARSABLE (photo));
 	g_assert (g_regex_match (regex, xml, 0, &match_info) == TRUE);
-	parsed_time_str = g_match_info_fetch (match_info, 1);
+	parsed_time_str = g_match_info_fetch (match_info, 2);
 	delta = g_ascii_strtoull (parsed_time_str, NULL, 10) - (((guint64) timeval.tv_sec) * 1000 + ((guint64) timeval.tv_usec) / 1000);
 	g_assert_cmpuint (abs (delta), <, 1000);
 
@@ -546,15 +546,15 @@ test_upload_simple (gconstpointer service)
 	time_str = g_time_val_to_iso8601 (&timeval);
 	summary = g_strdup_printf ("Photo Summary (%s)", time_str);
 
-	expected_xml = g_strdup_printf ("<entry "
-						"xmlns='http://www.w3.org/2005/Atom' "
-						"xmlns:gphoto='http://schemas.google.com/photos/2007' "
-						"xmlns:media='http://search.yahoo.com/mrss/' "
-						"xmlns:gd='http://schemas.google.com/g/2005' "
-						"xmlns:exif='http://schemas.google.com/photos/exif/2007' "
-						"xmlns:app='http://www.w3.org/2007/app' "
-						"xmlns:georss='http://www.georss.org/georss' "
-						"xmlns:gml='http://www.opengis.net/gml'>"
+	expected_xml = g_strdup_printf ("<entry ("
+						"xmlns='http://www.w3.org/2005/Atom' ?|"
+						"xmlns:gphoto='http://schemas.google.com/photos/2007' ?|"
+						"xmlns:media='http://search.yahoo.com/mrss/' ?|"
+						"xmlns:gd='http://schemas.google.com/g/2005' ?|"
+						"xmlns:exif='http://schemas.google.com/photos/exif/2007' ?|"
+						"xmlns:app='http://www.w3.org/2007/app' ?|"
+						"xmlns:georss='http://www.georss.org/georss' ?|"
+						"xmlns:gml='http://www.opengis.net/gml' ?){8}>"
 						"<title type='text'>Photo Entry Title</title>"
 						"<summary type='text'>Photo Summary \\(%s\\)</summary>"
 						"<category term='http://schemas.google.com/photos/2007#photo' "
@@ -585,7 +585,7 @@ test_upload_simple (gconstpointer service)
 	 * for the photo. */
 	xml = gdata_parsable_get_xml (GDATA_PARSABLE (photo));
 	g_assert (g_regex_match (regex, xml, 0, &match_info) == TRUE);
-	parsed_time_str = g_match_info_fetch (match_info, 1);
+	parsed_time_str = g_match_info_fetch (match_info, 2);
 	delta = g_ascii_strtoull (parsed_time_str, NULL, 10) - (((guint64) timeval.tv_sec) * 1000 + ((guint64) timeval.tv_usec) / 1000);
 	g_assert_cmpuint (abs (delta), <, 1000);
 
@@ -1258,14 +1258,15 @@ test_album_new (void)
 	/* Get the current time */
 	g_get_current_time (&timeval);
 
-	/* Build a regex to match the timestamp from the XML, since we can't definitely say what it'll be */
-	regex = g_regex_new ("<entry xmlns='http://www.w3.org/2005/Atom' "
-				    "xmlns:gphoto='http://schemas.google.com/photos/2007' "
-				    "xmlns:media='http://search.yahoo.com/mrss/' "
-				    "xmlns:gd='http://schemas.google.com/g/2005' "
-				    "xmlns:gml='http://www.opengis.net/gml' "
-				    "xmlns:app='http://www.w3.org/2007/app' "
-				    "xmlns:georss='http://www.georss.org/georss'>"
+	/* Build a regex to match the timestamp from the XML, since we can't definitely say what it'll be. Note that we also assign any order to the
+	 * namespace definitions, since due to a change in GLib's hashing algorithm, they could be in different orders with different GLib versions. */
+	regex = g_regex_new ("<entry (xmlns='http://www.w3.org/2005/Atom' ?|"
+				     "xmlns:gphoto='http://schemas.google.com/photos/2007' ?|"
+				     "xmlns:media='http://search.yahoo.com/mrss/' ?|"
+				     "xmlns:gd='http://schemas.google.com/g/2005' ?|"
+				     "xmlns:gml='http://www.opengis.net/gml' ?|"
+				     "xmlns:app='http://www.w3.org/2007/app' ?|"
+				     "xmlns:georss='http://www.georss.org/georss' ?){7}>"
 					"<title type='text'></title>"
 					"<id>http://picasaweb.google.com/data/entry/user/libgdata.picasaweb/albumid/5328889949261497249</id>"
 					"<category term='http://schemas.google.com/photos/2007#album' "
@@ -1286,7 +1287,7 @@ test_album_new (void)
 	 * for the photo. */
 	xml = gdata_parsable_get_xml (GDATA_PARSABLE (album));
 	g_assert (g_regex_match (regex, xml, 0, &match_info) == TRUE);
-	parsed_time_str = g_match_info_fetch (match_info, 1);
+	parsed_time_str = g_match_info_fetch (match_info, 2);
 	delta = g_ascii_strtoull (parsed_time_str, NULL, 10) - (((guint64) timeval.tv_sec) * 1000 + ((guint64) timeval.tv_usec) / 1000);
 	g_assert_cmpuint (abs (delta), <, 1000);
 
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index d86a852..c4936c6 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -267,7 +267,6 @@ test_upload_simple (gconstpointer service)
 	GDataYouTubeVideo *video, *new_video;
 	GDataMediaCategory *category;
 	GFile *video_file;
-	gchar *xml;
 	const gchar * const tags[] = { "toast", "wedding", NULL };
 	GError *error = NULL;
 
@@ -281,8 +280,7 @@ test_upload_simple (gconstpointer service)
 	gdata_youtube_video_set_keywords (video, tags);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (video));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (video,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 				"xmlns:media='http://search.yahoo.com/mrss/' "
@@ -301,7 +299,6 @@ test_upload_simple (gconstpointer service)
 					"<app:draft>no</app:draft>"
 				"</app:control>"
 			 "</entry>");
-	g_free (xml);
 
 	/* TODO: fix the path */
 	video_file = g_file_new_for_path (TEST_FILE_DIR "sample.ogg");
@@ -376,7 +373,6 @@ test_parsing_yt_recorded (void)
 {
 	GDataYouTubeVideo *video;
 	gint64 recorded;
-	gchar *xml;
 	GError *error = NULL;
 
 	video = GDATA_YOUTUBE_VIDEO (gdata_parsable_new_from_xml (GDATA_TYPE_YOUTUBE_VIDEO,
@@ -416,8 +412,7 @@ test_parsing_yt_recorded (void)
 	gdata_youtube_video_set_recorded (video, recorded);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (video));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (video,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 				"xmlns:media='http://search.yahoo.com/mrss/' "
@@ -445,7 +440,6 @@ test_parsing_yt_recorded (void)
 					"<app:draft>no</app:draft>"
 				"</app:control>"
 			 "</entry>");
-	g_free (xml);
 
 	/* TODO: more tests on entry properties */
 
@@ -456,7 +450,6 @@ static void
 test_parsing_yt_access_control (void)
 {
 	GDataYouTubeVideo *video;
-	gchar *xml;
 	GError *error = NULL;
 
 	video = GDATA_YOUTUBE_VIDEO (gdata_parsable_new_from_xml (GDATA_TYPE_YOUTUBE_VIDEO,
@@ -505,8 +498,7 @@ test_parsing_yt_access_control (void)
 	gdata_youtube_video_set_access_control (video, GDATA_YOUTUBE_ACTION_EMBED, GDATA_YOUTUBE_PERMISSION_DENIED);
 
 	/* Check the XML */
-	xml = gdata_parsable_get_xml (GDATA_PARSABLE (video));
-	g_assert_cmpstr (xml, ==,
+	gdata_test_assert_xml (video,
 			 "<?xml version='1.0' encoding='UTF-8'?>"
 			 "<entry xmlns='http://www.w3.org/2005/Atom' "
 				"xmlns:media='http://search.yahoo.com/mrss/' "
@@ -540,7 +532,6 @@ test_parsing_yt_access_control (void)
 					"<app:draft>no</app:draft>"
 				"</app:control>"
 			 "</entry>");
-	g_free (xml);
 
 	g_object_unref (video);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]