blob: 115afc233eed7de7622e19f146ce04db7387ead0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "Eina.h"
#include "eina_suite.h"
Eina_Clist string_list = EINA_CLIST_INIT(string_list);
struct test_string
{
Eina_Clist entry;
const char *string;
};
static void add_string(const char *foo)
{
struct test_string *t;
t = malloc(sizeof *t);
assert(t != NULL);
t->string = foo;
eina_clist_add_tail(&string_list, &t->entry);
}
static void print_strings(void)
{
struct test_string *str;
EINA_CLIST_FOR_EACH_ENTRY(str, &string_list, struct test_string, entry)
{
printf("%s ", str->string);
}
printf("\n");
}
static void free_list(void)
{
struct test_string *str, *tmp;
EINA_CLIST_FOR_EACH_ENTRY_SAFE(str, tmp, &string_list, struct test_string, entry)
{
eina_clist_remove(&str->entry);
}
}
START_TEST(eina_clist_basic)
{
unsigned int n = 0;
add_string("this");
n++;
add_string("is");
n++;
add_string("a");
n++;
add_string("test");
n++;
add_string("of");
n++;
add_string("clists");
n++;
add_string("-");
n++;
add_string("hello");
n++;
add_string("world");
n++;
fail_if(eina_clist_count(&string_list) != n);
print_strings();
free_list();
fail_if(eina_clist_count(&string_list) != 0);
}
END_TEST
void
eina_test_clist(TCase *tc)
{
tcase_add_test(tc, eina_clist_basic);
}
|