Add support for serializing tdbPersonalOwnerInfo
[libisds.git] / test / offline / isds_list_free.c
blobadc744072d0730b21c56eac49a053c7794b12327
1 #include "../test.h"
2 #include "isds.h"
4 int counter;
6 static void destructor(void **data) {
7 (void)data;
8 counter++;
11 static int test_isds_list_free(struct isds_list **list, int destructor_hits) {
12 counter = 0;
14 isds_list_free(list);
16 if (destructor_hits != counter)
17 FAIL_TEST("Destructor called wrong times: expected=%d, called=%d",
18 destructor_hits, counter);
20 if (!list) PASS_TEST;
22 if (*list)
23 FAIL_TEST("isds_list_free() did not null pointer");
25 PASS_TEST;
29 int main(void) {
31 INIT_TEST("isds_list_free()");
32 if (isds_init())
33 ABORT_UNIT("isds_init() failed");
36 /* isds_list_free() */
37 struct isds_list *list = NULL;
38 TEST("NULL", test_isds_list_free, NULL, 0);
39 TEST("*NULL", test_isds_list_free, &list, 0);
41 TEST_CALLOC(list);
42 TEST("One item without destructor", test_isds_list_free, &list, 0);
44 TEST_CALLOC(list);
45 list->destructor = destructor;
46 TEST("One item with destructor", test_isds_list_free, &list, 1);
48 TEST_CALLOC(list);
49 list->destructor = destructor;
50 TEST_CALLOC(list->next);
51 list->next->destructor = destructor;
52 TEST("Two items list", test_isds_list_free, &list, 2);
54 isds_cleanup();
55 SUM_TEST();