Added test for /bookmark list

This commit is contained in:
James Booth
2014-02-01 21:18:15 +00:00
parent 1654f13656
commit 3d7d070b13
10 changed files with 169 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#include <unistd.h>
#include "common.h"
#include "helpers.h"
#include "config/preferences.h"
void init_preferences(void **state)
@@ -38,3 +39,47 @@ void close_preferences(void **state)
rmdir("./tests/files/xdg_config_home");
rmdir("./tests/files");
}
static GCompareFunc cmp_func;
void
glist_set_cmp(GCompareFunc func)
{
cmp_func = func;
}
int
glist_contents_equal(const void *actual, const void *expected)
{
GList *ac = (GList *)actual;
GList *ex = (GList *)expected;
GList *p = ex;
printf("\nExpected\n");
while(ex) {
printf("\n\n%s\n", (char*)p->data);
ex = g_list_next(ex);
}
printf("\n\n");
p = ac;
printf("\nActual\n");
while(ac) {
printf("\n\n%s\n", (char *)p->data);
ac = g_list_next(ac);
}
printf("\n\n");
if (g_list_length(ex) != g_list_length(ac)) {
return 0;
}
GList *ex_curr = ex;
while (ex_curr != NULL) {
if (g_list_find_custom(ac, ex_curr->data, cmp_func) == NULL) {
return 0;
}
ex_curr = g_list_next(ex_curr);
}
return 1;
}