diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/eina/src/tests/eina_test_inlist.c | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2 SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz |
Update EFL to latest beta.
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/tests/eina_test_inlist.c | 171 |
1 files changed, 169 insertions, 2 deletions
diff --git a/libraries/eina/src/tests/eina_test_inlist.c b/libraries/eina/src/tests/eina_test_inlist.c index c27f393..a8631e7 100644 --- a/libraries/eina/src/tests/eina_test_inlist.c +++ b/libraries/eina/src/tests/eina_test_inlist.c | |||
@@ -34,6 +34,43 @@ struct _Eina_Test_Inlist | |||
34 | EINA_INLIST; | 34 | EINA_INLIST; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | #ifdef EINA_SAFETY_CHECKS | ||
38 | struct log_ctx { | ||
39 | const char *msg; | ||
40 | const char *fnc; | ||
41 | Eina_Bool did; | ||
42 | }; | ||
43 | |||
44 | /* tests should not output on success, just uncomment this for debugging */ | ||
45 | //#define SHOW_LOG 1 | ||
46 | |||
47 | static void | ||
48 | _eina_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args __UNUSED__) | ||
49 | { | ||
50 | struct log_ctx *ctx = data; | ||
51 | va_list cp_args; | ||
52 | const char *str; | ||
53 | |||
54 | va_copy(cp_args, args); | ||
55 | str = va_arg(cp_args, const char *); | ||
56 | va_end(cp_args); | ||
57 | |||
58 | ck_assert_int_eq(level, EINA_LOG_LEVEL_ERR); | ||
59 | ck_assert_str_eq(fmt, "%s"); | ||
60 | ck_assert_str_eq(ctx->msg, str); | ||
61 | ck_assert_str_eq(ctx->fnc, fnc); | ||
62 | ctx->did = EINA_TRUE; | ||
63 | |||
64 | #ifdef SHOW_LOG | ||
65 | eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); | ||
66 | #else | ||
67 | (void)d; | ||
68 | (void)file; | ||
69 | (void)line; | ||
70 | #endif | ||
71 | } | ||
72 | #endif | ||
73 | |||
37 | static Eina_Test_Inlist * | 74 | static Eina_Test_Inlist * |
38 | _eina_test_inlist_build(int i) | 75 | _eina_test_inlist_build(int i) |
39 | { | 76 | { |
@@ -52,6 +89,10 @@ START_TEST(eina_inlist_simple) | |||
52 | Eina_Test_Inlist *tmp; | 89 | Eina_Test_Inlist *tmp; |
53 | Eina_Test_Inlist *prev; | 90 | Eina_Test_Inlist *prev; |
54 | int i = 0; | 91 | int i = 0; |
92 | #ifdef EINA_SAFETY_CHECKS | ||
93 | Eina_Inlist *bkp; | ||
94 | struct log_ctx ctx; | ||
95 | #endif | ||
55 | 96 | ||
56 | fail_if(!eina_init()); | 97 | fail_if(!eina_init()); |
57 | 98 | ||
@@ -106,16 +147,142 @@ START_TEST(eina_inlist_simple) | |||
106 | } | 147 | } |
107 | 148 | ||
108 | #ifdef EINA_SAFETY_CHECKS | 149 | #ifdef EINA_SAFETY_CHECKS |
150 | bkp = lst; | ||
151 | eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx); | ||
152 | |||
153 | #define TEST_MAGIC_SAFETY(fn, _msg) \ | ||
154 | ctx.msg = _msg; \ | ||
155 | ctx.fnc = fn; \ | ||
156 | ctx.did = EINA_FALSE | ||
157 | |||
158 | #ifdef SHOW_LOG | ||
109 | fprintf(stderr, "you should have a safety check failure below:\n"); | 159 | fprintf(stderr, "you should have a safety check failure below:\n"); |
160 | #endif | ||
110 | { | 161 | { |
111 | Eina_Inlist *tmp2 = eina_inlist_remove(NULL, EINA_INLIST_GET(tmp)); | 162 | Eina_Inlist *tmp2; |
163 | |||
164 | TEST_MAGIC_SAFETY("eina_inlist_remove", | ||
165 | "safety check failed: list == NULL"); | ||
166 | |||
167 | tmp2 = eina_inlist_remove(NULL, EINA_INLIST_GET(tmp)); | ||
112 | fail_if(tmp2 != NULL); | 168 | fail_if(tmp2 != NULL); |
113 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | 169 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); |
170 | fail_unless(ctx.did); | ||
114 | } | 171 | } |
115 | 172 | ||
116 | fprintf(stderr, "you should have a safety check failure below:\n"); | 173 | #ifdef SHOW_LOG |
174 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
175 | #endif | ||
176 | TEST_MAGIC_SAFETY("eina_inlist_remove", | ||
177 | "safety check failed: item == NULL"); | ||
117 | lst = eina_inlist_remove(lst, NULL); | 178 | lst = eina_inlist_remove(lst, NULL); |
118 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | 179 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); |
180 | fail_unless(ctx.did); | ||
181 | |||
182 | #ifdef SHOW_LOG | ||
183 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
184 | #endif | ||
185 | TEST_MAGIC_SAFETY("eina_inlist_append", | ||
186 | "safety check failed: new_l == NULL"); | ||
187 | lst = eina_inlist_append(lst, NULL); | ||
188 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
189 | fail_unless(ctx.did); | ||
190 | |||
191 | #ifdef SHOW_LOG | ||
192 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
193 | #endif | ||
194 | TEST_MAGIC_SAFETY("eina_inlist_append_relative", | ||
195 | "safety check failed: new_l == NULL"); | ||
196 | lst = eina_inlist_append_relative(lst, NULL, NULL); | ||
197 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
198 | fail_unless(ctx.did); | ||
199 | |||
200 | #ifdef SHOW_LOG | ||
201 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
202 | #endif | ||
203 | TEST_MAGIC_SAFETY("eina_inlist_prepend", | ||
204 | "safety check failed: new_l == NULL"); | ||
205 | lst = eina_inlist_prepend(lst, NULL); | ||
206 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
207 | fail_unless(ctx.did); | ||
208 | |||
209 | #ifdef SHOW_LOG | ||
210 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
211 | #endif | ||
212 | TEST_MAGIC_SAFETY("eina_inlist_prepend_relative", | ||
213 | "safety check failed: new_l == NULL"); | ||
214 | lst = eina_inlist_prepend_relative(lst, NULL, NULL); | ||
215 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
216 | fail_unless(ctx.did); | ||
217 | |||
218 | #ifdef SHOW_LOG | ||
219 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
220 | #endif | ||
221 | TEST_MAGIC_SAFETY("eina_inlist_find", | ||
222 | "safety check failed: item == NULL"); | ||
223 | lst = eina_inlist_find(lst, NULL); | ||
224 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
225 | fail_unless(ctx.did); | ||
226 | |||
227 | #ifdef SHOW_LOG | ||
228 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
229 | #endif | ||
230 | TEST_MAGIC_SAFETY("eina_inlist_demote", | ||
231 | "safety check failed: list == NULL"); | ||
232 | lst = eina_inlist_demote(NULL, NULL); | ||
233 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
234 | fail_unless(ctx.did); | ||
235 | |||
236 | #ifdef SHOW_LOG | ||
237 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
238 | #endif | ||
239 | TEST_MAGIC_SAFETY("eina_inlist_demote", | ||
240 | "safety check failed: item == NULL"); | ||
241 | lst = eina_inlist_demote((void*)1L, NULL); | ||
242 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
243 | fail_unless(ctx.did); | ||
244 | lst = NULL; | ||
245 | |||
246 | #ifdef SHOW_LOG | ||
247 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
248 | #endif | ||
249 | TEST_MAGIC_SAFETY("eina_inlist_promote", | ||
250 | "safety check failed: list == NULL"); | ||
251 | lst = eina_inlist_promote(NULL, NULL); | ||
252 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
253 | fail_unless(ctx.did); | ||
254 | |||
255 | #ifdef SHOW_LOG | ||
256 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
257 | #endif | ||
258 | TEST_MAGIC_SAFETY("eina_inlist_promote", | ||
259 | "safety check failed: item == NULL"); | ||
260 | lst = eina_inlist_promote((void*)1L, NULL); | ||
261 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
262 | fail_unless(ctx.did); | ||
263 | lst = NULL; | ||
264 | |||
265 | #ifdef SHOW_LOG | ||
266 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
267 | #endif | ||
268 | TEST_MAGIC_SAFETY("eina_inlist_sorted_insert", | ||
269 | "safety check failed: item == NULL"); | ||
270 | lst = eina_inlist_sorted_insert(NULL, NULL, NULL); | ||
271 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
272 | fail_unless(ctx.did); | ||
273 | |||
274 | #ifdef SHOW_LOG | ||
275 | fprintf(stderr, "you should have a safety check failure below:\n"); | ||
276 | #endif | ||
277 | TEST_MAGIC_SAFETY("eina_inlist_sorted_insert", | ||
278 | "safety check failed: func == NULL"); | ||
279 | lst = eina_inlist_sorted_insert(NULL, (void*)1L, NULL); | ||
280 | fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); | ||
281 | fail_unless(ctx.did); | ||
282 | lst = NULL; | ||
283 | |||
284 | eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); | ||
285 | lst = bkp; | ||
119 | #endif | 286 | #endif |
120 | 287 | ||
121 | tmp = EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist); | 288 | tmp = EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist); |