static gboolean verify_sort (GList *list, int len)
{
+ int prev;
+
if (list->prev)
return FALSE;
- int prev = GPOINTER_TO_INT (list->data);
+ prev = GPOINTER_TO_INT (list->data);
len--;
for (list = list->next; list; list = list->next) {
int curr = GPOINTER_TO_INT (list->data);
return OK;
}
+static gint
+find_custom (gconstpointer a, gconstpointer b)
+{
+ return(strcmp (a, b));
+}
+
+RESULT
+test_list_find_custom ()
+{
+ GList *list = NULL, *found;
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+
+ list = g_list_prepend (list, baz);
+ list = g_list_prepend (list, bar);
+ list = g_list_prepend (list, foo);
+
+ found = g_list_find_custom (list, baz, find_custom);
+
+ if (found == NULL)
+ return FAILED ("Find failed");
+
+ g_list_free (list);
+
+ return OK;
+}
+
static Test list_tests [] = {
{ "length", test_list_length},
{ "nth", test_list_nth},
{ "remove_link", test_list_remove_link},
{ "remove_link", test_list_remove_link},
{ "sort", test_list_sort},
+ { "find_custom", test_list_find_custom},
{NULL, NULL}
};