[libgdata] [gd] Added test cases for the GData elements with classes



commit f752236c8dfdbcf1e0e123b70a1e039a4ce6aef8
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Jun 29 16:20:57 2009 +0100

    [gd] Added test cases for the GData elements with classes
    
    Added test cases for all the GData elements represented in gdata/gd. A few
    bugs (mainly escaping bugs) in the classes were fixed as a result.

 gdata/gd/gdata-gd-email-address.c  |    7 +-
 gdata/gd/gdata-gd-im-address.c     |   16 +-
 gdata/gd/gdata-gd-organization.c   |   26 ++-
 gdata/gd/gdata-gd-phone-number.c   |   34 ++-
 gdata/gd/gdata-gd-postal-address.c |   28 ++-
 gdata/gd/gdata-gd-postal-address.h |    2 +-
 gdata/gd/gdata-gd-when.c           |    4 +-
 gdata/gd/gdata-gd-where.c          |   23 +-
 gdata/gd/gdata-gd-who.c            |   14 +-
 gdata/tests/general.c              |  608 ++++++++++++++++++++++++++++++++++++
 10 files changed, 715 insertions(+), 47 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-email-address.c b/gdata/gd/gdata-gd-email-address.c
index bb500a8..0a60f2a 100644
--- a/gdata/gd/gdata-gd-email-address.c
+++ b/gdata/gd/gdata-gd-email-address.c
@@ -265,8 +265,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 	g_string_append_printf (xml_string, " address='%s'", priv->address);
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->label != NULL)
-		g_string_append_printf (xml_string, " label='%s'", priv->label);
+	if (priv->label != NULL) {
+		gchar *label = g_markup_escape_text (priv->label, -1);
+		g_string_append_printf (xml_string, " label='%s'", label);
+		g_free (label);
+	}
 
 	if (priv->is_primary == TRUE)
 		g_string_append (xml_string, " primary='true'");
diff --git a/gdata/gd/gdata-gd-im-address.c b/gdata/gd/gdata-gd-im-address.c
index 5aafcb2..d8025f1 100644
--- a/gdata/gd/gdata-gd-im-address.c
+++ b/gdata/gd/gdata-gd-im-address.c
@@ -298,8 +298,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->label != NULL)
-		g_string_append_printf (xml_string, " label='%s'", priv->label);
+	if (priv->label != NULL) {
+		gchar *label = g_markup_escape_text (priv->label, -1);
+		g_string_append_printf (xml_string, " label='%s'", label);
+		g_free (label);
+	}
 
 	if (priv->is_primary == TRUE)
 		g_string_append (xml_string, " primary='true'");
