[libgdata] tests: Convert all the tests to use the new XML tree comparison function
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] tests: Convert all the tests to use the new XML tree comparison function
- Date: Sat, 11 Dec 2010 18:32:59 +0000 (UTC)
commit 997fc9a3dda1d3d1e38e68b11cb3c5136d484e63
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 | 25 +---
gdata/tests/contacts.c | 22 +--
gdata/tests/general.c | 354 +++++++++++------------------------------------
gdata/tests/picasaweb.c | 29 ++---
gdata/tests/youtube.c | 15 +--
5 files changed, 108 insertions(+), 337 deletions(-)
---
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index 391ea07..cf3ed5d 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -268,7 +268,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);
@@ -290,8 +289,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' "
@@ -312,7 +310,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);
@@ -390,7 +387,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,
@@ -448,8 +444,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' "
@@ -466,7 +461,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);
}
@@ -539,14 +533,12 @@ static void
test_calendar_escaping (void)
{
GDataCalendarCalendar *calendar;
- gchar *xml;
calendar = gdata_calendar_calendar_new (NULL);
gdata_calendar_calendar_set_timezone (calendar, "<timezone>");
/* Check the outputted XML is escaped properly */
- xml = gdata_parsable_get_xml (GDATA_PARSABLE (calendar));
- g_assert_cmpstr (xml, ==,
+ gdata_test_assert_xml (calendar,
"<?xml version='1.0' encoding='UTF-8'?>"
"<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
"xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:app='http://www.w3.org/2007/app'>"
@@ -557,7 +549,6 @@ test_calendar_escaping (void)
"<gCal:color value='#000000'/>"
"<gCal:selected value='false'/>"
"</entry>");
- g_free (xml);
g_object_unref (calendar);
}
@@ -565,7 +556,6 @@ static void
test_event_escaping (void)
{
GDataCalendarEvent *event;
- gchar *xml;
event = gdata_calendar_event_new (NULL);
gdata_calendar_event_set_status (event, "<status>");
@@ -575,8 +565,7 @@ test_event_escaping (void)
gdata_calendar_event_set_recurrence (event, "<recurrence>");
/* Check the outputted XML is escaped properly */
- 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' "
"xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:app='http://www.w3.org/2007/app'>"
@@ -592,7 +581,6 @@ test_event_escaping (void)
"<gCal:anyoneCanAddSelf value='false'/>"
"<gd:recurrence><recurrence></gd:recurrence>"
"</entry>");
- g_free (xml);
g_object_unref (event);
}
@@ -722,7 +710,6 @@ test_acls_insert_rule (gconstpointer service)
GDataCategory *category;
GDataLink *_link;
GList *categories;
- gchar *xml;
gint64 edited;
GError *error = NULL;
@@ -739,8 +726,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' "
@@ -750,7 +736,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 dc25cf7..a125ab0 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);
@@ -793,7 +789,6 @@ static void
test_contact_escaping (void)
{
GDataContactsContact *contact;
- gchar *xml;
contact = gdata_contacts_contact_new (NULL);
gdata_contacts_contact_set_nickname (contact, "Nickname & stuff");
@@ -814,8 +809,7 @@ test_contact_escaping (void)
gdata_contacts_contact_add_group (contact, "http://foo.com?foo&bar");
/* Check the outputted XML is escaped properly */
- 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' "
"xmlns:app='http://www.w3.org/2007/app' xmlns:gContact='http://schemas.google.com/contact/2008'>"
@@ -841,7 +835,6 @@ test_contact_escaping (void)
"<gContact:shortName>Short name & stuff</gContact:shortName>"
"<gContact:subject>Subject & stuff</gContact:subject>"
"</entry>");
- g_free (xml);
g_object_unref (contact);
}
@@ -849,14 +842,12 @@ static void
test_group_escaping (void)
{
GDataContactsGroup *group;
- gchar *xml;
group = gdata_contacts_group_new (NULL);
gdata_contacts_group_set_extended_property (group, "extended & prop", "<unescaped>Value should be a pre-escaped XML blob.</unescaped>");
/* Check the outputted XML is escaped properly */
- 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' "
"xmlns:app='http://www.w3.org/2007/app' xmlns:gContact='http://schemas.google.com/contact/2008'>"
@@ -866,7 +857,6 @@ test_group_escaping (void)
"<unescaped>Value should be a pre-escaped XML blob.</unescaped>"
"</gd:extendedProperty>"
"</entry>");
- g_free (xml);
g_object_unref (group);
}
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index f8204df..16248a1 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 & 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 & 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);
}
@@ -532,7 +527,6 @@ static void
test_entry_escaping (void)
{
GDataEntry *entry;
- gchar *xml;
GError *error = NULL;
/* Since we can't construct a GDataEntry directly, we need to parse it from XML */
@@ -551,8 +545,7 @@ test_entry_escaping (void)
g_assert (GDATA_IS_ENTRY (entry));
/* Check the outputted XML is escaped properly */
- 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'>Escaped content & stuff</title>"
@@ -563,7 +556,6 @@ test_entry_escaping (void)
"<rights>Free & open source</rights>"
"<content type='text'>Content & things.</content>"
"</entry>");
- g_free (xml);
g_object_unref (entry);
/* Repeat with content given by a URI */
@@ -577,14 +569,12 @@ test_entry_escaping (void)
g_assert (GDATA_IS_ENTRY (entry));
/* Check the outputted XML is escaped properly */
- 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'>Escaped content & stuff</title>"
"<content type='text/plain' src='http://foo.com?foo&bar'/>"
"</entry>");
- g_free (xml);
g_object_unref (entry);
}
@@ -841,7 +831,6 @@ static void
test_feed_escaping (void)
{
GDataFeed *feed;
- gchar *xml;
GError *error = NULL;
/* Since we can't construct a GDataEntry directly, we need to parse it from XML */
@@ -856,15 +845,13 @@ test_feed_escaping (void)
g_assert (GDATA_IS_FEED (feed));
/* Check the outputted XML is escaped properly */
- xml = gdata_parsable_get_xml (GDATA_PARSABLE (feed));
- g_assert_cmpstr (xml, ==,
+ gdata_test_assert_xml (feed,
"<?xml version='1.0' encoding='UTF-8'?>"
"<feed xmlns='http://www.w3.org/2005/Atom'>"
"<title type='text'>Test feed & stuff.</title>"
"<id>http://foo.com?foo&bar</id>"
"<updated>2010-12-10T17:49:15Z</updated>"
"</feed>");
- g_free (xml);
g_object_unref (feed);
}
@@ -1051,8 +1038,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' "
@@ -1065,6 +1051,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));
@@ -1137,15 +1124,13 @@ static void
test_access_rule_escaping (void)
{
GDataAccessRule *rule;
- gchar *xml;
rule = gdata_access_rule_new (NULL);
gdata_access_rule_set_role (rule, "<role>");
gdata_access_rule_set_scope (rule, "<scope>", "<value>");
/* Check the outputted XML is escaped properly */
- 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' "
"xmlns:gAcl='http://schemas.google.com/acl/2007'>"
@@ -1154,7 +1139,6 @@ test_access_rule_escaping (void)
"<gAcl:role value='<role>'/>"
"<gAcl:scope type='<scope>' value='<value>'/>"
"</entry>");
- g_free (xml);
g_object_unref (rule);
}
@@ -1241,7 +1225,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,
@@ -1270,15 +1254,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),
@@ -1345,20 +1327,17 @@ static void
test_atom_author_escaping (void)
{
GDataAuthor *author;
- gchar *xml;
author = gdata_author_new ("First & Last Name", "http://foo.com?foo&bar", "John Smith <john smith gmail com>");
/* Check the outputted XML is escaped properly */
- 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>First & Last Name</name>"
"<uri>http://foo.com?foo&bar</uri>"
"<email>John Smith <john smith gmail com></email>"
"</author>");
- g_free (xml);
g_object_unref (author);
}
@@ -1366,7 +1345,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,
@@ -1391,12 +1370,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 & Trivia'/>");
- g_free (xml);
/* Check the properties */
g_object_get (G_OBJECT (category),
@@ -1438,14 +1415,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);
}
@@ -1466,17 +1441,14 @@ static void
test_atom_category_escaping (void)
{
GDataCategory *category;
- gchar *xml;
category = gdata_category_new ("<term>", "http://foo.com?foo&bar", "Label & Stuff");
/* Check the outputted XML is escaped properly */
- 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='<term>' scheme='http://foo.com?foo&bar' "
"label='Label & Stuff'/>");
- g_free (xml);
g_object_unref (category);
}
@@ -1559,7 +1531,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;
@@ -1593,12 +1565,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: <, >' "
"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),
@@ -1650,12 +1620,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);
}
@@ -1691,7 +1659,6 @@ static void
test_atom_link_escaping (void)
{
GDataLink *_link;
- gchar *xml;
_link = gdata_link_new ("http://foo.com?foo&bar", "http://foo.com?foo&relation=bar");
gdata_link_set_content_type (_link, "<content type>");
@@ -1700,12 +1667,10 @@ test_atom_link_escaping (void)
/* Check the outputted XML is escaped properly */
- xml = gdata_parsable_get_xml (GDATA_PARSABLE (_link));
- g_assert_cmpstr (xml, ==,
+ gdata_test_assert_xml (_link,
"<?xml version='1.0' encoding='UTF-8'?>"
"<link xmlns='http://www.w3.org/2005/Atom' href='http://foo.com?foo&bar' title='Title & stuff' "
"rel='http://foo.com?foo&relation=bar' type='<content type>' hreflang='<language>'/>");
- g_free (xml);
g_object_unref (_link);
}
@@ -1761,7 +1726,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,
@@ -1789,13 +1753,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 & Private' displayName='<John Smith>' "
"primary='true'/>");
- g_free (xml);
g_object_unref (email);
/* Now parse an address with less information available */
@@ -1813,12 +1775,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);
}
@@ -1826,7 +1786,6 @@ static void
test_gd_email_address_escaping (void)
{
GDataGDEmailAddress *email;
- gchar *xml;
g_test_bug ("630350");
@@ -1834,13 +1793,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 <fubar gmail com>' rel='http://schemas.google.com/g/2005#home?foo&bar' "
"label='Personal & Private' displayName='<John Smith>' primary='true'/>");
- g_free (xml);
g_object_unref (email);
}
@@ -1848,7 +1805,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,
@@ -1875,13 +1831,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 */
@@ -1899,12 +1853,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 & Miscellaneous' primary='false'/>");
- g_free (xml);
g_object_unref (im);
}
@@ -1912,19 +1864,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 <fubar gmail com>' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK?foo&bar' "
"rel='http://schemas.google.com/g/2005#home?foo&bar' label='Personal & Private' primary='true'/>");
- g_free (xml);
g_object_unref (im);
}
@@ -1932,7 +1881,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,
@@ -1969,8 +1917,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>"
@@ -1980,7 +1927,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 */
@@ -1999,13 +1945,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);
}
@@ -2014,7 +1958,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,
@@ -2055,8 +1998,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 & Occupation' primary='true'>"
@@ -2067,7 +2009,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 */
@@ -2089,11 +2030,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);
}
@@ -2101,7 +2040,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");
@@ -2109,8 +2047,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&bar' label='Personal & Private' primary='true'>"
@@ -2120,7 +2057,6 @@ test_gd_organization_escaping (void)
"<gd:orgJobDescription>Escaping <brackets>.</gd:orgJobDescription>"
"<gd:orgSymbol><&></gd:orgSymbol>"
"</gd:organization>");
- g_free (xml);
g_object_unref (org);
}
@@ -2128,7 +2064,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,
@@ -2156,13 +2091,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 & 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 ");
@@ -2184,12 +2117,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);
}
@@ -2197,19 +2128,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&bar' rel='http://schemas.google.com/g/2005#work_mobile?foo&bar' "
"label='Personal & Private' primary='true'>0123456789 <54></gd:phoneNumber>");
- g_free (xml);
g_object_unref (phone);
}
@@ -2217,7 +2145,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,
@@ -2256,8 +2183,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 & Safe House' primary='true'>"
@@ -2266,7 +2192,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 ");
@@ -2288,12 +2213,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);
}
@@ -2301,7 +2224,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>");
@@ -2319,8 +2241,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&bar' label='Personal & Private' "
@@ -2338,7 +2259,6 @@ test_gd_postal_address_escaping (void)
"<gd:country code='<bar>'><foo></gd:country>"
"<gd:formattedAddress><address></gd:formattedAddress>"
"</gd:structuredPostalAddress>");
- g_free (xml);
g_object_unref (address);
}
@@ -2346,7 +2266,6 @@ static void
test_gd_reminder (void)
{
GDataGDReminder *reminder, *reminder2;
- gchar *xml;
gint64 _time;
GError *error = NULL;
@@ -2362,11 +2281,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 */
@@ -2419,12 +2336,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);
}
@@ -2432,17 +2347,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&bar'/>");
- g_free (xml);
g_object_unref (reminder);
}
@@ -2451,7 +2363,6 @@ test_gd_when (void)
{
GDataGDWhen *when, *when2;
GDataGDReminder *reminder;
- gchar *xml;
GList *reminders;
gint64 _time, _time2;
GError *error = NULL;
@@ -2483,12 +2394,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 */
@@ -2522,8 +2431,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'>"
@@ -2531,7 +2439,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);
}
@@ -2539,7 +2446,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);
@@ -2547,12 +2453,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 & stuff!'/>");
- g_free (xml);
g_object_unref (when);
}
@@ -2560,7 +2464,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,
@@ -2585,13 +2488,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 <videoconference>' 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 */
@@ -2607,12 +2508,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 <Building 40>'/>");
- g_free (xml);
g_object_unref (where);
}
@@ -2620,18 +2519,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='<label>' rel='http://schemas.google.com/g/2005#event?foo&bar' "
"valueString='Value string & stuff!'/>");
- g_free (xml);
g_object_unref (where);
}
@@ -2639,7 +2535,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,
@@ -2664,12 +2559,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 */
@@ -2685,11 +2578,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);
}
@@ -2697,18 +2588,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 <john smith gmail com>' rel='http://schemas.google.com/g/2005#event.attendee?foo&bar' "
"valueString='Value string & stuff!'/>");
- g_free (xml);
g_object_unref (who);
}
@@ -2716,7 +2604,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,
@@ -2733,14 +2620,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 & 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 */
@@ -2756,12 +2641,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);
}
@@ -2769,17 +2652,14 @@ static void
test_media_category_escaping (void)
{
GDataMediaCategory *category;
- gchar *xml;
category = gdata_media_category_new ("<category>", "http://foo.com?foo&bar", "Label & stuff");
/* Check the outputted XML is escaped properly */
- 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://foo.com?foo&bar' label='Label & stuff'><category></media:category>");
- g_free (xml);
g_object_unref (category);
}
@@ -2875,7 +2755,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,
@@ -2924,8 +2803,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>"
@@ -2943,7 +2821,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");
@@ -2989,10 +2866,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
@@ -3039,7 +2915,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,
@@ -3065,12 +2940,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 */
@@ -3088,12 +2961,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='<a>' primary='false'/>");
- g_free (xml);
g_object_unref (calendar);
}
@@ -3126,30 +2997,25 @@ static void
test_gcontact_calendar_escaping (void)
{
GDataGContactCalendar *calendar;
- gchar *xml;
/* Test with rel */
calendar = gdata_gcontact_calendar_new ("http://foo.com?foo&bar", "http://foo.com?foo&relation=bar", NULL, TRUE);
/* Check the outputted XML is escaped properly */
- 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://foo.com?foo&bar' rel='http://foo.com?foo&relation=bar' primary='true'/>");
- g_free (xml);
g_object_unref (calendar);
/* Test with label */
calendar = gdata_gcontact_calendar_new ("http://foo.com?foo&bar", NULL, "Label & stuff", FALSE);
/* Check the outputted XML is escaped properly */
- 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://foo.com?foo&bar' label='Label & stuff' primary='false'/>");
- g_free (xml);
g_object_unref (calendar);
}
@@ -3158,7 +3024,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,
@@ -3184,14 +3049,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 */
@@ -3214,14 +3077,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='<a>'>"
"<gd:when startTime='2000-01-01'/>"
"</gContact:event>");
- g_free (xml);
g_object_unref (event);
}
@@ -3256,7 +3117,6 @@ static void
test_gcontact_event_escaping (void)
{
GDataGContactEvent *event;
- gchar *xml;
GDate date;
g_date_clear (&date, 1);
@@ -3266,28 +3126,24 @@ test_gcontact_event_escaping (void)
event = gdata_gcontact_event_new (&date, "http://foo.com?foo&relation=bar", NULL);
/* Check the outputted XML is escaped properly */
- 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='http://foo.com?foo&relation=bar'>"
"<gd:when startTime='2011-01-01'/>"
"</gContact:event>");
- g_free (xml);
g_object_unref (event);
/* Test with label */
event = gdata_gcontact_event_new (&date, NULL, "Label & stuff");
/* Check the outputted XML is escaped properly */
- 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='Label & stuff'>"
"<gd:when startTime='2011-01-01'/>"
"</gContact:event>");
- g_free (xml);
g_object_unref (event);
}
@@ -3295,7 +3151,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,
@@ -3319,12 +3174,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 */
@@ -3340,12 +3193,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='<a>'/>");
- g_free (xml);
g_object_unref (id);
}
@@ -3376,30 +3227,25 @@ static void
test_gcontact_external_id_escaping (void)
{
GDataGContactExternalID *id;
- gchar *xml;
/* Test with rel */
id = gdata_gcontact_external_id_new ("<id>", "http://foo.com?foo&relation=bar", NULL);
/* Check the outputted XML is escaped properly */
- 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='<id>' rel='http://foo.com?foo&relation=bar'/>");
- g_free (xml);
g_object_unref (id);
/* Test with label */
id = gdata_gcontact_external_id_new ("<id>", NULL, "Label & stuff");
/* Check the outputted XML is escaped properly */
- 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='<id>' label='Label & stuff'/>");
- g_free (xml);
g_object_unref (id);
}
@@ -3407,7 +3253,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,
@@ -3427,12 +3272,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 <angles>.</gContact:jot>");
- g_free (xml);
g_object_unref (jot);
/* Now parse a jot with different information available */
@@ -3447,11 +3290,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);
}
@@ -3479,17 +3320,14 @@ static void
test_gcontact_jot_escaping (void)
{
GDataGContactJot *jot;
- gchar *xml;
jot = gdata_gcontact_jot_new ("Content & stuff", "http://foo.com?foo&relation=bar");
/* Check the outputted XML is escaped properly */
- 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='http://foo.com?foo&relation=bar'>Content & stuff</gContact:jot>");
- g_free (xml);
g_object_unref (jot);
}
@@ -3497,7 +3335,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,
@@ -3520,12 +3357,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 */
@@ -3541,12 +3376,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);
}
@@ -3576,30 +3409,25 @@ static void
test_gcontact_language_escaping (void)
{
GDataGContactLanguage *language;
- gchar *xml;
/* Test with code */
language = gdata_gcontact_language_new ("<code>", NULL);
/* Check the outputted XML is escaped properly */
- 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='<code>'/>");
- g_free (xml);
g_object_unref (language);
/* Test with label */
language = gdata_gcontact_language_new (NULL, "Label & stuff");
/* Check the outputted XML is escaped properly */
- 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='Label & stuff'/>");
- g_free (xml);
g_object_unref (language);
}
@@ -3607,7 +3435,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,
@@ -3627,12 +3454,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 */
@@ -3648,12 +3473,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='<a>'>Sid</gContact:relation>");
- g_free (xml);
g_object_unref (relation);
}
@@ -3684,30 +3507,25 @@ static void
test_gcontact_relation_escaping (void)
{
GDataGContactRelation *relation;
- gchar *xml;
/* Test with rel */
relation = gdata_gcontact_relation_new ("First & Last Name", "http://foo.com?foo&relation=bar", NULL);
/* Check the outputted XML is escaped properly */
- 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='http://foo.com?foo&relation=bar'>First & Last Name</gContact:relation>");
- g_free (xml);
g_object_unref (relation);
/* Test with label */
relation = gdata_gcontact_relation_new ("First & Last Name", NULL, "Label & stuff");
/* Check the outputted XML is escaped properly */
- 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='Label & stuff'>First & Last Name</gContact:relation>");
- g_free (xml);
g_object_unref (relation);
}
@@ -3715,7 +3533,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,
@@ -3741,12 +3558,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='<Markup> blog' primary='true'/>");
- g_free (xml);
g_object_unref (website);
/* Now parse a website with less information available */
@@ -3763,12 +3578,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);
}
@@ -3799,18 +3612,15 @@ static void
test_gcontact_website_escaping (void)
{
GDataGContactWebsite *website;
- gchar *xml;
website = gdata_gcontact_website_new ("http://foo.com?foo&bar", "http://foo.com?foo&relation=bar", "Label & stuff", TRUE);
/* Check the outputted XML is escaped properly */
- 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://foo.com?foo&bar' rel='http://foo.com?foo&relation=bar' label='Label & stuff' "
"primary='true'/>");
- g_free (xml);
g_object_unref (website);
}
diff --git a/gdata/tests/picasaweb.c b/gdata/tests/picasaweb.c
index 9529035..b027f33 100644
--- a/gdata/tests/picasaweb.c
+++ b/gdata/tests/picasaweb.c
@@ -1271,14 +1271,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' "
@@ -1299,7 +1300,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);
@@ -1314,7 +1315,6 @@ static void
test_album_escaping (void)
{
GDataPicasaWebAlbum *album;
- gchar *xml;
GError *error = NULL;
const gchar * const tags[] = { "<tag1>", "tag2 & stuff, things", NULL };
@@ -1334,8 +1334,7 @@ test_album_escaping (void)
gdata_picasaweb_album_set_tags (album, tags);
/* Check the outputted XML is escaped properly */
- xml = gdata_parsable_get_xml (GDATA_PARSABLE (album));
- g_assert_cmpstr (xml, ==,
+ gdata_test_assert_xml (album,
"<?xml version='1.0' encoding='UTF-8'?>"
"<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' "
@@ -1349,7 +1348,6 @@ test_album_escaping (void)
"<gphoto:commentingEnabled>false</gphoto:commentingEnabled>"
"<media:group><media:keywords><tag1>,tag2 & stuff%2C things</media:keywords></media:group>"
"</entry>");
- g_free (xml);
g_object_unref (album);
}
@@ -1357,7 +1355,6 @@ static void
test_file_escaping (void)
{
GDataPicasaWebFile *file;
- gchar *xml;
GError *error = NULL;
const gchar * const tags[] = { "<tag1>", "tag2 & stuff, things", NULL };
@@ -1380,8 +1377,7 @@ test_file_escaping (void)
gdata_picasaweb_file_set_caption (file, "Caption & stuff.");
/* Check the outputted XML is escaped properly */
- xml = gdata_parsable_get_xml (GDATA_PARSABLE (file));
- g_assert_cmpstr (xml, ==,
+ gdata_test_assert_xml (file,
"<?xml version='1.0' encoding='UTF-8'?>"
"<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' "
@@ -1400,7 +1396,6 @@ test_file_escaping (void)
"<media:keywords><tag1>,tag2 & stuff%2C things</media:keywords>"
"</media:group>"
"</entry>");
- g_free (xml);
g_object_unref (file);
}
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index 43c2ec0..1b20b27 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -496,7 +496,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,
@@ -536,8 +535,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/' "
@@ -565,7 +563,6 @@ test_parsing_yt_recorded (void)
"<app:draft>no</app:draft>"
"</app:control>"
"</entry>");
- g_free (xml);
/* TODO: more tests on entry properties */
@@ -576,7 +573,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,
@@ -625,8 +621,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/' "
@@ -660,7 +655,6 @@ test_parsing_yt_access_control (void)
"<app:draft>no</app:draft>"
"</app:control>"
"</entry>");
- g_free (xml);
g_object_unref (video);
}
@@ -773,7 +767,6 @@ static void
test_video_escaping (void)
{
GDataYouTubeVideo *video;
- gchar *xml;
const gchar * const keywords[] = { "<keyword1>", "keyword2 & stuff, things", NULL };
video = gdata_youtube_video_new (NULL);
@@ -784,8 +777,7 @@ test_video_escaping (void)
gdata_youtube_video_set_aspect_ratio (video, "4 & 3");
/* Check the outputted XML is escaped properly */
- 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/' "
"xmlns:gd='http://schemas.google.com/g/2005' "
@@ -801,7 +793,6 @@ test_video_escaping (void)
"<yt:accessControl action='<action>' permission='allowed'/>"
"<app:control><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]