summaryrefslogtreecommitdiff
path: root/tests/dbus/handle-set.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dbus/handle-set.c')
-rw-r--r--tests/dbus/handle-set.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/tests/dbus/handle-set.c b/tests/dbus/handle-set.c
index ad9f24b44..67af18409 100644
--- a/tests/dbus/handle-set.c
+++ b/tests/dbus/handle-set.c
@@ -8,9 +8,20 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/errors.h>
-int main (int argc, char **argv)
+#include "tests/lib/myassert.h"
+
+static int fail = 0;
+
+static void
+myassert_failed (void)
{
+ fail = 1;
+}
+int
+main (int argc,
+ char **argv)
+{
TpHandleRepoIface *repo = NULL;
TpHandleSet *set = NULL;
TpIntSet *iset = NULL, *result = NULL;
@@ -19,30 +30,36 @@ int main (int argc, char **argv)
g_type_init ();
- repo = (TpHandleRepoIface *)g_object_new (TP_TYPE_DYNAMIC_HANDLE_REPO,
- "handle-type", TP_HANDLE_TYPE_CONTACT, NULL);
- g_assert (repo != NULL);
+ repo = (TpHandleRepoIface *) g_object_new (TP_TYPE_DYNAMIC_HANDLE_REPO,
+ "handle-type", TP_HANDLE_TYPE_CONTACT,
+ NULL);
+ MYASSERT (repo != NULL, "");
set = tp_handle_set_new (repo);
- g_assert (set != NULL);
+ MYASSERT (set != NULL, "");
h1 = tp_handle_ensure (repo, "h1@foo", NULL, NULL);
h2 = tp_handle_ensure (repo, "h2@foo", NULL, NULL);
h3 = tp_handle_ensure (repo, "h3@foo", NULL, NULL);
h4 = tp_handle_ensure (repo, "h4@foo", NULL, NULL);
- g_assert (h1 && h2 && h3 && h4);
+ MYASSERT (h1 != 0, "");
+ MYASSERT (h2 != 0, "");
+ MYASSERT (h3 != 0, "");
+ MYASSERT (h4 != 0, "");
/* Add one handle, check that it's in, check the size */
tp_handle_set_add (set, h1);
- g_assert (tp_handle_set_is_member (set, h1));
- g_assert (tp_handle_set_size (set) == 1);
+ MYASSERT (tp_handle_set_is_member (set, h1), "");
+ MYASSERT (tp_handle_set_size (set) == 1,
+ ": size really %i", tp_handle_set_size (set));
/* Adding it again should be no-op */
tp_handle_set_add (set, h1);
- g_assert (tp_handle_set_size (set) == 1);
+ MYASSERT (tp_handle_set_size (set) == 1,
+ ": size really %i", tp_handle_set_size (set));
/* Removing a non-member should fail */
- g_assert (tp_handle_set_remove (set, h2) == FALSE);
+ MYASSERT (tp_handle_set_remove (set, h2) == FALSE, "");
/* Add some members via _update() */
iset = tp_intset_new ();
@@ -53,13 +70,13 @@ int main (int argc, char **argv)
tp_intset_destroy (iset);
/* h2 and h3 should be added, and h1 not */
- g_assert (!tp_intset_is_member (result, h1));
- g_assert (tp_intset_is_member (result, h2));
- g_assert (tp_intset_is_member (result, h3));
+ MYASSERT (!tp_intset_is_member (result, h1), "");
+ MYASSERT (tp_intset_is_member (result, h2), "");
+ MYASSERT (tp_intset_is_member (result, h3), "");
tp_intset_destroy (result);
- g_assert (tp_handle_set_is_member (set, h2));
- g_assert (tp_handle_set_is_member (set, h3));
+ MYASSERT (tp_handle_set_is_member (set, h2), "");
+ MYASSERT (tp_handle_set_is_member (set, h3), "");
/* Remove some members via _update_difference() */
iset = tp_intset_new ();
@@ -69,21 +86,22 @@ int main (int argc, char **argv)
tp_intset_destroy (iset);
/* h1 should be removed, h4 not */
- g_assert (tp_intset_is_member (result, h1));
- g_assert (!tp_intset_is_member (result, h4));
+ MYASSERT (tp_intset_is_member (result, h1), "");
+ MYASSERT (!tp_intset_is_member (result, h4), "");
tp_intset_destroy (result);
/* Removing a member should succeed */
- g_assert (tp_handle_set_remove (set, h2) == TRUE);
+ MYASSERT (tp_handle_set_remove (set, h2) == TRUE, "");
/* Finally, only h3 should be in the set */
- g_assert (tp_handle_set_is_member (set, h3));
- g_assert (tp_handle_set_size (set) == 1);
+ MYASSERT (tp_handle_set_is_member (set, h3), "");
+ MYASSERT (tp_handle_set_size (set) == 1,
+ ": size really %i", tp_handle_set_size (set));
- g_assert (tp_handle_set_remove (set, h3) == TRUE);
+ MYASSERT (tp_handle_set_remove (set, h3) == TRUE, "");
tp_handle_set_destroy (set);
g_object_unref (G_OBJECT (repo));
- return 0;
+ return fail;
}