X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=eglib%2Ftest%2Flist.c;h=68dadee612afd0912105c7d880468529ee79173f;hb=ca6666ddbde387185869ddf3ed62c134cd197d92;hp=ff14a93c119097c1a6c97eedf68a89f0b3f4a1c8;hpb=0443306d611d0830e27327e1f0a3ef3457dfa535;p=mono.git diff --git a/eglib/test/list.c b/eglib/test/list.c index ff14a93c119..68dadee612a 100644 --- a/eglib/test/list.c +++ b/eglib/test/list.c @@ -315,10 +315,12 @@ static int intcompare (gconstpointer p1, gconstpointer p2) 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); @@ -386,6 +388,34 @@ test_list_sort () 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}, @@ -401,6 +431,7 @@ static Test list_tests [] = { { "remove_link", test_list_remove_link}, { "remove_link", test_list_remove_link}, { "sort", test_list_sort}, + { "find_custom", test_list_find_custom}, {NULL, NULL} };