@@ -333,7 +336,7 @@ gdata_gd_im_address_new (const gchar *address, const gchar *protocol, const gcha
 {
 	g_return_val_if_fail (address != NULL && *address != '\0', NULL);
 	g_return_val_if_fail (relation_type == NULL || *relation_type != '\0', NULL);
-	return g_object_new (GDATA_TYPE_GD_IM_ADDRESS, "address", address, "relation-type", relation_type,
+	return g_object_new (GDATA_TYPE_GD_IM_ADDRESS, "address", address, "protocol", protocol, "relation-type", relation_type,
 			     "label", label, "is-primary", is_primary, NULL);
 }
 
@@ -354,8 +357,6 @@ gdata_gd_im_address_new (const gchar *address, const gchar *protocol, const gcha
 gint
 gdata_gd_im_address_compare (const GDataGDIMAddress *a, const GDataGDIMAddress *b)
 {
-	gint address_cmp;
-
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (b == NULL)
@@ -364,10 +365,9 @@ gdata_gd_im_address_compare (const GDataGDIMAddress *a, const GDataGDIMAddress *
 	if (a == b)
 		return 0;
 
-	address_cmp = g_strcmp0 (a->priv->address, b->priv->address);
-	if (address_cmp == 0 && g_strcmp0 (a->priv->protocol, b->priv->protocol) == 0)
+	if (g_strcmp0 (a->priv->address, b->priv->address) == 0 && g_strcmp0 (a->priv->protocol, b->priv->protocol) == 0)
 		return 0;
-	return address_cmp;
+	return 1;
 }
 
 /**
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index 5a97a65..9f4271a 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -320,8 +320,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->label != NULL)
-		g_string_append_printf (xml_string, " label='%s'", priv->label);
+	if (priv->label != NULL) {
+		gchar *label = g_markup_escape_text (priv->label, -1);
+		g_string_append_printf (xml_string, " label='%s'", label);
+		g_free (label);
+	}
 
 	if (priv->is_primary == TRUE)
 		g_string_append (xml_string, " primary='true'");
@@ -334,10 +337,17 @@ get_xml (GDataParsable *parsable, GString *xml_string)
 {
 	GDataGDOrganizationPrivate *priv = GDATA_GD_ORGANIZATION (parsable)->priv;
 
-	if (priv->name != NULL)
-		g_string_append_printf (xml_string, "<gd:orgName>%s</gd:orgName>", priv->name);
-	if (priv->title != NULL)
-		g_string_append_printf (xml_string, "<gd:orgTitle>%s</gd:orgTitle>", priv->title);
+	if (priv->name != NULL) {
+		gchar *name = g_markup_escape_text (priv->name, -1);
+		g_string_append_printf (xml_string, "<gd:orgName>%s</gd:orgName>", name);
+		g_free (name);
+	}
+
+	if (priv->title != NULL) {
+		gchar *title = g_markup_escape_text (priv->title, -1);
+		g_string_append_printf (xml_string, "<gd:orgTitle>%s</gd:orgTitle>", title);
+		g_free (title);
+	}
 }
 
 static void
@@ -393,7 +403,9 @@ gdata_gd_organization_compare (const GDataGDOrganization *a, const GDataGDOrgani
 
 	if (a == b)
 		return 0;
-	return g_strcmp0 (a->priv->name, b->priv->name);
+	if (g_strcmp0 (a->priv->name, b->priv->name) == 0 && g_strcmp0 (a->priv->title, b->priv->title) == 0)
+		return 0;
+	return 1;
 }
 
 /**
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index b41e802..3691a94 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -29,6 +29,7 @@
 
 #include <glib.h>
 #include <libxml/parser.h>
+#include <string.h>
 
 #include "gdata-gd-phone-number.h"
 #include "gdata-parsable.h"
@@ -247,8 +248,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 	GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
 
 	number = xmlNodeListGetString (doc, root_node->children, TRUE);
-	if (number == NULL || *number == '\0')
+	if (number == NULL || *number == '\0') {
+		xmlFree (number);
 		return gdata_parser_error_required_content_missing (root_node, error);
+	}
 
 	rel = xmlGetProp (root_node, (xmlChar*) "rel");
 	if (rel != NULL && *rel == '\0') {
@@ -276,7 +279,7 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 	label = xmlGetProp (root_node, (xmlChar*) "label");
 	uri = xmlGetProp (root_node, (xmlChar*) "uri");
 
-	priv->number = g_strdup ((gchar*) number);
+	gdata_gd_phone_number_set_number (GDATA_GD_PHONE_NUMBER (parsable), (gchar*) number);
 	priv->uri = g_strdup ((gchar*) uri);
 	priv->relation_type = g_strdup ((gchar*) rel);
 	priv->label = g_strdup ((gchar*) label);
@@ -314,8 +317,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 		g_string_append_printf (xml_string, " uri='%s'", priv->uri);
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->label != NULL)
-		g_string_append_printf (xml_string, " label='%s'", priv->label);
+	if (priv->label != NULL) {
+		gchar *label = g_markup_escape_text (priv->label, -1);
+		g_string_append_printf (xml_string, " label='%s'", label);
+		g_free (label);
+	}
 
 	if (priv->is_primary == TRUE)
 		g_string_append (xml_string, " primary='true'");
@@ -326,9 +332,12 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 static void
 get_xml (GDataParsable *parsable, GString *xml_string)
 {
+	gchar *number;
 	GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
 
-	g_string_append (xml_string, priv->number);
+	number = g_markup_escape_text (priv->number, -1);
+	g_string_append (xml_string, number);
+	g_free (number);
 }
 
 static void
@@ -417,10 +426,23 @@ gdata_gd_phone_number_get_number (GDataGDPhoneNumber *self)
 void
 gdata_gd_phone_number_set_number (GDataGDPhoneNumber *self, const gchar *number)
 {
+	gint len;
+
 	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (self));
+	g_return_if_fail (number != NULL && *number != '\0');
 
 	g_free (self->priv->number);
-	self->priv->number = g_strdup (number);
+
+	/* Trim leading and trailing whitespace from the number.
+	 * See here: http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPhoneNumber */
+	while (*number != '\0' && g_ascii_isspace (*number))
+		number++;
+
+	len = strlen (number);
+	while (len > 0 && g_ascii_isspace (number[len - 1]))
+		len--;
+
+	self->priv->number = g_strndup (number, len);
 	g_object_notify (G_OBJECT (self), "number");
 }
 
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index 9f88cd0..ff7af42 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -29,6 +29,7 @@
 
 #include <glib.h>
 #include <libxml/parser.h>
+#include <string.h>
 
 #include "gdata-gd-postal-address.h"
 #include "gdata-parsable.h"
@@ -222,8 +223,10 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 	GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
 
 	address = xmlNodeListGetString (doc, root_node->children, TRUE);
-	if (address == NULL || *address == '\0')
+	if (address == NULL || *address == '\0') {
+		xmlFree (address);
 		return gdata_parser_error_required_content_missing (root_node, error);
+	}
 
 	rel = xmlGetProp (root_node, (xmlChar*) "rel");
 	if (rel != NULL && *rel == '\0') {
@@ -249,7 +252,7 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 	/* Other properties */
 	label = xmlGetProp (root_node, (xmlChar*) "label");
 
-	priv->address = g_strdup ((gchar*) address);
+	gdata_gd_postal_address_set_address (GDATA_GD_POSTAL_ADDRESS (parsable), (const gchar*) address);
 	priv->relation_type = g_strdup ((gchar*) rel);
 	priv->label = g_strdup ((gchar*) label);
 	priv->is_primary = primary_bool;
@@ -283,8 +286,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->label != NULL)
-		g_string_append_printf (xml_string, " label='%s'", priv->label);
+	if (priv->label != NULL) {
+		gchar *label = g_markup_escape_text (priv->label, -1);
+		g_string_append_printf (xml_string, " label='%s'", label);
+		g_free (label);
+	}
 
 	if (priv->is_primary == TRUE)
 		g_string_append (xml_string, " primary='true'");
@@ -385,11 +391,23 @@ gdata_gd_postal_address_get_address (GDataGDPostalAddress *self)
 void
 gdata_gd_postal_address_set_address (GDataGDPostalAddress *self, const gchar *address)
 {
+	gint len;
+
 	g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
 	g_return_if_fail (address != NULL && *address != '\0');
 
 	g_free (self->priv->address);
-	self->priv->address = g_strdup (address);
+
+	/* Trim leading and trailing whitespace from the address.
+	 * See here: http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress */
+	while (*address != '\0' && g_ascii_isspace (*address))
+		address++;
+
+	len = strlen (address);
+	while (len > 0 && g_ascii_isspace (address[len - 1]))
+		len--;
+
+	self->priv->address = g_strndup (address, len);
 	g_object_notify (G_OBJECT (self), "address");
 }
 
diff --git a/gdata/gd/gdata-gd-postal-address.h b/gdata/gd/gdata-gd-postal-address.h
index 787ae62..ca09c59 100644
--- a/gdata/gd/gdata-gd-postal-address.h
+++ b/gdata/gd/gdata-gd-postal-address.h
@@ -61,7 +61,7 @@ typedef struct {
 GType gdata_gd_postal_address_get_type (void) G_GNUC_CONST;
 
 GDataGDPostalAddress *gdata_gd_postal_address_new (const gchar *address, const gchar *relation_type,
-						 const gchar *label, gboolean is_primary) G_GNUC_WARN_UNUSED_RESULT;
+						   const gchar *label, gboolean is_primary) G_GNUC_WARN_UNUSED_RESULT;
 gint gdata_gd_postal_address_compare (const GDataGDPostalAddress *a, const GDataGDPostalAddress *b);
 
 const gchar *gdata_gd_postal_address_get_address (GDataGDPostalAddress *self);
diff --git a/gdata/gd/gdata-gd-when.c b/gdata/gd/gdata-gd-when.c
index b97a01b..3f0468d 100644
--- a/gdata/gd/gdata-gd-when.c
+++ b/gdata/gd/gdata-gd-when.c
@@ -278,7 +278,7 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 		end_time_timeval.tv_sec = end_time_timeval.tv_usec = 0;
 	}
 
-	value_string = xmlGetProp (root_node, (xmlChar*) "value");
+	value_string = xmlGetProp (root_node, (xmlChar*) "valueString");
 
 	priv->start_time = start_time_timeval;
 	priv->end_time = end_time_timeval;
@@ -348,7 +348,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 	}
 
 	if (priv->value_string != NULL)
-		g_string_append_printf (xml_string, " value='%s'", priv->value_string);
+		g_string_append_printf (xml_string, " valueString='%s'", priv->value_string);
 }
 
 static void
