diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/tests/eina_test_clist.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/tests/eina_test_clist.c')
-rw-r--r-- | libraries/eina/src/tests/eina_test_clist.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_clist.c b/libraries/eina/src/tests/eina_test_clist.c new file mode 100644 index 0000000..901c0e8 --- /dev/null +++ b/libraries/eina/src/tests/eina_test_clist.c | |||
@@ -0,0 +1,89 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | #include <string.h> | ||
7 | #include <assert.h> | ||
8 | |||
9 | #include <Eina.h> | ||
10 | #include "eina_suite.h" | ||
11 | |||
12 | Eina_Clist string_list = EINA_CLIST_INIT(string_list); | ||
13 | |||
14 | struct test_string | ||
15 | { | ||
16 | Eina_Clist entry; | ||
17 | const char *string; | ||
18 | }; | ||
19 | |||
20 | static void add_string(const char *foo) | ||
21 | { | ||
22 | struct test_string *t; | ||
23 | |||
24 | t = malloc(sizeof *t); | ||
25 | assert(t != NULL); | ||
26 | |||
27 | t->string = foo; | ||
28 | eina_clist_add_tail(&string_list, &t->entry); | ||
29 | } | ||
30 | |||
31 | static void print_strings(void) | ||
32 | { | ||
33 | struct test_string *str; | ||
34 | |||
35 | EINA_CLIST_FOR_EACH_ENTRY(str, &string_list, struct test_string, entry) | ||
36 | { | ||
37 | printf("%s ", str->string); | ||
38 | } | ||
39 | printf("\n"); | ||
40 | } | ||
41 | |||
42 | static void free_list(void) | ||
43 | { | ||
44 | struct test_string *str, *tmp; | ||
45 | |||
46 | EINA_CLIST_FOR_EACH_ENTRY_SAFE(str, tmp, &string_list, struct test_string, entry) | ||
47 | { | ||
48 | eina_clist_remove(&str->entry); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | START_TEST(eina_clist_basic) | ||
53 | { | ||
54 | unsigned int n = 0; | ||
55 | |||
56 | add_string("this"); | ||
57 | n++; | ||
58 | add_string("is"); | ||
59 | n++; | ||
60 | add_string("a"); | ||
61 | n++; | ||
62 | add_string("test"); | ||
63 | n++; | ||
64 | add_string("of"); | ||
65 | n++; | ||
66 | add_string("clists"); | ||
67 | n++; | ||
68 | add_string("-"); | ||
69 | n++; | ||
70 | add_string("hello"); | ||
71 | n++; | ||
72 | add_string("world"); | ||
73 | n++; | ||
74 | |||
75 | fail_if(eina_clist_count(&string_list) != n); | ||
76 | |||
77 | print_strings(); | ||
78 | |||
79 | free_list(); | ||
80 | |||
81 | fail_if(eina_clist_count(&string_list) != 0); | ||
82 | } | ||
83 | END_TEST | ||
84 | |||
85 | void | ||
86 | eina_test_clist(TCase *tc) | ||
87 | { | ||
88 | tcase_add_test(tc, eina_clist_basic); | ||
89 | } | ||