From: <svn...@op...> - 2009-08-07 17:37:11
|
Author: bellmich Date: Fri Aug 7 19:36:58 2009 New Revision: 1231 URL: http://libsyncml.opensync.org/changeset/1231 Log: updated SmlLocation If something is out of memory then it is a good idea to use g_error because this is a fatal event. Deleted: trunk/libsyncml/data_sync_api/sml_location_internals.h Modified: trunk/libsyncml/data_sync_api/sml_location.c trunk/libsyncml/data_sync_api/sml_location.h trunk/tests/check_data_sync_api_location.c Modified: trunk/libsyncml/data_sync_api/sml_location.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_location.c Fri Aug 7 19:35:36 2009 (r1230) +++ trunk/libsyncml/data_sync_api/sml_location.c Fri Aug 7 19:36:58 2009 (r1231) @@ -18,8 +18,7 @@ * Boston, MA 02110-1301 USA */ -#include "sml_location_internals.h" -#include "../sml_error_internals.h" +#include "sml_location.h" #include <string.h> G_DEFINE_TYPE (SmlLocation, sml_location, G_TYPE_OBJECT) @@ -173,36 +172,6 @@ } /** - * sml_location_new_with_options: - * - * Creates a new instance of #SmlLocation. - * - * Return value: the newly created #SmlLocation instance - */ -SmlLocation* -sml_location_new_with_options (const gchar* uid, - const gchar* name, - GError **error) -{ - CHECK_ERROR_REF - - SmlLocation *loc = sml_location_new(); - sml_return_val_error_if_fail (SML_IS_LOCATION (loc), NULL, error, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); - - if (!sml_location_set_uri(loc, uid, error)) { - g_object_unref(loc); - return NULL; - } - - if (!sml_location_set_name(loc, name, error)) { - g_object_unref(loc); - return NULL; - } - - return loc; -} - -/** * sml_location_get_uri: * @self: A #SmlLocation * @@ -224,13 +193,11 @@ * * Sets the URI property. */ -gboolean +void sml_location_set_uri (SmlLocation *self, - const gchar* uri, - GError **error) + const gchar* uri) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (SML_IS_LOCATION (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlLocation object."); + g_assert(SML_IS_LOCATION (self)); /* normalize the URI */ if (uri && strlen(uri) == 0) @@ -238,9 +205,8 @@ g_free (self->priv->uri); self->priv->uri = g_strdup (uri); - sml_return_val_error_if_fail (!uri || self->priv->uri, FALSE, error, SML_ERROR_GENERIC, "Cannot copy the URI - out of memory."); - - return TRUE; + if (uri && !self->priv->uri) + g_error("Cannot copy the URI - out of memory."); } /** @@ -265,13 +231,11 @@ * * Sets the name property. */ -gboolean +void sml_location_set_name (SmlLocation *self, - const gchar* name, - GError **error) + const gchar* name) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (SML_IS_LOCATION (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlLocation object."); + g_assert(SML_IS_LOCATION (self)); /* normalize the name */ if (name && strlen(name) == 0) @@ -279,9 +243,8 @@ g_free (self->priv->name); self->priv->name = g_strdup (name); - sml_return_val_error_if_fail (!name || self->priv->name, FALSE, error, SML_ERROR_GENERIC, "Cannot copy the name - out of memory."); - - return TRUE; + if (name && !self->priv->name) + g_error("Cannot copy the name - out of memory."); } /** @@ -306,13 +269,11 @@ * * Sets the parentURI property. */ -gboolean +void sml_location_set_parent_uri (SmlLocation *self, - const gchar* parent_uri, - GError **error) + const gchar* parent_uri) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (SML_IS_LOCATION (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlLocation object."); + g_assert(SML_IS_LOCATION (self)); /* normalize the parent URI */ if (parent_uri && strlen(parent_uri) == 0) @@ -320,9 +281,8 @@ g_free (self->priv->parent_uri); self->priv->parent_uri = g_strdup (parent_uri); - sml_return_val_error_if_fail (!parent_uri || self->priv->parent_uri, FALSE, error, SML_ERROR_GENERIC, "Cannot copy the parent URI - out of memory."); - - return TRUE; + if (parent_uri && !self->priv->parent_uri) + g_error("Cannot copy the parent URI - out of memory."); } /** @@ -332,26 +292,19 @@ * */ SmlLocation* -sml_location_clone (SmlLocation *self, - GError **error) +sml_location_clone (SmlLocation *self) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (SML_IS_LOCATION (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlLocation object."); + g_assert(self); SmlLocation *loc = sml_location_new(); - sml_return_val_error_if_fail (SML_IS_LOCATION (self), FALSE, error, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); - if (self->priv->uri && !sml_location_set_uri(loc, self->priv->uri, error)) { - g_object_unref(loc); - return NULL; - } - if (self->priv->name && !sml_location_set_name(loc, self->priv->name, error)) { - g_object_unref(loc); - return NULL; - } - if (self->priv->parent_uri && !sml_location_set_parent_uri(loc, self->priv->parent_uri, error)) { - g_object_unref(loc); - return NULL; - } + if (!loc) + g_error("Cannot create new SmlLocation object - out of memory."); + if (self->priv->uri) + sml_location_set_uri(loc, self->priv->uri); + if (self->priv->name) + sml_location_set_name(loc, self->priv->name); + if (self->priv->parent_uri) + sml_location_set_parent_uri(loc, self->priv->parent_uri); return loc; } @@ -365,32 +318,33 @@ static gchar* _sml_location_strreplace (const gchar *input, const gchar *needle, - const gchar *replacement, - GError **error) + const gchar *replacement) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (input, NULL, error, SML_ERROR_GENERIC, "There must be an input string."); - sml_return_val_error_if_fail (strlen(input) > 0, NULL, error, SML_ERROR_GENERIC, "The input string cannot be an empty string."); - sml_return_val_error_if_fail (needle, NULL, error, SML_ERROR_GENERIC, "There must be a needle string."); - sml_return_val_error_if_fail (strlen(needle) > 0, NULL, error, SML_ERROR_GENERIC, "The needle string cannot be an empty string."); + g_assert(input); + g_assert(strlen(input) > 0); + g_assert(needle); + g_assert(strlen(needle) > 0); /* normalize the replacement string */ if (replacement != NULL && strlen(replacement) == 0) replacement = NULL; gchar *output = g_strdup(input); - sml_return_val_error_if_fail (output, NULL, error, SML_ERROR_GENERIC, "Cannot duplicate input string - out of memory."); + if (!output) + g_error("Cannot duplicate input string - out of memory."); /* loop until there is no needle */ while (g_strrstr(output, needle)) { /* copy the string until the position of the needle */ gchar *prefix = g_strndup(output, g_strrstr(output, needle) - output); - sml_return_val_error_if_fail (prefix, NULL, error, SML_ERROR_GENERIC, "Cannot copy string before the needle - out of memory."); + if (!prefix) + g_error("Cannot copy string before the needle - out of memory."); /* concatenate prefix of needle, replacement and suffix of needle */ gchar *buffer2 = g_strconcat(prefix, replacement ? replacement : "", g_strrstr(output, needle) + strlen(needle), NULL); - sml_return_val_error_if_fail (buffer2, NULL, error, SML_ERROR_GENERIC, "Cannot create new string with replacement - out of memory."); + if (!buffer2) + g_error("Cannot create new string with replacement - out of memory."); /* cleanup */ g_free(prefix); @@ -402,22 +356,16 @@ } static gchar* -_sml_location_get_normalized_uri (const gchar *uri, - GError **error) +_sml_location_get_normalized_uri (const gchar *uri) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (uri, NULL, error, SML_ERROR_GENERIC, "There must be an URI."); - sml_return_val_error_if_fail (strlen(uri) > 0, NULL, error, SML_ERROR_GENERIC, "The URI cannot be an empty string."); + g_assert(uri); + g_assert(strlen(uri) > 0); /* remove ./ (e.g. "./Contacts" will be "Contacts") */ - gchar *buffer = _sml_location_strreplace(uri, "./", "", error); - if (!buffer) - return NULL; + gchar *buffer = _sml_location_strreplace(uri, "./", ""); /* replace // from Windows-like systems (e.g. "//Contacts" will be "/Contacts") */ - gchar *buffer2 = _sml_location_strreplace(buffer, "//", "/", error); - if (!buffer2) - return NULL; + gchar *buffer2 = _sml_location_strreplace(buffer, "//", "/"); /* cleanup */ g_free(buffer); @@ -441,11 +389,9 @@ * Return value: */ G_CONST_RETURN gchar* -sml_location_get_full_uri (SmlLocation *self, - GError **error) +sml_location_get_full_uri (SmlLocation *self) { - CHECK_ERROR_REF - sml_return_val_error_if_fail (SML_IS_LOCATION (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlLocation object."); + g_assert(SML_IS_LOCATION (self)); /* cleanup cache */ if (self->priv->full_uri) { @@ -456,20 +402,14 @@ /* normalize URI */ gchar *path = NULL; if (self->priv->uri) { - path = _sml_location_get_normalized_uri(self->priv->uri, error); - if (!path) - return NULL; + path = _sml_location_get_normalized_uri(self->priv->uri); } /* add parent (e.g. TargetRef or SourceRef from hierarchical sync) */ if (self->priv->parent_uri) { /* normalize parent */ - gchar *parent_uri = _sml_location_get_normalized_uri(self->priv->parent_uri, error); - if (!parent_uri) { - g_free(path); - return NULL; - } + gchar *parent_uri = _sml_location_get_normalized_uri(self->priv->parent_uri); /* ensure absolute URI */ if (path && !g_path_is_absolute(path)) { @@ -477,8 +417,7 @@ g_free(path); path = absolute; if (!path) - g_free(parent_uri); - sml_return_val_error_if_fail (path, NULL, error, SML_ERROR_GENERIC, "Cannot add '/' as prefix - out of memory."); + g_error("Cannot add '/' as prefix - out of memory."); } /* prepend the parent */ @@ -486,11 +425,12 @@ g_free(path); g_free(parent_uri); path = parent; - sml_return_val_error_if_fail (path, NULL, error, SML_ERROR_GENERIC, "Cannot add parent as prefix - out of memory."); + if (!path) + g_error("Cannot add parent as prefix - out of memory."); } /* cache the result */ - self->priv->full_uri = _sml_location_get_normalized_uri(path, error); + self->priv->full_uri = _sml_location_get_normalized_uri(path); g_free(path); return self->priv->full_uri; @@ -506,9 +446,8 @@ sml_location_is_equal (SmlLocation *self, SmlLocation *loc) { - g_return_val_if_fail (SML_IS_LOCATION (self), FALSE); + g_assert(self); - GError *error = NULL; gboolean ret = FALSE; if (!loc) @@ -516,19 +455,8 @@ /* normalization */ - const char *loc_path = sml_location_get_full_uri(loc, &error); - if (!loc_path) { - g_warning("%s", error->message); - g_error_free(error); - return FALSE; - } - - const char *self_path = sml_location_get_full_uri(self, &error); - if (!self_path) { - g_warning("%s", error->message); - g_error_free(error); - return FALSE; - } + const char *loc_path = sml_location_get_full_uri(loc); + const char *self_path = sml_location_get_full_uri(self); /* comparison */ Modified: trunk/libsyncml/data_sync_api/sml_location.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_location.h Fri Aug 7 19:35:36 2009 (r1230) +++ trunk/libsyncml/data_sync_api/sml_location.h Fri Aug 7 19:36:58 2009 (r1231) @@ -53,14 +53,14 @@ GType sml_location_get_type (void); SmlLocation* sml_location_new (void); G_CONST_RETURN gchar* sml_location_get_uri (SmlLocation *self); -gboolean sml_location_set_uri (SmlLocation *self, const gchar* uri, GError **error); +void sml_location_set_uri (SmlLocation *self, const gchar* uri); G_CONST_RETURN gchar* sml_location_get_name (SmlLocation *self); -gboolean sml_location_set_name (SmlLocation *self, const gchar* name, GError **error); +void sml_location_set_name (SmlLocation *self, const gchar* name); G_CONST_RETURN gchar* sml_location_get_parent_uri (SmlLocation *self); -gboolean sml_location_set_parent_uri (SmlLocation *self, const gchar* parent_uri, GError **error); -SmlLocation* sml_location_clone (SmlLocation *self, GError **error); +void sml_location_set_parent_uri (SmlLocation *self, const gchar* parent_uri); +SmlLocation* sml_location_clone (SmlLocation *self); gboolean sml_location_is_equal (SmlLocation *self, SmlLocation *loc); -G_CONST_RETURN gchar* sml_location_get_full_uri (SmlLocation *self, GError **error); +G_CONST_RETURN gchar* sml_location_get_full_uri (SmlLocation *self); G_END_DECLS Modified: trunk/tests/check_data_sync_api_location.c ============================================================================== --- trunk/tests/check_data_sync_api_location.c Fri Aug 7 19:35:36 2009 (r1230) +++ trunk/tests/check_data_sync_api_location.c Fri Aug 7 19:36:58 2009 (r1231) @@ -35,24 +35,21 @@ START_TEST (location_uri) { setup_testbed(NULL); - GError *error = NULL; + SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); sml_fail_unless(sml_location_get_uri(location) == NULL, "The default URI must be NULL."); - sml_fail_unless(sml_location_set_uri(location, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, NULL); sml_fail_unless(sml_location_get_uri(location) == NULL, "The URI must still be NULL."); - sml_fail_unless(sml_location_set_uri(location, "http://localhost", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "http://localhost"); const gchar *uri = sml_location_get_uri(location); sml_fail_unless(uri != NULL, "The URI is now set."); sml_fail_unless(strcmp(uri, "http://localhost") == 0, "The URI must be set to http://localhost."); - sml_fail_unless(sml_location_set_uri(location, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, NULL); sml_fail_unless(sml_location_get_uri(location) == NULL, "The URI must be NULL again."); g_object_unref(location); @@ -62,24 +59,21 @@ START_TEST (location_name) { setup_testbed(NULL); - GError *error = NULL; + SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); sml_fail_unless(sml_location_get_name(location) == NULL, "The default name must be NULL."); - sml_fail_unless(sml_location_set_name(location, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_name(location, NULL); sml_fail_unless(sml_location_get_name(location) == NULL, "The name must still be NULL."); - sml_fail_unless(sml_location_set_name(location, "John Doe", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_name(location, "John Doe"); const gchar *name = sml_location_get_name(location); sml_fail_unless(name != NULL, "The name is now set."); sml_fail_unless(strcmp(name, "John Doe") == 0, "The name must be set to 'John Doe'."); - sml_fail_unless(sml_location_set_name(location, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_name(location, NULL); sml_fail_unless(sml_location_get_name(location) == NULL, "The name must be NULL again."); g_object_unref(location); @@ -89,24 +83,21 @@ START_TEST (location_parent_uri) { setup_testbed(NULL); - GError *error = NULL; + SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); sml_fail_unless(sml_location_get_parent_uri(location) == NULL, "The default parent URI must be NULL."); - sml_fail_unless(sml_location_set_parent_uri(location, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(location, NULL); sml_fail_unless(sml_location_get_parent_uri(location) == NULL, "The parent URI must still be NULL."); - sml_fail_unless(sml_location_set_parent_uri(location, "http://localhost", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(location, "http://localhost"); const gchar *parent_uri = sml_location_get_parent_uri(location); sml_fail_unless(parent_uri != NULL, "The parent URI is now set."); sml_fail_unless(strcmp(parent_uri, "http://localhost") == 0, "The parent URI must be set to http://localhost."); - sml_fail_unless(sml_location_set_parent_uri(location, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(location, NULL); sml_fail_unless(sml_location_get_parent_uri(location) == NULL, "The parent URI must be NULL again."); g_object_unref(location); @@ -117,17 +108,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc, "./test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc2, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc2, "./test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -140,17 +127,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc, "./test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc2, "./test2", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc2, "./test2"); sml_fail_unless(!sml_location_is_equal(objloc, objloc2), NULL); @@ -163,17 +146,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc, "/test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc2, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc2, "/test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -186,17 +165,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc, "/test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_uri(objloc2, "/test2", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(objloc2, "/test2"); sml_fail_unless(!sml_location_is_equal(objloc, objloc2), NULL); @@ -209,17 +184,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "./test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "./test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -232,17 +203,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "./test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "./test2", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "./test2"); sml_fail_unless(!sml_location_is_equal(objloc, objloc2), NULL); @@ -255,17 +222,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -278,17 +241,13 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test2", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test2"); sml_fail_unless(!sml_location_is_equal(objloc, objloc2), NULL); @@ -301,19 +260,15 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test"); + sml_location_set_uri(objloc, "./test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc2, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test"); + sml_location_set_uri(objloc2, "./test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -326,19 +281,15 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc, "test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test"); + sml_location_set_uri(objloc, "test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc2, "./test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test"); + sml_location_set_uri(objloc2, "./test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -351,19 +302,15 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test/asd", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc, "test/", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test/asd"); + sml_location_set_uri(objloc, "test/"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test/.//asd//", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc2, "././test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test/.//asd//"); + sml_location_set_uri(objloc2, "././test"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -376,19 +323,15 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test/asd2", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc, "test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test/asd2"); + sml_location_set_uri(objloc, "test"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test/.//asd//", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc2, "././test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test/.//asd//"); + sml_location_set_uri(objloc2, "././test"); sml_fail_unless(!sml_location_is_equal(objloc, objloc2), NULL); @@ -401,19 +344,15 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/test/asd", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc, "tes3t", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/test/asd"); + sml_location_set_uri(objloc, "tes3t"); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, "/test/.//asd//", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc2, "././test", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, "/test/.//asd//"); + sml_location_set_uri(objloc2, "././test"); sml_fail_unless(!sml_location_is_equal(objloc, objloc2), NULL); @@ -426,19 +365,15 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlLocation *objloc = sml_location_new(); sml_fail_unless(objloc != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc, "/", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc, "", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc, "/"); + sml_location_set_uri(objloc, ""); SmlLocation *objloc2 = sml_location_new(); sml_fail_unless(objloc2 != NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(objloc2, ".//", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(sml_location_set_uri(objloc2, "///", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_parent_uri(objloc2, ".//"); + sml_location_set_uri(objloc2, "///"); sml_fail_unless(sml_location_is_equal(objloc, objloc2), NULL); @@ -451,11 +386,10 @@ { setup_testbed(NULL); - GError *error = NULL; SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(sml_location_set_uri(loc, "test", &error), "%s", error?error->message:"No GError set."); + sml_location_set_uri(loc, "test"); g_object_ref(loc); |