diff --git a/gdata/gd/gdata-gd-where.c b/gdata/gd/gdata-gd-where.c
index 716646f..2f8ca6d 100644
--- a/gdata/gd/gdata-gd-where.c
+++ b/gdata/gd/gdata-gd-where.c
@@ -231,12 +231,20 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 {
 	GDataGDWherePrivate *priv = GDATA_GD_WHERE (parsable)->priv;
 
-	if (priv->label != NULL)
-		g_string_append_printf (xml_string, " label='%s'", priv->label);
+	if (priv->label != NULL) {
+		gchar *label = g_markup_escape_text (priv->label, -1);
+		g_string_append_printf (xml_string, " label='%s'", label);
+		g_free (label);
+	}
+
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->value_string != NULL)
-		g_string_append_printf (xml_string, " valueString='%s'", priv->value_string);
+
+	if (priv->value_string != NULL) {
+		gchar *value_string = g_markup_escape_text (priv->value_string, -1);
+		g_string_append_printf (xml_string, " valueString='%s'", value_string);
+		g_free (value_string);
+	}
 }
 
 static void
@@ -290,8 +298,6 @@ gdata_gd_where_new (const gchar *relation_type, const gchar *value_string, const
 gint
 gdata_gd_where_compare (const GDataGDWhere *a, const GDataGDWhere *b)
 {
-	gint value_string_cmp;
-
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (b == NULL)
@@ -300,10 +306,9 @@ gdata_gd_where_compare (const GDataGDWhere *a, const GDataGDWhere *b)
 	if (a == b)
 		return 0;
 
-	value_string_cmp = g_strcmp0 (a->priv->value_string, b->priv->value_string);
-	if (value_string_cmp == 0 && g_strcmp0 (a->priv->label, b->priv->label))
+	if (g_strcmp0 (a->priv->value_string, b->priv->value_string) == 0 && g_strcmp0 (a->priv->label, b->priv->label) == 0)
 		return 0;
-	return value_string_cmp;
+	return 1;
 }
 
 /**
diff --git a/gdata/gd/gdata-gd-who.c b/gdata/gd/gdata-gd-who.c
index 60b2a3b..2f3417e 100644
--- a/gdata/gd/gdata-gd-who.c
+++ b/gdata/gd/gdata-gd-who.c
@@ -240,8 +240,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 		g_string_append_printf (xml_string, " email='%s'", priv->email_address);
 	if (priv->relation_type != NULL)
 		g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
-	if (priv->value_string != NULL)
-		g_string_append_printf (xml_string, " valueString='%s'", priv->value_string);
+	if (priv->value_string != NULL) {
+		gchar *value_string = g_markup_escape_text (priv->value_string, -1);
+		g_string_append_printf (xml_string, " valueString='%s'", value_string);
+		g_free (value_string);
+	}
 }
 
 static void
@@ -296,8 +299,6 @@ gdata_gd_who_new (const gchar *relation_type, const gchar *value_string, const g
 gint
 gdata_gd_who_compare (const GDataGDWho *a, const GDataGDWho *b)
 {
-	gint value_string_cmp;
-
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (b == NULL)
@@ -306,10 +307,9 @@ gdata_gd_who_compare (const GDataGDWho *a, const GDataGDWho *b)
 	if (a == b)
 		return 0;
 
-	value_string_cmp = g_strcmp0 (a->priv->value_string, b->priv->value_string);
-	if (value_string_cmp == 0 && g_strcmp0 (a->priv->email_address, b->priv->email_address))
+	if (g_strcmp0 (a->priv->value_string, b->priv->value_string) == 0 && g_strcmp0 (a->priv->email_address, b->priv->email_address) == 0)
 		return 0;
-	return value_string_cmp;
+	return 1;
 }
 
 /**
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 51c5bc6..d4a20f0 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -497,6 +497,603 @@ test_atom_link (void)
 	g_object_unref (link);
 }
 
+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,
+		"<gd:email xmlns:gd='http://schemas.google.com/g/2005' label='Personal &amp; Private' rel='http://schemas.google.com/g/2005#home' "
+			"address='fubar gmail com' primary='true'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_EMAIL_ADDRESS (email));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_email_address_get_address (email), ==, "fubar gmail com");
+	g_assert_cmpstr (gdata_gd_email_address_get_relation_type (email), ==, "http://schemas.google.com/g/2005#home";);
+	g_assert_cmpstr (gdata_gd_email_address_get_label (email), ==, "Personal & Private");
+	g_assert (gdata_gd_email_address_is_primary (email) == TRUE);
+
+	/* Compare it against another identical address */
+	email2 = gdata_gd_email_address_new ("fubar gmail com", "http://schemas.google.com/g/2005#home";, "Personal & Private", TRUE);
+	g_assert_cmpint (gdata_gd_email_address_compare (email, email2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_email_address_set_address (email2, "test example com");
+	g_assert_cmpint (gdata_gd_email_address_compare (email, email2), !=, 0);
+	g_object_unref (email2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (email));
+	g_assert_cmpstr (xml, ==,
+			 "<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' primary='true'/>");
+	g_free (xml);
+	g_object_unref (email);
+
+	/* Now parse an address with less information available */
+	email = GDATA_GD_EMAIL_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_EMAIL_ADDRESS,
+		"<gd:email xmlns:gd='http://schemas.google.com/g/2005' address='test example com'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_EMAIL_ADDRESS (email));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_email_address_get_address (email), ==, "test example com");
+	g_assert (gdata_gd_email_address_get_relation_type (email) == NULL);
+	g_assert (gdata_gd_email_address_get_label (email) == NULL);
+	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, ==,
+			 "<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);
+}
+
+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,
+		"<gd:im xmlns:gd='http://schemas.google.com/g/2005' protocol='http://schemas.google.com/g/2005#MSN' address='foo bar msn com' "
+			"rel='http://schemas.google.com/g/2005#home' primary='true'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_IM_ADDRESS (im));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_im_address_get_address (im), ==, "foo bar msn com");
+	g_assert_cmpstr (gdata_gd_im_address_get_protocol (im), ==, "http://schemas.google.com/g/2005#MSN";);
+	g_assert_cmpstr (gdata_gd_im_address_get_relation_type (im), ==, "http://schemas.google.com/g/2005#home";);
+	g_assert (gdata_gd_im_address_get_label (im) == NULL);
+	g_assert (gdata_gd_im_address_is_primary (im) == TRUE);
+
+	/* Compare it against another identical address */
+	im2 = gdata_gd_im_address_new ("foo bar msn com", "http://schemas.google.com/g/2005#MSN";, "http://schemas.google.com/g/2005#home";, NULL, TRUE);
+	g_assert_cmpint (gdata_gd_im_address_compare (im, im2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_im_address_set_protocol (im2, "http://schemas.google.com/g/2005#GOOGLE_TALK";);
+	g_assert_cmpint (gdata_gd_im_address_compare (im, im2), !=, 0);
+	g_object_unref (im2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
+	g_assert_cmpstr (xml, ==,
+			 "<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 */
+	im = GDATA_GD_IM_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_IM_ADDRESS,
+		"<gd:im xmlns:gd='http://schemas.google.com/g/2005' label='Other &amp; Miscellaneous' address='foo baz example com'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_IM_ADDRESS (im));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_im_address_get_address (im), ==, "foo baz example com");
+	g_assert (gdata_gd_im_address_get_protocol (im) == NULL);
+	g_assert (gdata_gd_im_address_get_relation_type (im) == NULL);
+	g_assert_cmpstr (gdata_gd_im_address_get_label (im), ==, "Other & Miscellaneous");
+	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, ==,
+			 "<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);
+}
+
+static void
+test_gd_organization (void)
+{
+	GDataGDOrganization *org, *org2;
+	gchar *xml;
+	GError *error = NULL;
+
+	org = GDATA_GD_ORGANIZATION (gdata_parsable_new_from_xml (GDATA_TYPE_GD_ORGANIZATION,
+		"<gd:organization xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#work' label='Work &amp; Occupation' "
+			"primary='true'>"
+			"<gd:orgName>Google, Inc.</gd:orgName>"
+			"<gd:orgTitle>&lt;Angle Bracketeer&gt;</gd:orgTitle>"
+		"</gd:organization>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_ORGANIZATION (org));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_organization_get_name (org), ==, "Google, Inc.");
+	g_assert_cmpstr (gdata_gd_organization_get_title (org), ==, "<Angle Bracketeer>");
+	g_assert_cmpstr (gdata_gd_organization_get_relation_type (org), ==, "http://schemas.google.com/g/2005#work";);
+	g_assert_cmpstr (gdata_gd_organization_get_label (org), ==, "Work & Occupation");
+	g_assert (gdata_gd_organization_is_primary (org) == TRUE);
+
+	/* Compare it against another identical organization */
+	org2 = gdata_gd_organization_new ("Google, Inc.", "<Angle Bracketeer>", "http://schemas.google.com/g/2005#work";, "Work & Occupation", TRUE);
+	g_assert_cmpint (gdata_gd_organization_compare (org, org2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_organization_set_title (org2, "Demoted!");
+	g_assert_cmpint (gdata_gd_organization_compare (org, org2), !=, 0);
+	g_object_unref (org2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
+	g_assert_cmpstr (xml, ==,
+			 "<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'>"
+				"<gd:orgName>Google, Inc.</gd:orgName>"
+				"<gd:orgTitle>&lt;Angle Bracketeer&gt;</gd:orgTitle>"
+			 "</gd:organization>");
+	g_free (xml);
+	g_object_unref (org);
+
+	/* Now parse an organization with less information available */
+	org = GDATA_GD_ORGANIZATION (gdata_parsable_new_from_xml (GDATA_TYPE_GD_ORGANIZATION,
+		"<gd:organization xmlns:gd='http://schemas.google.com/g/2005'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_ORGANIZATION (org));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert (gdata_gd_organization_get_name (org) == NULL);
+	g_assert (gdata_gd_organization_get_title (org) == NULL);
+	g_assert (gdata_gd_organization_get_relation_type (org) == NULL);
+	g_assert (gdata_gd_organization_get_label (org) == NULL);
+	g_assert (gdata_gd_organization_is_primary (org) == FALSE);
+
+	/* Check the outputted XML contains the unknown XML */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
+	g_assert_cmpstr (xml, ==,
+			 "<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);
+}
+
+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,
+		"<gd:phoneNumber xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#mobile' "
+			"label='Personal &amp; business calls only' uri='tel:+12065551212'>+1 206 555 1212</gd:phoneNumber>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_PHONE_NUMBER (phone));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_phone_number_get_number (phone), ==, "+1 206 555 1212");
+	g_assert_cmpstr (gdata_gd_phone_number_get_uri (phone), ==, "tel:+12065551212");
+	g_assert_cmpstr (gdata_gd_phone_number_get_relation_type (phone), ==, "http://schemas.google.com/g/2005#mobile";);
+	g_assert_cmpstr (gdata_gd_phone_number_get_label (phone), ==, "Personal & business calls only");
+	g_assert (gdata_gd_phone_number_is_primary (phone) == FALSE);
+
+	/* Compare it against another identical number */
+	phone2 = gdata_gd_phone_number_new ("+1 206 555 1212", "http://schemas.google.com/g/2005#mobile";, "Personal & business calls only",
+					    "tel:+12065551212", FALSE);
+	g_assert_cmpint (gdata_gd_phone_number_compare (phone, phone2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_phone_number_set_number (phone2, "+1 206 555 1212 666");
+	g_assert_cmpint (gdata_gd_phone_number_compare (phone, phone2), !=, 0);
+	g_object_unref (phone2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
+	g_assert_cmpstr (xml, ==,
+			 "<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);
+	g_object_unref (phone);
+
+	/* Now parse a phone number with less information available, but some extraneous whitespace */
+	phone = GDATA_GD_PHONE_NUMBER (gdata_parsable_new_from_xml (GDATA_TYPE_GD_PHONE_NUMBER,
+		"<gd:phoneNumber xmlns:gd='http://schemas.google.com/g/2005'>  (425) 555-8080 ext. 72585  \n </gd:phoneNumber>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_PHONE_NUMBER (phone));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_phone_number_get_number (phone), ==, "(425) 555-8080 ext. 72585");
+	g_assert (gdata_gd_phone_number_get_uri (phone) == NULL);
+	g_assert (gdata_gd_phone_number_get_relation_type (phone) == NULL);
+	g_assert (gdata_gd_phone_number_get_label (phone) == NULL);
+	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, ==,
+			 "<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);
+}
+
+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,
+		"<gd:postalAddress xmlns:gd='http://schemas.google.com/g/2005' label='Home &amp; Safe House' "
+			"rel='http://schemas.google.com/g/2005#home' primary='true'>"
+			" \t 500 West 45th Street\nNew York, NY 10036  \n  "
+		"</gd:postalAddress>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_POSTAL_ADDRESS (postal));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_postal_address_get_address (postal), ==, "500 West 45th Street\nNew York, NY 10036");
+	g_assert_cmpstr (gdata_gd_postal_address_get_relation_type (postal), ==, "http://schemas.google.com/g/2005#home";);
+	g_assert_cmpstr (gdata_gd_postal_address_get_label (postal), ==, "Home & Safe House");
+	g_assert (gdata_gd_postal_address_is_primary (postal) == TRUE);
+
+	/* Compare it against another identical address */
+	postal2 = gdata_gd_postal_address_new ("500 West 45th Street\nNew York, NY 10036", "http://schemas.google.com/g/2005#home";,
+					       "Home & Safe House", TRUE);
+	g_assert_cmpint (gdata_gd_postal_address_compare (postal, postal2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_postal_address_set_address (postal2, "Atlas Mountains");
+	g_assert_cmpint (gdata_gd_postal_address_compare (postal, postal2), !=, 0);
+	g_object_unref (postal2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (postal));
+	g_assert_cmpstr (xml, ==,
+			 "<gd:postalAddress 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'>"
+				"500 West 45th Street\nNew York, NY 10036"
+			 "</gd:postalAddress>");
+	g_free (xml);
+	g_object_unref (postal);
+
+	/* Now parse an address with less information available */
+	postal = GDATA_GD_POSTAL_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_POSTAL_ADDRESS,
+		"<gd:postalAddress xmlns:gd='http://schemas.google.com/g/2005'>f</gd:postalAddress>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_POSTAL_ADDRESS (postal));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_postal_address_get_address (postal), ==, "f");
+	g_assert (gdata_gd_postal_address_get_relation_type (postal) == NULL);
+	g_assert (gdata_gd_postal_address_get_label (postal) == NULL);
+	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, ==,
+			 "<gd:postalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' primary='false'>"
+				 "f</gd:postalAddress>");
+	g_free (xml);
+	g_object_unref (postal);
+}
+
+static void
+test_gd_reminder (void)
+{
+	GDataGDReminder *reminder, *reminder2;
+	gchar *xml;
+	GTimeVal time_val;
+	GError *error = NULL;
+
+	reminder = GDATA_GD_REMINDER (gdata_parsable_new_from_xml (GDATA_TYPE_GD_REMINDER,
+		"<gd:reminder xmlns:gd='http://schemas.google.com/g/2005' days='15'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_REMINDER (reminder));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert (gdata_gd_reminder_get_method (reminder) == NULL);
+	g_assert (gdata_gd_reminder_is_absolute_time (reminder) == FALSE);
+	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, ==,
+			 "<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 */
+	reminder = GDATA_GD_REMINDER (gdata_parsable_new_from_xml (GDATA_TYPE_GD_REMINDER,
+		"<gd:reminder xmlns:gd='http://schemas.google.com/g/2005' hours='15'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_REMINDER (reminder));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert (gdata_gd_reminder_get_method (reminder) == NULL);
+	g_assert (gdata_gd_reminder_is_absolute_time (reminder) == FALSE);
+	g_assert_cmpint (gdata_gd_reminder_get_relative_time (reminder), ==, 15 * 60);
+
+	/* Compare to another reminder */
+	reminder2 = gdata_gd_reminder_new (NULL, NULL, 15 * 60);
+	g_assert_cmpint (gdata_gd_reminder_compare (reminder, reminder2), ==, 0);
+	g_object_unref (reminder2);
+	g_object_unref (reminder);
+
+	/* â?¦and another */
+	reminder = GDATA_GD_REMINDER (gdata_parsable_new_from_xml (GDATA_TYPE_GD_REMINDER,
+		"<gd:reminder xmlns:gd='http://schemas.google.com/g/2005' minutes='15'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_REMINDER (reminder));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert (gdata_gd_reminder_get_method (reminder) == NULL);
+	g_assert (gdata_gd_reminder_is_absolute_time (reminder) == FALSE);
+	g_assert_cmpint (gdata_gd_reminder_get_relative_time (reminder), ==, 15);
+	g_object_unref (reminder);
+
+	/* Try again with an absolute time and a method */
+	reminder = GDATA_GD_REMINDER (gdata_parsable_new_from_xml (GDATA_TYPE_GD_REMINDER,
+		"<gd:reminder xmlns:gd='http://schemas.google.com/g/2005' method='alert' absoluteTime='2005-06-06T16:55:00-08:00'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_REMINDER (reminder));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_reminder_get_method (reminder), ==, "alert");
+	g_assert (gdata_gd_reminder_is_absolute_time (reminder) == TRUE);
+	gdata_gd_reminder_get_absolute_time (reminder, &time_val);
+	g_assert_cmpint (time_val.tv_sec, ==, 1118105700);
+	g_assert_cmpint (time_val.tv_usec, ==, 0);
+
+	/* Compare to another reminder */
+	reminder2 = gdata_gd_reminder_new ("alert", &time_val, -1);
+	g_assert_cmpint (gdata_gd_reminder_compare (reminder, reminder2), ==, 0);
+	g_object_unref (reminder2);
+
+	/* Check the outputted XML */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (reminder));
+	g_assert_cmpstr (xml, ==,
+			 "<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);
+}
+
+static void
+test_gd_when (void)
+{
+	GDataGDWhen *when, *when2;
+	gchar *xml;
+	GList *reminders;
+	GTimeVal time_val, time_val2;
+	GError *error = NULL;
+
+	when = GDATA_GD_WHEN (gdata_parsable_new_from_xml (GDATA_TYPE_GD_WHEN,
+		"<gd:when xmlns:gd='http://schemas.google.com/g/2005' startTime='2005-06-06T17:00:00-08:00' endTime='2005-06-06T18:00:00-08:00'/>",
+		-1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_WHEN (when));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	gdata_gd_when_get_start_time (when, &time_val);
+	g_assert_cmpint (time_val.tv_sec, ==, 1118106000);
+	g_assert_cmpint (time_val.tv_usec, ==, 0);
+	gdata_gd_when_get_end_time (when, &time_val2);
+	g_assert_cmpint (time_val2.tv_sec, ==, 1118109600);
+	g_assert_cmpint (time_val2.tv_usec, ==, 0);
+	g_assert (gdata_gd_when_is_date (when) == FALSE);
+	g_assert (gdata_gd_when_get_value_string (when) == NULL);
+	g_assert (gdata_gd_when_get_reminders (when) == NULL);
+
+	/* Compare it against another identical time */
+	when2 = gdata_gd_when_new (&time_val, &time_val2, FALSE);
+	g_assert_cmpint (gdata_gd_when_compare (when, when2), ==, 0);
+
+	/* â?¦and a different one */
+	time_val2.tv_usec = 100;
+	gdata_gd_when_set_end_time (when2, &time_val2);
+	g_assert_cmpint (gdata_gd_when_compare (when, when2), !=, 0);
+	g_object_unref (when2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
+	g_assert_cmpstr (xml, ==,
+			 "<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 */
+	when = GDATA_GD_WHEN (gdata_parsable_new_from_xml (GDATA_TYPE_GD_WHEN,
+		"<gd:when xmlns:gd='http://schemas.google.com/g/2005' startTime='2005-06-06' endTime='2005-06-08' valueString='This weekend'>"
+			"<gd:reminder minutes='15'/>"
+			"<foobar/>"
+		"</gd:when>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_WHEN (when));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	gdata_gd_when_get_start_time (when, &time_val);
+	g_assert_cmpint (time_val.tv_sec, ==, 1118016000);
+	g_assert_cmpint (time_val.tv_usec, ==, 0);
+	gdata_gd_when_get_end_time (when, &time_val2);
+	g_assert_cmpint (time_val2.tv_sec, ==, 1118188800);
+	g_assert_cmpint (time_val2.tv_usec, ==, 0);
+	g_assert (gdata_gd_when_is_date (when) == TRUE);
+	g_assert_cmpstr (gdata_gd_when_get_value_string (when), ==, "This weekend");
+
+	reminders = gdata_gd_when_get_reminders (when);
+	g_assert (reminders != NULL);
+	g_assert (GDATA_IS_GD_REMINDER (reminders->data));
+	g_assert (reminders->next == NULL);
+	g_assert (gdata_gd_reminder_is_absolute_time (GDATA_GD_REMINDER (reminders->data)) == FALSE);
+	g_assert_cmpint (gdata_gd_reminder_get_relative_time (GDATA_GD_REMINDER (reminders->data)), ==, 15);
+
+	/* Check the outputted XML is correct */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
+	g_assert_cmpstr (xml, ==,
+			 "<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'>"
+				"<gd:reminder minutes='15'/>"
+				"<foobar/>"
+			 "</gd:when>");
+	g_free (xml);
+	g_object_unref (when);
+}
+
+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,
+		"<gd:where xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#event.alternate' "
+			"label='New York Location &lt;videoconference&gt;' valueString='Metropolis'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_WHERE (where));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_where_get_relation_type (where), ==, "http://schemas.google.com/g/2005#event.alternate";);
+	g_assert_cmpstr (gdata_gd_where_get_value_string (where), ==, "Metropolis");
+	g_assert_cmpstr (gdata_gd_where_get_label (where), ==, "New York Location <videoconference>");
+
+	/* Compare it against another identical place */
+	where2 = gdata_gd_where_new ("http://schemas.google.com/g/2005#event.alternate";, "Metropolis", "New York Location <videoconference>");
+	g_assert_cmpint (gdata_gd_where_compare (where, where2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_where_set_label (where2, "Atlas Mountains");
+	g_assert_cmpint (gdata_gd_where_compare (where, where2), !=, 0);
+	g_object_unref (where2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
+	g_assert_cmpstr (xml, ==,
+			 "<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 */
+	where = GDATA_GD_WHERE (gdata_parsable_new_from_xml (GDATA_TYPE_GD_WHERE,
+		"<gd:where xmlns:gd='http://schemas.google.com/g/2005' valueString='Google Cafeteria &lt;Building 40&gt;'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_WHERE (where));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_where_get_value_string (where), ==, "Google Cafeteria <Building 40>");
+	g_assert (gdata_gd_where_get_relation_type (where) == NULL);
+	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, ==,
+			 "<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);
+}
+
+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,
+		"<gd:who xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#message.to' valueString='Elizabeth' "
+			"email='liz example com'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_WHO (who));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_gd_who_get_relation_type (who), ==, "http://schemas.google.com/g/2005#message.to";);
+	g_assert_cmpstr (gdata_gd_who_get_value_string (who), ==, "Elizabeth");
+	g_assert_cmpstr (gdata_gd_who_get_email_address (who), ==, "liz example com");
+
+	/* Compare it against another identical person */
+	who2 = gdata_gd_who_new ("http://schemas.google.com/g/2005#message.to";, "Elizabeth", "liz example com");
+	g_assert_cmpint (gdata_gd_who_compare (who, who2), ==, 0);
+
+	/* â?¦and a different one */
+	gdata_gd_who_set_email_address (who2, "john example com");
+	g_assert_cmpint (gdata_gd_who_compare (who, who2), !=, 0);
+	g_object_unref (who2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (who));
+	g_assert_cmpstr (xml, ==,
+			 "<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 */
+	who = GDATA_GD_WHO (gdata_parsable_new_from_xml (GDATA_TYPE_GD_WHO,
+		"<gd:who xmlns:gd='http://schemas.google.com/g/2005'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GD_WHO (who));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert (gdata_gd_who_get_value_string (who) == NULL);
+	g_assert (gdata_gd_who_get_relation_type (who) == NULL);
+	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, ==,
+			 "<gd:who xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'/>");
+	g_free (xml);
+	g_object_unref (who);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -509,10 +1106,21 @@ main (int argc, char *argv[])
 	g_test_add_func ("/query/categories", test_query_categories);
 	g_test_add_func ("/color/parsing", test_color_parsing);
 	g_test_add_func ("/color/output", test_color_output);
+
 	g_test_add_func ("/atom/author", test_atom_author);
 	g_test_add_func ("/atom/category", test_atom_category);
 	g_test_add_func ("/atom/generator", test_atom_generator);
 	g_test_add_func ("/atom/link", test_atom_link);
+
+	g_test_add_func ("/gd/email_address", test_gd_email_address);
+	g_test_add_func ("/gd/im_address", test_gd_im_address);
+	g_test_add_func ("/gd/organization", test_gd_organization);
+	g_test_add_func ("/gd/phone_number", test_gd_phone_number);
+	g_test_add_func ("/gd/postal_address", test_gd_postal_address);
+	g_test_add_func ("/gd/reminder", test_gd_reminder);
+	g_test_add_func ("/gd/when", test_gd_when);
+	g_test_add_func ("/gd/where", test_gd_where);
+	g_test_add_func ("/gd/who", test_gd_who);
 	/*g_test_add_data_func ("/media/thumbnail/parse_time", "", test_media_thumbnail_parse_time);
 	g_test_add_data_func ("/media/thumbnail/parse_time", "de_DE", test_media_thumbnail_parse_time);*/
 



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