diff options
author | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
commit | 825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch) | |
tree | 75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/eina/src/tests/eina_test_value.c | |
parent | Add ability to disable the test harness, or the Lua compile test. (diff) | |
download | SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2 SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz |
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/tests/eina_test_value.c | 1799 |
1 files changed, 1799 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_value.c b/libraries/eina/src/tests/eina_test_value.c new file mode 100644 index 0000000..2d04c2f --- /dev/null +++ b/libraries/eina/src/tests/eina_test_value.c | |||
@@ -0,0 +1,1799 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2012 ProFUSION embedded systems | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; | ||
16 | * if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include "config.h" | ||
21 | #endif | ||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <inttypes.h> | ||
25 | |||
26 | #include "eina_suite.h" | ||
27 | #include "Eina.h" | ||
28 | |||
29 | #define FP_ERR (0.0000001) | ||
30 | #define CHECK_FP(a, b) ((a - b) < FP_ERR) | ||
31 | |||
32 | START_TEST(eina_value_test_simple) | ||
33 | { | ||
34 | Eina_Value *value; | ||
35 | char c; | ||
36 | short s; | ||
37 | int i; | ||
38 | long l; | ||
39 | int64_t i64; | ||
40 | unsigned char uc; | ||
41 | unsigned short us; | ||
42 | unsigned int ui; | ||
43 | unsigned long ul; | ||
44 | uint64_t u64; | ||
45 | float f; | ||
46 | double d; | ||
47 | |||
48 | eina_init(); | ||
49 | |||
50 | value = eina_value_new(EINA_VALUE_TYPE_CHAR); | ||
51 | fail_unless(value != NULL); | ||
52 | fail_unless(eina_value_set(value, 'x')); | ||
53 | fail_unless(eina_value_get(value, &c)); | ||
54 | fail_unless(c == 'x'); | ||
55 | eina_value_flush(value); | ||
56 | |||
57 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_SHORT)); | ||
58 | fail_unless(eina_value_set(value, 300)); | ||
59 | fail_unless(eina_value_get(value, &s)); | ||
60 | fail_unless(s == 300); | ||
61 | eina_value_flush(value); | ||
62 | |||
63 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT)); | ||
64 | fail_unless(eina_value_set(value, -12345)); | ||
65 | fail_unless(eina_value_get(value, &i)); | ||
66 | fail_unless(i == -12345); | ||
67 | eina_value_flush(value); | ||
68 | |||
69 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_LONG)); | ||
70 | fail_unless(eina_value_set(value, 0xb33f)); | ||
71 | fail_unless(eina_value_get(value, &l)); | ||
72 | fail_unless(l == 0xb33f); | ||
73 | eina_value_flush(value); | ||
74 | |||
75 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT64)); | ||
76 | fail_unless(eina_value_set(value, 0x0011223344556677)); | ||
77 | fail_unless(eina_value_get(value, &i64)); | ||
78 | fail_unless(i64 == 0x0011223344556677); | ||
79 | eina_value_flush(value); | ||
80 | |||
81 | /* unsigned: */ | ||
82 | |||
83 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UCHAR)); | ||
84 | fail_unless(eina_value_set(value, 200)); | ||
85 | fail_unless(eina_value_get(value, &uc)); | ||
86 | fail_unless(uc == 200); | ||
87 | eina_value_flush(value); | ||
88 | |||
89 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_USHORT)); | ||
90 | fail_unless(eina_value_set(value, 65535)); | ||
91 | fail_unless(eina_value_get(value, &us)); | ||
92 | fail_unless(us == 65535); | ||
93 | eina_value_flush(value); | ||
94 | |||
95 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT)); | ||
96 | fail_unless(eina_value_set(value, 4000000000U)); | ||
97 | fail_unless(eina_value_get(value, &ui)); | ||
98 | fail_unless(ui == 4000000000U); | ||
99 | eina_value_flush(value); | ||
100 | |||
101 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_ULONG)); | ||
102 | fail_unless(eina_value_set(value, 3000000001U)); | ||
103 | fail_unless(eina_value_get(value, &ul)); | ||
104 | fail_unless(ul == 3000000001U); | ||
105 | eina_value_flush(value); | ||
106 | |||
107 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT64)); | ||
108 | fail_unless(eina_value_set(value, 0x1122334455667788)); | ||
109 | fail_unless(eina_value_get(value, &u64)); | ||
110 | fail_unless(u64 == 0x1122334455667788); | ||
111 | eina_value_flush(value); | ||
112 | |||
113 | /* floating point */ | ||
114 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)); | ||
115 | fail_unless(eina_value_set(value, 0.1234)); | ||
116 | fail_unless(eina_value_get(value, &f)); | ||
117 | fail_unless(CHECK_FP(0.1234, f)); | ||
118 | eina_value_flush(value); | ||
119 | |||
120 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_DOUBLE)); | ||
121 | fail_unless(eina_value_set(value, 34567.8)); | ||
122 | fail_unless(eina_value_get(value, &d)); | ||
123 | fail_unless(CHECK_FP(34567.8, d)); | ||
124 | eina_value_flush(value); | ||
125 | |||
126 | eina_value_free(value); | ||
127 | eina_shutdown(); | ||
128 | } | ||
129 | END_TEST | ||
130 | |||
131 | START_TEST(eina_value_test_compare) | ||
132 | { | ||
133 | Eina_Value *a, *b; | ||
134 | |||
135 | eina_init(); | ||
136 | |||
137 | a = eina_value_new(EINA_VALUE_TYPE_CHAR); | ||
138 | fail_unless(a != NULL); | ||
139 | b = eina_value_new(EINA_VALUE_TYPE_CHAR); | ||
140 | fail_unless(b != NULL); | ||
141 | |||
142 | fail_unless(eina_value_set(a, 123)); | ||
143 | fail_unless(eina_value_set(b, 123)); | ||
144 | fail_unless(eina_value_compare(a, b) == 0); | ||
145 | fail_unless(eina_value_set(a, -10)); | ||
146 | fail_unless(eina_value_set(b, 123)); | ||
147 | fail_unless(eina_value_compare(a, b) < 0); | ||
148 | fail_unless(eina_value_set(a, 123)); | ||
149 | fail_unless(eina_value_set(b, 10)); | ||
150 | fail_unless(eina_value_compare(a, b) > 0); | ||
151 | eina_value_flush(a); | ||
152 | eina_value_flush(b); | ||
153 | |||
154 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_SHORT)); | ||
155 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_SHORT)); | ||
156 | fail_unless(eina_value_set(a, 1230)); | ||
157 | fail_unless(eina_value_set(b, 1230)); | ||
158 | fail_unless(eina_value_compare(a, b) == 0); | ||
159 | fail_unless(eina_value_set(a, -100)); | ||
160 | fail_unless(eina_value_set(b, 1230)); | ||
161 | fail_unless(eina_value_compare(a, b) < 0); | ||
162 | fail_unless(eina_value_set(a, 1230)); | ||
163 | fail_unless(eina_value_set(b, -100)); | ||
164 | fail_unless(eina_value_compare(a, b) > 0); | ||
165 | eina_value_flush(a); | ||
166 | eina_value_flush(b); | ||
167 | |||
168 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_INT)); | ||
169 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_INT)); | ||
170 | fail_unless(eina_value_set(a, 300000)); | ||
171 | fail_unless(eina_value_set(b, 300000)); | ||
172 | fail_unless(eina_value_compare(a, b) == 0); | ||
173 | fail_unless(eina_value_set(a, -100)); | ||
174 | fail_unless(eina_value_set(b, 300000)); | ||
175 | fail_unless(eina_value_compare(a, b) < 0); | ||
176 | fail_unless(eina_value_set(a, 300000)); | ||
177 | fail_unless(eina_value_set(b, -100)); | ||
178 | fail_unless(eina_value_compare(a, b) > 0); | ||
179 | eina_value_flush(a); | ||
180 | eina_value_flush(b); | ||
181 | |||
182 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_LONG)); | ||
183 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_LONG)); | ||
184 | fail_unless(eina_value_set(a, 300000L)); | ||
185 | fail_unless(eina_value_set(b, 300000L)); | ||
186 | fail_unless(eina_value_compare(a, b) == 0); | ||
187 | fail_unless(eina_value_set(a, -100L)); | ||
188 | fail_unless(eina_value_set(b, 300000L)); | ||
189 | fail_unless(eina_value_compare(a, b) < 0); | ||
190 | fail_unless(eina_value_set(a, 300000L)); | ||
191 | fail_unless(eina_value_set(b, -100L)); | ||
192 | fail_unless(eina_value_compare(a, b) > 0); | ||
193 | eina_value_flush(a); | ||
194 | eina_value_flush(b); | ||
195 | |||
196 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_INT64)); | ||
197 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_INT64)); | ||
198 | fail_unless(eina_value_set(a, (int64_t)800000)); | ||
199 | fail_unless(eina_value_set(b, (int64_t)800000)); | ||
200 | fail_unless(eina_value_compare(a, b) == 0); | ||
201 | fail_unless(eina_value_set(a, (int64_t)-100)); | ||
202 | fail_unless(eina_value_set(b, (int64_t)8000000)); | ||
203 | fail_unless(eina_value_compare(a, b) < 0); | ||
204 | fail_unless(eina_value_set(a, (int64_t)8000000)); | ||
205 | fail_unless(eina_value_set(b, (int64_t)-100)); | ||
206 | fail_unless(eina_value_compare(a, b) > 0); | ||
207 | eina_value_flush(a); | ||
208 | eina_value_flush(b); | ||
209 | |||
210 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_UCHAR)); | ||
211 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_UCHAR)); | ||
212 | fail_unless(eina_value_set(a, 123)); | ||
213 | fail_unless(eina_value_set(b, 123)); | ||
214 | fail_unless(eina_value_compare(a, b) == 0); | ||
215 | fail_unless(eina_value_set(a, 10)); | ||
216 | fail_unless(eina_value_set(b, 123)); | ||
217 | fail_unless(eina_value_compare(a, b) < 0); | ||
218 | fail_unless(eina_value_set(a, 123)); | ||
219 | fail_unless(eina_value_set(b, 10)); | ||
220 | fail_unless(eina_value_compare(a, b) > 0); | ||
221 | eina_value_flush(a); | ||
222 | eina_value_flush(b); | ||
223 | |||
224 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_USHORT)); | ||
225 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_USHORT)); | ||
226 | fail_unless(eina_value_set(a, 1230)); | ||
227 | fail_unless(eina_value_set(b, 1230)); | ||
228 | fail_unless(eina_value_compare(a, b) == 0); | ||
229 | fail_unless(eina_value_set(a, 100)); | ||
230 | fail_unless(eina_value_set(b, 1230)); | ||
231 | fail_unless(eina_value_compare(a, b) < 0); | ||
232 | fail_unless(eina_value_set(a, 1230)); | ||
233 | fail_unless(eina_value_set(b, 100)); | ||
234 | fail_unless(eina_value_compare(a, b) > 0); | ||
235 | eina_value_flush(a); | ||
236 | eina_value_flush(b); | ||
237 | |||
238 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_UINT)); | ||
239 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_UINT)); | ||
240 | fail_unless(eina_value_set(a, 300000)); | ||
241 | fail_unless(eina_value_set(b, 300000)); | ||
242 | fail_unless(eina_value_compare(a, b) == 0); | ||
243 | fail_unless(eina_value_set(a, 100)); | ||
244 | fail_unless(eina_value_set(b, 300000)); | ||
245 | fail_unless(eina_value_compare(a, b) < 0); | ||
246 | fail_unless(eina_value_set(a, 300000)); | ||
247 | fail_unless(eina_value_set(b, 100)); | ||
248 | fail_unless(eina_value_compare(a, b) > 0); | ||
249 | eina_value_flush(a); | ||
250 | eina_value_flush(b); | ||
251 | |||
252 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_ULONG)); | ||
253 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_ULONG)); | ||
254 | fail_unless(eina_value_set(a, 300000UL)); | ||
255 | fail_unless(eina_value_set(b, 300000UL)); | ||
256 | fail_unless(eina_value_compare(a, b) == 0); | ||
257 | fail_unless(eina_value_set(a, 100UL)); | ||
258 | fail_unless(eina_value_set(b, 300000UL)); | ||
259 | fail_unless(eina_value_compare(a, b) < 0); | ||
260 | fail_unless(eina_value_set(a, 300000UL)); | ||
261 | fail_unless(eina_value_set(b, 100UL)); | ||
262 | fail_unless(eina_value_compare(a, b) > 0); | ||
263 | eina_value_flush(a); | ||
264 | eina_value_flush(b); | ||
265 | |||
266 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_UINT64)); | ||
267 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_UINT64)); | ||
268 | fail_unless(eina_value_set(a, (uint64_t)8000000)); | ||
269 | fail_unless(eina_value_set(b, (uint64_t)8000000)); | ||
270 | fail_unless(eina_value_compare(a, b) == 0); | ||
271 | fail_unless(eina_value_set(a, (uint64_t)100)); | ||
272 | fail_unless(eina_value_set(b, (uint64_t)8000000)); | ||
273 | fail_unless(eina_value_compare(a, b) < 0); | ||
274 | fail_unless(eina_value_set(a, (uint64_t)8000000)); | ||
275 | fail_unless(eina_value_set(b, (uint64_t)100)); | ||
276 | fail_unless(eina_value_compare(a, b) > 0); | ||
277 | eina_value_flush(a); | ||
278 | eina_value_flush(b); | ||
279 | |||
280 | fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_STRING)); | ||
281 | fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_STRING)); | ||
282 | fail_unless(eina_value_set(a, "aaa")); | ||
283 | fail_unless(eina_value_set(b, "aaa")); | ||
284 | fail_unless(eina_value_compare(a, b) == 0); | ||
285 | fail_unless(eina_value_set(a, "abc")); | ||
286 | fail_unless(eina_value_set(b, "acd")); | ||
287 | fail_unless(eina_value_compare(a, b) < 0); | ||
288 | fail_unless(eina_value_set(a, "acd")); | ||
289 | fail_unless(eina_value_set(b, "abc")); | ||
290 | fail_unless(eina_value_compare(a, b) > 0); | ||
291 | eina_value_flush(a); | ||
292 | eina_value_flush(b); | ||
293 | |||
294 | fail_unless(eina_value_array_setup(a, EINA_VALUE_TYPE_CHAR, 0)); | ||
295 | fail_unless(eina_value_array_setup(b, EINA_VALUE_TYPE_CHAR, 0)); | ||
296 | fail_unless(eina_value_compare(a, b) == 0); | ||
297 | |||
298 | fail_unless(eina_value_array_append(a, 1)); | ||
299 | fail_unless(eina_value_array_append(a, 2)); | ||
300 | fail_unless(eina_value_array_append(a, 3)); | ||
301 | |||
302 | fail_unless(eina_value_array_append(b, 1)); | ||
303 | fail_unless(eina_value_array_append(b, 2)); | ||
304 | fail_unless(eina_value_array_append(b, 3)); | ||
305 | |||
306 | fail_unless(eina_value_compare(a, b) == 0); | ||
307 | |||
308 | fail_unless(eina_value_array_set(a, 0, 0)); | ||
309 | fail_unless(eina_value_compare(a, b) < 0); | ||
310 | |||
311 | fail_unless(eina_value_array_set(a, 0, 10)); | ||
312 | fail_unless(eina_value_compare(a, b) > 0); | ||
313 | |||
314 | fail_unless(eina_value_array_set(a, 0, 1)); | ||
315 | |||
316 | fail_unless(eina_value_array_set(b, 0, 0)); | ||
317 | fail_unless(eina_value_compare(a, b) > 0); | ||
318 | |||
319 | fail_unless(eina_value_array_set(b, 0, 10)); | ||
320 | fail_unless(eina_value_compare(a, b) < 0); | ||
321 | |||
322 | fail_unless(eina_value_array_set(b, 0, 1)); | ||
323 | fail_unless(eina_value_compare(a, b) == 0); | ||
324 | |||
325 | /* bigger arrays are greater */ | ||
326 | fail_unless(eina_value_array_append(b, 0)); | ||
327 | fail_unless(eina_value_compare(a, b) < 0); | ||
328 | |||
329 | fail_unless(eina_value_array_append(a, 0)); | ||
330 | fail_unless(eina_value_array_append(a, 0)); | ||
331 | fail_unless(eina_value_compare(a, b) > 0); | ||
332 | |||
333 | /* bigger arrays are greater, unless an element says otherwise */ | ||
334 | fail_unless(eina_value_array_set(b, 0, 10)); | ||
335 | fail_unless(eina_value_compare(a, b) < 0); | ||
336 | |||
337 | eina_value_flush(a); | ||
338 | eina_value_flush(b); | ||
339 | |||
340 | fail_unless(eina_value_list_setup(a, EINA_VALUE_TYPE_CHAR)); | ||
341 | fail_unless(eina_value_list_setup(b, EINA_VALUE_TYPE_CHAR)); | ||
342 | fail_unless(eina_value_compare(a, b) == 0); | ||
343 | |||
344 | fail_unless(eina_value_list_append(a, 1)); | ||
345 | fail_unless(eina_value_list_append(a, 2)); | ||
346 | fail_unless(eina_value_list_append(a, 3)); | ||
347 | |||
348 | fail_unless(eina_value_list_append(b, 1)); | ||
349 | fail_unless(eina_value_list_append(b, 2)); | ||
350 | fail_unless(eina_value_list_append(b, 3)); | ||
351 | |||
352 | fail_unless(eina_value_compare(a, b) == 0); | ||
353 | |||
354 | fail_unless(eina_value_list_set(a, 0, 0)); | ||
355 | fail_unless(eina_value_compare(a, b) < 0); | ||
356 | |||
357 | fail_unless(eina_value_list_set(a, 0, 10)); | ||
358 | fail_unless(eina_value_compare(a, b) > 0); | ||
359 | |||
360 | fail_unless(eina_value_list_set(a, 0, 1)); | ||
361 | |||
362 | fail_unless(eina_value_list_set(b, 0, 0)); | ||
363 | fail_unless(eina_value_compare(a, b) > 0); | ||
364 | |||
365 | fail_unless(eina_value_list_set(b, 0, 10)); | ||
366 | fail_unless(eina_value_compare(a, b) < 0); | ||
367 | |||
368 | fail_unless(eina_value_list_set(b, 0, 1)); | ||
369 | fail_unless(eina_value_compare(a, b) == 0); | ||
370 | |||
371 | /* bigger lists are greater */ | ||
372 | fail_unless(eina_value_list_append(b, 0)); | ||
373 | fail_unless(eina_value_compare(a, b) < 0); | ||
374 | |||
375 | fail_unless(eina_value_list_append(a, 0)); | ||
376 | fail_unless(eina_value_list_append(a, 0)); | ||
377 | fail_unless(eina_value_compare(a, b) > 0); | ||
378 | |||
379 | /* bigger lists are greater, unless an element says otherwise */ | ||
380 | fail_unless(eina_value_list_set(b, 0, 10)); | ||
381 | fail_unless(eina_value_compare(a, b) < 0); | ||
382 | |||
383 | eina_value_flush(a); | ||
384 | eina_value_flush(b); | ||
385 | |||
386 | fail_unless(eina_value_hash_setup(a, EINA_VALUE_TYPE_CHAR, 0)); | ||
387 | fail_unless(eina_value_hash_setup(b, EINA_VALUE_TYPE_CHAR, 0)); | ||
388 | fail_unless(eina_value_compare(a, b) == 0); | ||
389 | |||
390 | fail_unless(eina_value_hash_set(a, "abc", 1)); | ||
391 | fail_unless(eina_value_hash_set(a, "xyz", 2)); | ||
392 | fail_unless(eina_value_hash_set(a, "hello", 3)); | ||
393 | |||
394 | fail_unless(eina_value_hash_set(b, "abc", 1)); | ||
395 | fail_unless(eina_value_hash_set(b, "xyz", 2)); | ||
396 | fail_unless(eina_value_hash_set(b, "hello", 3)); | ||
397 | |||
398 | fail_unless(eina_value_compare(a, b) == 0); | ||
399 | |||
400 | fail_unless(eina_value_hash_set(a, "abc", 0)); | ||
401 | fail_unless(eina_value_compare(a, b) < 0); | ||
402 | |||
403 | fail_unless(eina_value_hash_set(a, "abc", 10)); | ||
404 | fail_unless(eina_value_compare(a, b) > 0); | ||
405 | |||
406 | fail_unless(eina_value_hash_set(a, "abc", 1)); | ||
407 | |||
408 | fail_unless(eina_value_hash_set(b, "abc", 0)); | ||
409 | fail_unless(eina_value_compare(a, b) > 0); | ||
410 | |||
411 | fail_unless(eina_value_hash_set(b, "abc", 10)); | ||
412 | fail_unless(eina_value_compare(a, b) < 0); | ||
413 | |||
414 | fail_unless(eina_value_hash_set(b, "abc", 1)); | ||
415 | fail_unless(eina_value_compare(a, b) == 0); | ||
416 | |||
417 | /* bigger hashs are greater */ | ||
418 | fail_unless(eina_value_hash_set(b,"newkey", 0)); | ||
419 | fail_unless(eina_value_compare(a, b) < 0); | ||
420 | |||
421 | fail_unless(eina_value_hash_set(a, "newkey", 0)); | ||
422 | fail_unless(eina_value_hash_set(a, "onemorenewkey", 0)); | ||
423 | fail_unless(eina_value_compare(a, b) > 0); | ||
424 | |||
425 | /* bigger hashs are greater, unless an element says otherwise */ | ||
426 | fail_unless(eina_value_hash_set(b, "abc", 10)); | ||
427 | fail_unless(eina_value_compare(a, b) < 0); | ||
428 | |||
429 | eina_value_free(a); | ||
430 | eina_value_free(b); | ||
431 | eina_shutdown(); | ||
432 | } | ||
433 | END_TEST | ||
434 | |||
435 | START_TEST(eina_value_test_string) | ||
436 | { | ||
437 | Eina_Value *value; | ||
438 | const char *s; | ||
439 | |||
440 | eina_init(); | ||
441 | |||
442 | value = eina_value_new(EINA_VALUE_TYPE_STRING); | ||
443 | fail_unless(value != NULL); | ||
444 | fail_unless(eina_value_set(value, "hello world!")); | ||
445 | fail_unless(eina_value_get(value, &s)); | ||
446 | fail_unless(strcmp(s, "hello world!") == 0); | ||
447 | |||
448 | fail_unless(eina_value_set(value, "eina-value")); | ||
449 | fail_unless(eina_value_get(value, &s)); | ||
450 | fail_unless(strcmp(s, "eina-value") == 0); | ||
451 | |||
452 | eina_value_flush(value); | ||
453 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING)); | ||
454 | |||
455 | fail_unless(eina_value_set(value, "profusion")); | ||
456 | fail_unless(eina_value_get(value, &s)); | ||
457 | fail_unless(strcmp(s, "profusion") == 0); | ||
458 | |||
459 | eina_value_free(value); | ||
460 | eina_shutdown(); | ||
461 | } | ||
462 | END_TEST | ||
463 | |||
464 | START_TEST(eina_value_test_pvariant) | ||
465 | { | ||
466 | Eina_Value *value; | ||
467 | char c, in_c; | ||
468 | short s, in_s; | ||
469 | int i, in_i; | ||
470 | long l, in_l; | ||
471 | int64_t i64, in_i64; | ||
472 | unsigned char uc, in_uc; | ||
473 | unsigned short us, in_us; | ||
474 | unsigned int ui, in_ui; | ||
475 | unsigned long ul, in_ul; | ||
476 | uint64_t u64, in_u64; | ||
477 | float f, in_f; | ||
478 | double d, in_d; | ||
479 | const char *str, *in_str; | ||
480 | |||
481 | eina_init(); | ||
482 | |||
483 | value = eina_value_new(EINA_VALUE_TYPE_CHAR); | ||
484 | fail_unless(value != NULL); | ||
485 | in_c = 'x'; | ||
486 | fail_unless(eina_value_pset(value, &in_c)); | ||
487 | fail_unless(eina_value_pget(value, &c)); | ||
488 | fail_unless(c == 'x'); | ||
489 | eina_value_flush(value); | ||
490 | |||
491 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_SHORT)); | ||
492 | in_s = 300; | ||
493 | fail_unless(eina_value_pset(value, &in_s)); | ||
494 | fail_unless(eina_value_pget(value, &s)); | ||
495 | fail_unless(s == 300); | ||
496 | eina_value_flush(value); | ||
497 | |||
498 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT)); | ||
499 | in_i = -12345; | ||
500 | fail_unless(eina_value_pset(value, &in_i)); | ||
501 | fail_unless(eina_value_pget(value, &i)); | ||
502 | fail_unless(i == -12345); | ||
503 | eina_value_flush(value); | ||
504 | |||
505 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_LONG)); | ||
506 | in_l = 0xb33f; | ||
507 | fail_unless(eina_value_pset(value, &in_l)); | ||
508 | fail_unless(eina_value_pget(value, &l)); | ||
509 | fail_unless(l == 0xb33f); | ||
510 | eina_value_flush(value); | ||
511 | |||
512 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT64)); | ||
513 | in_i64 = 0x0011223344556677; | ||
514 | fail_unless(eina_value_pset(value, &in_i64)); | ||
515 | fail_unless(eina_value_pget(value, &i64)); | ||
516 | fail_unless(i64 == 0x0011223344556677); | ||
517 | eina_value_flush(value); | ||
518 | |||
519 | /* unsigned: */ | ||
520 | |||
521 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UCHAR)); | ||
522 | in_uc = 200; | ||
523 | fail_unless(eina_value_pset(value, &in_uc)); | ||
524 | fail_unless(eina_value_pget(value, &uc)); | ||
525 | fail_unless(uc == 200); | ||
526 | eina_value_flush(value); | ||
527 | |||
528 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_USHORT)); | ||
529 | in_us = 65535; | ||
530 | fail_unless(eina_value_pset(value, &in_us)); | ||
531 | fail_unless(eina_value_pget(value, &us)); | ||
532 | fail_unless(us == 65535); | ||
533 | eina_value_flush(value); | ||
534 | |||
535 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT)); | ||
536 | in_ui = 4000000000U; | ||
537 | fail_unless(eina_value_pset(value, &in_ui)); | ||
538 | fail_unless(eina_value_pget(value, &ui)); | ||
539 | fail_unless(ui == 4000000000U); | ||
540 | eina_value_flush(value); | ||
541 | |||
542 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_ULONG)); | ||
543 | in_ul = 3000000001U; | ||
544 | fail_unless(eina_value_pset(value, &in_ul)); | ||
545 | fail_unless(eina_value_pget(value, &ul)); | ||
546 | fail_unless(ul == 3000000001U); | ||
547 | eina_value_flush(value); | ||
548 | |||
549 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT64)); | ||
550 | in_u64 = 0x1122334455667788; | ||
551 | fail_unless(eina_value_pset(value, &in_u64)); | ||
552 | fail_unless(eina_value_pget(value, &u64)); | ||
553 | fail_unless(u64 == 0x1122334455667788); | ||
554 | eina_value_flush(value); | ||
555 | |||
556 | /* floating point */ | ||
557 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)); | ||
558 | in_f = 0.1234; | ||
559 | fail_unless(eina_value_pset(value, &in_f)); | ||
560 | fail_unless(eina_value_pget(value, &f)); | ||
561 | fail_unless(CHECK_FP(0.1234, f)); | ||
562 | eina_value_flush(value); | ||
563 | |||
564 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_DOUBLE)); | ||
565 | in_d = 34567.8; | ||
566 | fail_unless(eina_value_pset(value, &in_d)); | ||
567 | fail_unless(eina_value_pget(value, &d)); | ||
568 | fail_unless(CHECK_FP(34567.8, d)); | ||
569 | eina_value_flush(value); | ||
570 | |||
571 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING)); | ||
572 | in_str = "hello world!"; | ||
573 | fail_unless(eina_value_pset(value, &in_str)); | ||
574 | fail_unless(eina_value_pget(value, &str)); | ||
575 | fail_unless(strcmp(str, "hello world!") == 0); | ||
576 | |||
577 | in_str = "eina-value"; | ||
578 | fail_unless(eina_value_pset(value, &in_str)); | ||
579 | fail_unless(eina_value_pget(value, &str)); | ||
580 | fail_unless(strcmp(str, "eina-value") == 0); | ||
581 | |||
582 | eina_value_flush(value); | ||
583 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING)); | ||
584 | |||
585 | in_str = "profusion"; | ||
586 | fail_unless(eina_value_pset(value, &in_str)); | ||
587 | fail_unless(eina_value_pget(value, &str)); | ||
588 | fail_unless(strcmp(str, "profusion") == 0); | ||
589 | |||
590 | eina_value_free(value); | ||
591 | eina_shutdown(); | ||
592 | } | ||
593 | END_TEST | ||
594 | |||
595 | START_TEST(eina_value_test_to_string) | ||
596 | { | ||
597 | Eina_Value *value; | ||
598 | char c, in_c; | ||
599 | short s, in_s; | ||
600 | int i, in_i; | ||
601 | long l, in_l; | ||
602 | int64_t i64, in_i64; | ||
603 | unsigned char uc, in_uc; | ||
604 | unsigned short us, in_us; | ||
605 | unsigned int ui, in_ui; | ||
606 | unsigned long ul, in_ul; | ||
607 | uint64_t u64, in_u64; | ||
608 | float f, in_f; | ||
609 | double d, in_d; | ||
610 | const char *str, *in_str; | ||
611 | char *out; | ||
612 | char buf[256]; | ||
613 | |||
614 | eina_init(); | ||
615 | |||
616 | value = eina_value_new(EINA_VALUE_TYPE_CHAR); | ||
617 | fail_unless(value != NULL); | ||
618 | in_c = 'x'; | ||
619 | fail_unless(eina_value_pset(value, &in_c)); | ||
620 | fail_unless(eina_value_pget(value, &c)); | ||
621 | fail_unless(c == 'x'); | ||
622 | snprintf(buf, sizeof(buf), "%hhd", in_c); | ||
623 | out = eina_value_to_string(value); | ||
624 | fail_unless(out != NULL); | ||
625 | fail_unless(strcmp(buf, out) == 0); | ||
626 | free(out); | ||
627 | eina_value_flush(value); | ||
628 | |||
629 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_SHORT)); | ||
630 | in_s = 300; | ||
631 | fail_unless(eina_value_pset(value, &in_s)); | ||
632 | fail_unless(eina_value_pget(value, &s)); | ||
633 | fail_unless(s == 300); | ||
634 | snprintf(buf, sizeof(buf), "%hd", in_s); | ||
635 | out = eina_value_to_string(value); | ||
636 | fail_unless(out != NULL); | ||
637 | fail_unless(strcmp(buf, out) == 0); | ||
638 | free(out); | ||
639 | eina_value_flush(value); | ||
640 | |||
641 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT)); | ||
642 | in_i = -12345; | ||
643 | fail_unless(eina_value_pset(value, &in_i)); | ||
644 | fail_unless(eina_value_pget(value, &i)); | ||
645 | fail_unless(i == -12345); | ||
646 | snprintf(buf, sizeof(buf), "%d", in_i); | ||
647 | out = eina_value_to_string(value); | ||
648 | fail_unless(out != NULL); | ||
649 | fail_unless(strcmp(buf, out) == 0); | ||
650 | free(out); | ||
651 | eina_value_flush(value); | ||
652 | |||
653 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_LONG)); | ||
654 | in_l = 0xb33f; | ||
655 | fail_unless(eina_value_pset(value, &in_l)); | ||
656 | fail_unless(eina_value_pget(value, &l)); | ||
657 | fail_unless(l == 0xb33f); | ||
658 | snprintf(buf, sizeof(buf), "%ld", in_l); | ||
659 | out = eina_value_to_string(value); | ||
660 | fail_unless(out != NULL); | ||
661 | fail_unless(strcmp(buf, out) == 0); | ||
662 | free(out); | ||
663 | eina_value_flush(value); | ||
664 | |||
665 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT64)); | ||
666 | in_i64 = 0x0011223344556677; | ||
667 | fail_unless(eina_value_pset(value, &in_i64)); | ||
668 | fail_unless(eina_value_pget(value, &i64)); | ||
669 | fail_unless(i64 == 0x0011223344556677); | ||
670 | snprintf(buf, sizeof(buf), "%"PRId64, in_i64); | ||
671 | out = eina_value_to_string(value); | ||
672 | fail_unless(out != NULL); | ||
673 | fail_unless(strcmp(buf, out) == 0); | ||
674 | free(out); | ||
675 | eina_value_flush(value); | ||
676 | |||
677 | /* unsigned: */ | ||
678 | |||
679 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UCHAR)); | ||
680 | in_uc = 200; | ||
681 | fail_unless(eina_value_pset(value, &in_uc)); | ||
682 | fail_unless(eina_value_pget(value, &uc)); | ||
683 | fail_unless(uc == 200); | ||
684 | snprintf(buf, sizeof(buf), "%hhu", in_uc); | ||
685 | out = eina_value_to_string(value); | ||
686 | fail_unless(out != NULL); | ||
687 | fail_unless(strcmp(buf, out) == 0); | ||
688 | free(out); | ||
689 | eina_value_flush(value); | ||
690 | |||
691 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_USHORT)); | ||
692 | in_us = 65535; | ||
693 | fail_unless(eina_value_pset(value, &in_us)); | ||
694 | fail_unless(eina_value_pget(value, &us)); | ||
695 | fail_unless(us == 65535); | ||
696 | snprintf(buf, sizeof(buf), "%hu", in_us); | ||
697 | out = eina_value_to_string(value); | ||
698 | fail_unless(out != NULL); | ||
699 | fail_unless(strcmp(buf, out) == 0); | ||
700 | free(out); | ||
701 | eina_value_flush(value); | ||
702 | |||
703 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT)); | ||
704 | in_ui = 4000000000U; | ||
705 | fail_unless(eina_value_pset(value, &in_ui)); | ||
706 | fail_unless(eina_value_pget(value, &ui)); | ||
707 | fail_unless(ui == 4000000000U); | ||
708 | snprintf(buf, sizeof(buf), "%u", in_ui); | ||
709 | out = eina_value_to_string(value); | ||
710 | fail_unless(out != NULL); | ||
711 | fail_unless(strcmp(buf, out) == 0); | ||
712 | free(out); | ||
713 | eina_value_flush(value); | ||
714 | |||
715 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_ULONG)); | ||
716 | in_ul = 3000000001U; | ||
717 | fail_unless(eina_value_pset(value, &in_ul)); | ||
718 | fail_unless(eina_value_pget(value, &ul)); | ||
719 | fail_unless(ul == 3000000001U); | ||
720 | snprintf(buf, sizeof(buf), "%lu", in_ul); | ||
721 | out = eina_value_to_string(value); | ||
722 | fail_unless(out != NULL); | ||
723 | fail_unless(strcmp(buf, out) == 0); | ||
724 | free(out); | ||
725 | eina_value_flush(value); | ||
726 | |||
727 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT64)); | ||
728 | in_u64 = 0x1122334455667788; | ||
729 | fail_unless(eina_value_pset(value, &in_u64)); | ||
730 | fail_unless(eina_value_pget(value, &u64)); | ||
731 | fail_unless(u64 == 0x1122334455667788); | ||
732 | snprintf(buf, sizeof(buf), "%"PRIu64, in_u64); | ||
733 | out = eina_value_to_string(value); | ||
734 | fail_unless(out != NULL); | ||
735 | fail_unless(strcmp(buf, out) == 0); | ||
736 | free(out); | ||
737 | eina_value_flush(value); | ||
738 | |||
739 | /* floating point */ | ||
740 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)); | ||
741 | in_f = 0.1234; | ||
742 | fail_unless(eina_value_pset(value, &in_f)); | ||
743 | fail_unless(eina_value_pget(value, &f)); | ||
744 | fail_unless(CHECK_FP(0.1234, f)); | ||
745 | snprintf(buf, sizeof(buf), "%g", in_f); | ||
746 | out = eina_value_to_string(value); | ||
747 | fail_unless(out != NULL); | ||
748 | fail_unless(strncmp(buf, out, 6) == 0); /* stupid float... */ | ||
749 | free(out); | ||
750 | eina_value_flush(value); | ||
751 | |||
752 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_DOUBLE)); | ||
753 | in_d = 34567.8; | ||
754 | fail_unless(eina_value_pset(value, &in_d)); | ||
755 | fail_unless(eina_value_pget(value, &d)); | ||
756 | fail_unless(CHECK_FP(34567.8, d)); | ||
757 | snprintf(buf, sizeof(buf), "%g", in_d); | ||
758 | out = eina_value_to_string(value); | ||
759 | fail_unless(out != NULL); | ||
760 | fail_unless(strncmp(buf, out, 7) == 0); /* stupid double... */ | ||
761 | free(out); | ||
762 | eina_value_flush(value); | ||
763 | |||
764 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING)); | ||
765 | in_str = "hello world!"; | ||
766 | fail_unless(eina_value_pset(value, &in_str)); | ||
767 | fail_unless(eina_value_pget(value, &str)); | ||
768 | fail_unless(strcmp(str, "hello world!") == 0); | ||
769 | out = eina_value_to_string(value); | ||
770 | fail_unless(out != NULL); | ||
771 | fail_unless(strcmp(in_str, out) == 0); | ||
772 | free(out); | ||
773 | |||
774 | in_str = "eina-value"; | ||
775 | fail_unless(eina_value_pset(value, &in_str)); | ||
776 | fail_unless(eina_value_pget(value, &str)); | ||
777 | fail_unless(strcmp(str, "eina-value") == 0); | ||
778 | out = eina_value_to_string(value); | ||
779 | fail_unless(out != NULL); | ||
780 | fail_unless(strcmp(in_str, out) == 0); | ||
781 | free(out); | ||
782 | |||
783 | eina_value_flush(value); | ||
784 | fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING)); | ||
785 | |||
786 | in_str = "profusion"; | ||
787 | fail_unless(eina_value_pset(value, &in_str)); | ||
788 | fail_unless(eina_value_pget(value, &str)); | ||
789 | fail_unless(strcmp(str, "profusion") == 0); | ||
790 | out = eina_value_to_string(value); | ||
791 | fail_unless(out != NULL); | ||
792 | fail_unless(strcmp(in_str, out) == 0); | ||
793 | free(out); | ||
794 | |||
795 | eina_value_free(value); | ||
796 | eina_shutdown(); | ||
797 | } | ||
798 | END_TEST | ||
799 | |||
800 | START_TEST(eina_value_test_convert_char) | ||
801 | { | ||
802 | Eina_Value *value, conv; | ||
803 | char c; | ||
804 | short s; | ||
805 | int i; | ||
806 | long l; | ||
807 | int64_t i64; | ||
808 | unsigned char uc; | ||
809 | unsigned short us; | ||
810 | unsigned int ui; | ||
811 | unsigned long ul; | ||
812 | uint64_t u64; | ||
813 | float f; | ||
814 | double d; | ||
815 | const char *str; | ||
816 | |||
817 | eina_init(); | ||
818 | |||
819 | value = eina_value_new(EINA_VALUE_TYPE_CHAR); | ||
820 | fail_unless(value != NULL); | ||
821 | |||
822 | fail_unless(eina_value_set(value, 123)); | ||
823 | |||
824 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UCHAR)); | ||
825 | fail_unless(eina_value_convert(value, &conv)); | ||
826 | fail_unless(eina_value_get(&conv, &uc)); | ||
827 | fail_unless(uc == 123); | ||
828 | eina_value_flush(&conv); | ||
829 | |||
830 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_USHORT)); | ||
831 | fail_unless(eina_value_convert(value, &conv)); | ||
832 | fail_unless(eina_value_get(&conv, &us)); | ||
833 | fail_unless(us == 123); | ||
834 | eina_value_flush(&conv); | ||
835 | |||
836 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT)); | ||
837 | fail_unless(eina_value_convert(value, &conv)); | ||
838 | fail_unless(eina_value_get(&conv, &ui)); | ||
839 | fail_unless(ui == 123); | ||
840 | eina_value_flush(&conv); | ||
841 | |||
842 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_ULONG)); | ||
843 | fail_unless(eina_value_convert(value, &conv)); | ||
844 | fail_unless(eina_value_get(&conv, &ul)); | ||
845 | fail_unless(ul == 123); | ||
846 | eina_value_flush(&conv); | ||
847 | |||
848 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT64)); | ||
849 | fail_unless(eina_value_convert(value, &conv)); | ||
850 | fail_unless(eina_value_get(&conv, &u64)); | ||
851 | fail_unless(u64 == 123); | ||
852 | eina_value_flush(&conv); | ||
853 | |||
854 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_CHAR)); | ||
855 | fail_unless(eina_value_convert(value, &conv)); | ||
856 | fail_unless(eina_value_get(&conv, &c)); | ||
857 | fail_unless(c == 123); | ||
858 | eina_value_flush(&conv); | ||
859 | |||
860 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_SHORT)); | ||
861 | fail_unless(eina_value_convert(value, &conv)); | ||
862 | fail_unless(eina_value_get(&conv, &s)); | ||
863 | fail_unless(s == 123); | ||
864 | eina_value_flush(&conv); | ||
865 | |||
866 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT)); | ||
867 | fail_unless(eina_value_convert(value, &conv)); | ||
868 | fail_unless(eina_value_get(&conv, &i)); | ||
869 | fail_unless(i == 123); | ||
870 | eina_value_flush(&conv); | ||
871 | |||
872 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_LONG)); | ||
873 | fail_unless(eina_value_convert(value, &conv)); | ||
874 | fail_unless(eina_value_get(&conv, &l)); | ||
875 | fail_unless(l == 123); | ||
876 | eina_value_flush(&conv); | ||
877 | |||
878 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT64)); | ||
879 | fail_unless(eina_value_convert(value, &conv)); | ||
880 | fail_unless(eina_value_get(&conv, &i64)); | ||
881 | fail_unless(i64 == 123); | ||
882 | eina_value_flush(&conv); | ||
883 | |||
884 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_FLOAT)); | ||
885 | fail_unless(eina_value_convert(value, &conv)); | ||
886 | fail_unless(eina_value_get(&conv, &f)); | ||
887 | fail_unless(CHECK_FP(f, 123)); | ||
888 | eina_value_flush(&conv); | ||
889 | |||
890 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_DOUBLE)); | ||
891 | fail_unless(eina_value_convert(value, &conv)); | ||
892 | fail_unless(eina_value_get(&conv, &d)); | ||
893 | fail_unless(CHECK_FP(d, 123)); | ||
894 | eina_value_flush(&conv); | ||
895 | |||
896 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_STRING)); | ||
897 | fail_unless(eina_value_convert(value, &conv)); | ||
898 | fail_unless(eina_value_get(&conv, &str)); | ||
899 | fail_unless(str != NULL); | ||
900 | fail_unless(strcmp(str, "123") == 0); | ||
901 | eina_value_flush(&conv); | ||
902 | |||
903 | /* negative tests */ | ||
904 | fail_unless(eina_value_set(value, -123)); | ||
905 | |||
906 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UCHAR)); | ||
907 | fail_if(eina_value_convert(value, &conv)); | ||
908 | eina_value_flush(&conv); | ||
909 | |||
910 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_USHORT)); | ||
911 | fail_if(eina_value_convert(value, &conv)); | ||
912 | eina_value_flush(&conv); | ||
913 | |||
914 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT)); | ||
915 | fail_if(eina_value_convert(value, &conv)); | ||
916 | eina_value_flush(&conv); | ||
917 | |||
918 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_ULONG)); | ||
919 | fail_if(eina_value_convert(value, &conv)); | ||
920 | eina_value_flush(&conv); | ||
921 | |||
922 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT64)); | ||
923 | fail_if(eina_value_convert(value, &conv)); | ||
924 | eina_value_flush(&conv); | ||
925 | |||
926 | eina_value_free(value); | ||
927 | eina_shutdown(); | ||
928 | } | ||
929 | END_TEST | ||
930 | |||
931 | START_TEST(eina_value_test_convert_uchar) | ||
932 | { | ||
933 | Eina_Value *value, conv; | ||
934 | char c; | ||
935 | short s; | ||
936 | int i; | ||
937 | long l; | ||
938 | int64_t i64; | ||
939 | unsigned char uc; | ||
940 | unsigned short us; | ||
941 | unsigned int ui; | ||
942 | unsigned long ul; | ||
943 | uint64_t u64; | ||
944 | float f; | ||
945 | double d; | ||
946 | const char *str; | ||
947 | |||
948 | eina_init(); | ||
949 | |||
950 | value = eina_value_new(EINA_VALUE_TYPE_UCHAR); | ||
951 | fail_unless(value != NULL); | ||
952 | |||
953 | fail_unless(eina_value_set(value, 31)); | ||
954 | |||
955 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UCHAR)); | ||
956 | fail_unless(eina_value_convert(value, &conv)); | ||
957 | fail_unless(eina_value_get(&conv, &uc)); | ||
958 | fail_unless(uc == 31); | ||
959 | eina_value_flush(&conv); | ||
960 | |||
961 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_USHORT)); | ||
962 | fail_unless(eina_value_convert(value, &conv)); | ||
963 | fail_unless(eina_value_get(&conv, &us)); | ||
964 | fail_unless(us == 31); | ||
965 | eina_value_flush(&conv); | ||
966 | |||
967 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT)); | ||
968 | fail_unless(eina_value_convert(value, &conv)); | ||
969 | fail_unless(eina_value_get(&conv, &ui)); | ||
970 | fail_unless(ui == 31); | ||
971 | eina_value_flush(&conv); | ||
972 | |||
973 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_ULONG)); | ||
974 | fail_unless(eina_value_convert(value, &conv)); | ||
975 | fail_unless(eina_value_get(&conv, &ul)); | ||
976 | fail_unless(ul == 31); | ||
977 | eina_value_flush(&conv); | ||
978 | |||
979 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT64)); | ||
980 | fail_unless(eina_value_convert(value, &conv)); | ||
981 | fail_unless(eina_value_get(&conv, &u64)); | ||
982 | fail_unless(u64 == 31); | ||
983 | eina_value_flush(&conv); | ||
984 | |||
985 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_CHAR)); | ||
986 | fail_unless(eina_value_convert(value, &conv)); | ||
987 | fail_unless(eina_value_get(&conv, &c)); | ||
988 | fail_unless(c == 31); | ||
989 | eina_value_flush(&conv); | ||
990 | |||
991 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_SHORT)); | ||
992 | fail_unless(eina_value_convert(value, &conv)); | ||
993 | fail_unless(eina_value_get(&conv, &s)); | ||
994 | fail_unless(s == 31); | ||
995 | eina_value_flush(&conv); | ||
996 | |||
997 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT)); | ||
998 | fail_unless(eina_value_convert(value, &conv)); | ||
999 | fail_unless(eina_value_get(&conv, &i)); | ||
1000 | fail_unless(i == 31); | ||
1001 | eina_value_flush(&conv); | ||
1002 | |||
1003 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_LONG)); | ||
1004 | fail_unless(eina_value_convert(value, &conv)); | ||
1005 | fail_unless(eina_value_get(&conv, &l)); | ||
1006 | fail_unless(l == 31); | ||
1007 | eina_value_flush(&conv); | ||
1008 | |||
1009 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT64)); | ||
1010 | fail_unless(eina_value_convert(value, &conv)); | ||
1011 | fail_unless(eina_value_get(&conv, &i64)); | ||
1012 | fail_unless(i64 == 31); | ||
1013 | eina_value_flush(&conv); | ||
1014 | |||
1015 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_FLOAT)); | ||
1016 | fail_unless(eina_value_convert(value, &conv)); | ||
1017 | fail_unless(eina_value_get(&conv, &f)); | ||
1018 | fail_unless(CHECK_FP(f, 31)); | ||
1019 | eina_value_flush(&conv); | ||
1020 | |||
1021 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_DOUBLE)); | ||
1022 | fail_unless(eina_value_convert(value, &conv)); | ||
1023 | fail_unless(eina_value_get(&conv, &d)); | ||
1024 | fail_unless(CHECK_FP(d, 31)); | ||
1025 | eina_value_flush(&conv); | ||
1026 | |||
1027 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_STRING)); | ||
1028 | fail_unless(eina_value_convert(value, &conv)); | ||
1029 | fail_unless(eina_value_get(&conv, &str)); | ||
1030 | fail_unless(str != NULL); | ||
1031 | fail_unless(strcmp(str, "31") == 0); | ||
1032 | eina_value_flush(&conv); | ||
1033 | |||
1034 | /* negative tests */ | ||
1035 | fail_unless(eina_value_set(value, 200)); | ||
1036 | |||
1037 | fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_CHAR)); | ||
1038 | fail_if(eina_value_convert(value, &conv)); | ||
1039 | eina_value_flush(&conv); | ||
1040 | |||
1041 | eina_value_free(value); | ||
1042 | eina_shutdown(); | ||
1043 | } | ||
1044 | END_TEST | ||
1045 | |||
1046 | |||
1047 | START_TEST(eina_value_test_array) | ||
1048 | { | ||
1049 | Eina_Value *value, other; | ||
1050 | Eina_Value_Array desc; | ||
1051 | Eina_Inarray *inarray; | ||
1052 | char c; | ||
1053 | char buf[1024]; | ||
1054 | char *str; | ||
1055 | |||
1056 | eina_init(); | ||
1057 | |||
1058 | value = eina_value_array_new(EINA_VALUE_TYPE_CHAR, 0); | ||
1059 | fail_unless(value != NULL); | ||
1060 | |||
1061 | fail_unless(eina_value_array_append(value, 'k')); | ||
1062 | fail_unless(eina_value_array_append(value, '-')); | ||
1063 | fail_unless(eina_value_array_append(value, 's')); | ||
1064 | |||
1065 | fail_unless(eina_value_array_get(value, 0, &c)); | ||
1066 | fail_unless(c == 'k'); | ||
1067 | fail_unless(eina_value_array_get(value, 1, &c)); | ||
1068 | fail_unless(c == '-'); | ||
1069 | fail_unless(eina_value_array_get(value, 2, &c)); | ||
1070 | fail_unless(c == 's'); | ||
1071 | |||
1072 | fail_unless(eina_value_array_insert(value, 0, '!')); | ||
1073 | fail_unless(eina_value_array_get(value, 0, &c)); | ||
1074 | fail_unless(c == '!'); | ||
1075 | fail_unless(eina_value_array_get(value, 1, &c)); | ||
1076 | fail_unless(c == 'k'); | ||
1077 | fail_unless(eina_value_array_get(value, 2, &c)); | ||
1078 | fail_unless(c == '-'); | ||
1079 | fail_unless(eina_value_array_get(value, 3, &c)); | ||
1080 | fail_unless(c == 's'); | ||
1081 | |||
1082 | fail_unless(eina_value_array_set(value, 0, '*')); | ||
1083 | fail_unless(eina_value_array_get(value, 0, &c)); | ||
1084 | fail_unless(c == '*'); | ||
1085 | fail_unless(eina_value_array_get(value, 1, &c)); | ||
1086 | fail_unless(c == 'k'); | ||
1087 | fail_unless(eina_value_array_get(value, 2, &c)); | ||
1088 | fail_unless(c == '-'); | ||
1089 | fail_unless(eina_value_array_get(value, 3, &c)); | ||
1090 | fail_unless(c == 's'); | ||
1091 | |||
1092 | snprintf(buf, sizeof(buf), "[%hhd, %hhd, %hhd, %hhd]", | ||
1093 | '*', 'k', '-', 's'); | ||
1094 | |||
1095 | str = eina_value_to_string(value); | ||
1096 | fail_unless(str != NULL); | ||
1097 | fail_unless(strcmp(str, buf) == 0); | ||
1098 | free(str); | ||
1099 | |||
1100 | eina_value_flush(value); | ||
1101 | fail_unless(eina_value_array_setup(value, EINA_VALUE_TYPE_STRINGSHARE, 2)); | ||
1102 | |||
1103 | fail_unless(eina_value_array_append(value, "Enlightenment.org")); | ||
1104 | fail_unless(eina_value_array_append(value, "X11")); | ||
1105 | fail_unless(eina_value_array_append(value, "Pants")); | ||
1106 | fail_unless(eina_value_array_append(value, "on!!!")); | ||
1107 | fail_unless(eina_value_array_append(value, "k-s")); | ||
1108 | |||
1109 | str = eina_value_to_string(value); | ||
1110 | fail_unless(str != NULL); | ||
1111 | fail_unless(strcmp(str, "[Enlightenment.org, X11, Pants, on!!!, k-s]") == 0); | ||
1112 | free(str); | ||
1113 | |||
1114 | eina_value_flush(value); | ||
1115 | fail_unless(eina_value_array_setup(value, EINA_VALUE_TYPE_CHAR, 0)); | ||
1116 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR)); | ||
1117 | |||
1118 | fail_unless(eina_value_set(&other, 100)); | ||
1119 | fail_unless(eina_value_get(&other, &c)); | ||
1120 | fail_unless(c == 100); | ||
1121 | |||
1122 | fail_unless(eina_value_convert(&other, value)); | ||
1123 | str = eina_value_to_string(value); | ||
1124 | fail_unless(str != NULL); | ||
1125 | fail_unless(strcmp(str, "[100]") == 0); | ||
1126 | free(str); | ||
1127 | |||
1128 | fail_unless(eina_value_array_set(value, 0, 33)); | ||
1129 | fail_unless(eina_value_convert(value, &other)); | ||
1130 | fail_unless(eina_value_get(&other, &c)); | ||
1131 | fail_unless(c == 33); | ||
1132 | |||
1133 | inarray = eina_inarray_new(sizeof(char), 0); | ||
1134 | fail_unless(inarray != NULL); | ||
1135 | c = 11; | ||
1136 | fail_unless(eina_inarray_append(inarray, &c) >= 0); | ||
1137 | c = 21; | ||
1138 | fail_unless(eina_inarray_append(inarray, &c) >= 0); | ||
1139 | c = 31; | ||
1140 | fail_unless(eina_inarray_append(inarray, &c) >= 0); | ||
1141 | desc.subtype = EINA_VALUE_TYPE_CHAR; | ||
1142 | desc.step = 0; | ||
1143 | desc.array = inarray; /* will be adopted and freed by value */ | ||
1144 | fail_unless(eina_value_set(value, desc)); /* manually configure */ | ||
1145 | fail_unless(eina_value_array_get(value, 0, &c)); | ||
1146 | fail_unless(c == 11); | ||
1147 | fail_unless(eina_value_array_get(value, 1, &c)); | ||
1148 | fail_unless(c == 21); | ||
1149 | fail_unless(eina_value_array_get(value, 2, &c)); | ||
1150 | fail_unless(c == 31); | ||
1151 | |||
1152 | eina_value_free(value); | ||
1153 | eina_shutdown(); | ||
1154 | } | ||
1155 | END_TEST | ||
1156 | |||
1157 | START_TEST(eina_value_test_list) | ||
1158 | { | ||
1159 | Eina_Value *value, other; | ||
1160 | Eina_Value_List desc; | ||
1161 | char c; | ||
1162 | char buf[1024]; | ||
1163 | char *str; | ||
1164 | const char *s; | ||
1165 | |||
1166 | eina_init(); | ||
1167 | |||
1168 | value = eina_value_list_new(EINA_VALUE_TYPE_CHAR); | ||
1169 | fail_unless(value != NULL); | ||
1170 | |||
1171 | fail_unless(eina_value_list_append(value, 'k')); | ||
1172 | fail_unless(eina_value_list_append(value, '-')); | ||
1173 | fail_unless(eina_value_list_append(value, 's')); | ||
1174 | |||
1175 | fail_unless(eina_value_list_get(value, 0, &c)); | ||
1176 | fail_unless(c == 'k'); | ||
1177 | fail_unless(eina_value_list_get(value, 1, &c)); | ||
1178 | fail_unless(c == '-'); | ||
1179 | fail_unless(eina_value_list_get(value, 2, &c)); | ||
1180 | fail_unless(c == 's'); | ||
1181 | |||
1182 | fail_unless(eina_value_list_insert(value, 0, '!')); | ||
1183 | fail_unless(eina_value_list_get(value, 0, &c)); | ||
1184 | fail_unless(c == '!'); | ||
1185 | fail_unless(eina_value_list_get(value, 1, &c)); | ||
1186 | fail_unless(c == 'k'); | ||
1187 | fail_unless(eina_value_list_get(value, 2, &c)); | ||
1188 | fail_unless(c == '-'); | ||
1189 | fail_unless(eina_value_list_get(value, 3, &c)); | ||
1190 | fail_unless(c == 's'); | ||
1191 | |||
1192 | fail_unless(eina_value_list_set(value, 0, '*')); | ||
1193 | fail_unless(eina_value_list_get(value, 0, &c)); | ||
1194 | fail_unless(c == '*'); | ||
1195 | fail_unless(eina_value_list_get(value, 1, &c)); | ||
1196 | fail_unless(c == 'k'); | ||
1197 | fail_unless(eina_value_list_get(value, 2, &c)); | ||
1198 | fail_unless(c == '-'); | ||
1199 | fail_unless(eina_value_list_get(value, 3, &c)); | ||
1200 | fail_unless(c == 's'); | ||
1201 | |||
1202 | snprintf(buf, sizeof(buf), "[%hhd, %hhd, %hhd, %hhd]", | ||
1203 | '*', 'k', '-', 's'); | ||
1204 | |||
1205 | str = eina_value_to_string(value); | ||
1206 | fail_unless(str != NULL); | ||
1207 | fail_unless(strcmp(str, buf) == 0); | ||
1208 | free(str); | ||
1209 | |||
1210 | eina_value_flush(value); | ||
1211 | fail_unless(eina_value_list_setup(value, EINA_VALUE_TYPE_STRINGSHARE)); | ||
1212 | |||
1213 | fail_unless(eina_value_list_append(value, "Enlightenment.org")); | ||
1214 | fail_unless(eina_value_list_append(value, "X11")); | ||
1215 | fail_unless(eina_value_list_append(value, "Pants")); | ||
1216 | fail_unless(eina_value_list_append(value, "on!!!")); | ||
1217 | fail_unless(eina_value_list_append(value, "k-s")); | ||
1218 | |||
1219 | str = eina_value_to_string(value); | ||
1220 | fail_unless(str != NULL); | ||
1221 | fail_unless(strcmp(str, "[Enlightenment.org, X11, Pants, on!!!, k-s]") == 0); | ||
1222 | free(str); | ||
1223 | |||
1224 | eina_value_flush(value); | ||
1225 | fail_unless(eina_value_list_setup(value, EINA_VALUE_TYPE_CHAR)); | ||
1226 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR)); | ||
1227 | |||
1228 | fail_unless(eina_value_set(&other, 100)); | ||
1229 | fail_unless(eina_value_get(&other, &c)); | ||
1230 | fail_unless(c == 100); | ||
1231 | |||
1232 | fail_unless(eina_value_convert(&other, value)); | ||
1233 | str = eina_value_to_string(value); | ||
1234 | fail_unless(str != NULL); | ||
1235 | fail_unless(strcmp(str, "[100]") == 0); | ||
1236 | free(str); | ||
1237 | |||
1238 | fail_unless(eina_value_list_set(value, 0, 33)); | ||
1239 | fail_unless(eina_value_convert(value, &other)); | ||
1240 | fail_unless(eina_value_get(&other, &c)); | ||
1241 | fail_unless(c == 33); | ||
1242 | |||
1243 | desc.subtype = EINA_VALUE_TYPE_STRING; | ||
1244 | desc.list = NULL; | ||
1245 | desc.list = eina_list_append(desc.list, strdup("hello")); | ||
1246 | desc.list = eina_list_append(desc.list, strdup("world")); | ||
1247 | desc.list = eina_list_append(desc.list, strdup("eina")); | ||
1248 | fail_unless(eina_list_count(desc.list) == 3); | ||
1249 | fail_unless(eina_value_set(value, desc)); | ||
1250 | fail_unless(eina_value_list_get(value, 0, &s)); | ||
1251 | fail_unless(s != NULL); | ||
1252 | fail_unless(strcmp(s, "hello") == 0); | ||
1253 | fail_unless(eina_value_list_get(value, 1, &s)); | ||
1254 | fail_unless(s != NULL); | ||
1255 | fail_unless(strcmp(s, "world") == 0); | ||
1256 | fail_unless(eina_value_list_get(value, 2, &s)); | ||
1257 | fail_unless(s != NULL); | ||
1258 | fail_unless(strcmp(s, "eina") == 0); | ||
1259 | |||
1260 | eina_value_free(value); | ||
1261 | eina_shutdown(); | ||
1262 | } | ||
1263 | END_TEST | ||
1264 | |||
1265 | START_TEST(eina_value_test_hash) | ||
1266 | { | ||
1267 | Eina_Value *value, other; | ||
1268 | Eina_Value_Hash desc; | ||
1269 | char c; | ||
1270 | char buf[1024]; | ||
1271 | char **ptr; | ||
1272 | char *str; | ||
1273 | const char *s; | ||
1274 | |||
1275 | eina_init(); | ||
1276 | |||
1277 | value = eina_value_hash_new(EINA_VALUE_TYPE_CHAR, 0); | ||
1278 | fail_unless(value != NULL); | ||
1279 | |||
1280 | fail_unless(eina_value_hash_set(value, "first", 'k')); | ||
1281 | fail_unless(eina_value_hash_set(value, "second", '-')); | ||
1282 | fail_unless(eina_value_hash_set(value, "third", 's')); | ||
1283 | |||
1284 | fail_unless(eina_value_hash_get(value, "first", &c)); | ||
1285 | fail_unless(c == 'k'); | ||
1286 | fail_unless(eina_value_hash_get(value, "second", &c)); | ||
1287 | fail_unless(c == '-'); | ||
1288 | fail_unless(eina_value_hash_get(value, "third", &c)); | ||
1289 | fail_unless(c == 's'); | ||
1290 | |||
1291 | fail_unless(eina_value_hash_set(value, "first", '!')); | ||
1292 | fail_unless(eina_value_hash_get(value, "first", &c)); | ||
1293 | fail_unless(c == '!'); | ||
1294 | fail_unless(eina_value_hash_get(value, "second", &c)); | ||
1295 | fail_unless(c == '-'); | ||
1296 | fail_unless(eina_value_hash_get(value, "third", &c)); | ||
1297 | fail_unless(c == 's'); | ||
1298 | |||
1299 | puts("testing hash to string -- may fail due hash algorithm changes!"); | ||
1300 | |||
1301 | /* watchout, this is the order I got -- hash algorithm changes may change | ||
1302 | * the order! | ||
1303 | */ | ||
1304 | snprintf(buf, sizeof(buf), "{first: %hhd, second: %hhd, third: %hhd}", | ||
1305 | '!', '-', 's'); | ||
1306 | |||
1307 | str = eina_value_to_string(value); | ||
1308 | fail_unless(str != NULL); | ||
1309 | printf("want: %s\n", buf); | ||
1310 | printf("got.: %s\n", str); | ||
1311 | fail_unless(strcmp(str, buf) == 0); | ||
1312 | free(str); | ||
1313 | |||
1314 | eina_value_flush(value); | ||
1315 | fail_unless(eina_value_hash_setup(value, EINA_VALUE_TYPE_STRINGSHARE, 0)); | ||
1316 | |||
1317 | fail_unless(eina_value_hash_set(value, "a", "Enlightenment.org")); | ||
1318 | fail_unless(eina_value_hash_set(value, "b", "X11")); | ||
1319 | fail_unless(eina_value_hash_set(value, "c", "Pants")); | ||
1320 | fail_unless(eina_value_hash_set(value, "d", "on!!!")); | ||
1321 | fail_unless(eina_value_hash_set(value, "e", "k-s")); | ||
1322 | |||
1323 | /* watchout, this is the order I got -- hash algorithm changes may change | ||
1324 | * the order! | ||
1325 | */ | ||
1326 | strcpy(buf, "{e: k-s, d: on!!!, a: Enlightenment.org, b: X11, c: Pants}"); | ||
1327 | |||
1328 | str = eina_value_to_string(value); | ||
1329 | fail_unless(str != NULL); | ||
1330 | printf("want: %s\n", buf); | ||
1331 | printf("got.: %s\n", str); | ||
1332 | fail_unless(strcmp(str, buf) == 0); | ||
1333 | free(str); | ||
1334 | |||
1335 | eina_value_flush(value); | ||
1336 | fail_unless(eina_value_hash_setup(value, EINA_VALUE_TYPE_CHAR, 0)); | ||
1337 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR)); | ||
1338 | |||
1339 | fail_unless(eina_value_set(&other, 100)); | ||
1340 | fail_unless(eina_value_get(&other, &c)); | ||
1341 | fail_unless(c == 100); | ||
1342 | |||
1343 | fail_unless(eina_value_hash_set(value, "first", 33)); | ||
1344 | fail_unless(eina_value_convert(value, &other)); | ||
1345 | fail_unless(eina_value_get(&other, &c)); | ||
1346 | fail_unless(c == 33); | ||
1347 | |||
1348 | desc.subtype = EINA_VALUE_TYPE_STRING; | ||
1349 | desc.buckets_power_size = 0; | ||
1350 | desc.hash = eina_hash_string_small_new(NULL); | ||
1351 | fail_unless(desc.hash != NULL); | ||
1352 | /* watch out hash pointer is to a size of subtype->value_size! */ | ||
1353 | ptr = malloc(sizeof(char *)); | ||
1354 | *ptr = strdup("there"); | ||
1355 | fail_unless(eina_hash_add(desc.hash, "hi", ptr)); | ||
1356 | ptr = malloc(sizeof(char *)); | ||
1357 | *ptr = strdup("y"); | ||
1358 | fail_unless(eina_hash_add(desc.hash, "x", ptr)); | ||
1359 | |||
1360 | fail_unless(eina_value_set(value, desc)); | ||
1361 | |||
1362 | fail_unless(eina_value_hash_get(value, "hi", &s)); | ||
1363 | fail_unless(s != NULL); | ||
1364 | fail_unless(strcmp(s, "there") == 0); | ||
1365 | |||
1366 | fail_unless(eina_value_hash_get(value, "x", &s)); | ||
1367 | fail_unless(s != NULL); | ||
1368 | fail_unless(strcmp(s, "y") == 0); | ||
1369 | |||
1370 | eina_value_free(value); | ||
1371 | eina_shutdown(); | ||
1372 | } | ||
1373 | END_TEST | ||
1374 | |||
1375 | |||
1376 | START_TEST(eina_value_test_timeval) | ||
1377 | { | ||
1378 | Eina_Value *value, other; | ||
1379 | struct timeval itv, otv; | ||
1380 | char c; | ||
1381 | char *str; | ||
1382 | |||
1383 | eina_init(); | ||
1384 | |||
1385 | value = eina_value_new(EINA_VALUE_TYPE_TIMEVAL); | ||
1386 | fail_unless(value != NULL); | ||
1387 | |||
1388 | itv.tv_sec = 1; | ||
1389 | itv.tv_usec = 123; | ||
1390 | fail_unless(eina_value_set(value, itv)); | ||
1391 | fail_unless(eina_value_get(value, &otv)); | ||
1392 | fail_unless(memcmp(&itv, &otv, sizeof(struct timeval)) == 0); | ||
1393 | |||
1394 | itv.tv_sec = 3; | ||
1395 | itv.tv_usec = -1; | ||
1396 | fail_unless(eina_value_set(value, itv)); | ||
1397 | fail_unless(eina_value_get(value, &otv)); | ||
1398 | itv.tv_sec = 2; | ||
1399 | itv.tv_usec = 999999; | ||
1400 | fail_unless(memcmp(&itv, &otv, sizeof(struct timeval)) == 0); | ||
1401 | |||
1402 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR)); | ||
1403 | fail_unless(eina_value_convert(value, &other)); | ||
1404 | fail_unless(eina_value_get(&other, &c)); | ||
1405 | fail_unless(c == 2); | ||
1406 | eina_value_flush(&other); | ||
1407 | |||
1408 | itv.tv_sec = 12345; | ||
1409 | itv.tv_usec = 6789; | ||
1410 | fail_unless(eina_value_set(value, itv)); | ||
1411 | str = eina_value_to_string(value); | ||
1412 | fail_unless(str != NULL); | ||
1413 | fail_unless(strcmp(str, "12345.006789") == 0); | ||
1414 | free(str); | ||
1415 | |||
1416 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_TIMEVAL)); | ||
1417 | fail_unless(eina_value_set(&other, itv)); | ||
1418 | fail_unless(eina_value_compare(value, &other) == 0); | ||
1419 | |||
1420 | itv.tv_sec++; | ||
1421 | fail_unless(eina_value_set(&other, itv)); | ||
1422 | fail_unless(eina_value_compare(value, &other) < 0); | ||
1423 | |||
1424 | itv.tv_sec -= 2; | ||
1425 | fail_unless(eina_value_set(&other, itv)); | ||
1426 | fail_unless(eina_value_compare(value, &other) > 0); | ||
1427 | |||
1428 | itv.tv_sec++; | ||
1429 | fail_unless(eina_value_set(&other, itv)); | ||
1430 | fail_unless(eina_value_compare(value, &other) == 0); | ||
1431 | |||
1432 | itv.tv_usec++; | ||
1433 | fail_unless(eina_value_set(&other, itv)); | ||
1434 | fail_unless(eina_value_compare(value, &other) < 0); | ||
1435 | |||
1436 | itv.tv_usec -= 2; | ||
1437 | fail_unless(eina_value_set(&other, itv)); | ||
1438 | fail_unless(eina_value_compare(value, &other) > 0); | ||
1439 | |||
1440 | itv.tv_usec++; | ||
1441 | fail_unless(eina_value_set(&other, itv)); | ||
1442 | fail_unless(eina_value_compare(value, &other) == 0); | ||
1443 | |||
1444 | eina_value_flush(&other); | ||
1445 | |||
1446 | |||
1447 | eina_value_free(value); | ||
1448 | eina_shutdown(); | ||
1449 | } | ||
1450 | END_TEST | ||
1451 | |||
1452 | |||
1453 | START_TEST(eina_value_test_blob) | ||
1454 | { | ||
1455 | Eina_Value *value, other; | ||
1456 | Eina_Value_Blob in, out; | ||
1457 | unsigned char blob[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
1458 | int i = 0x11223344; | ||
1459 | char *str; | ||
1460 | |||
1461 | eina_init(); | ||
1462 | |||
1463 | value = eina_value_new(EINA_VALUE_TYPE_BLOB); | ||
1464 | fail_unless(value != NULL); | ||
1465 | |||
1466 | in.ops = NULL; | ||
1467 | in.memory = blob; | ||
1468 | in.size = sizeof(blob); | ||
1469 | fail_unless(eina_value_set(value, in)); | ||
1470 | fail_unless(eina_value_get(value, &out)); | ||
1471 | fail_unless(out.memory == blob); | ||
1472 | fail_unless(out.size == sizeof(blob)); | ||
1473 | fail_unless(memcmp(&in, &out, sizeof(Eina_Value_Blob)) == 0); | ||
1474 | |||
1475 | str = eina_value_to_string(value); | ||
1476 | fail_unless(str != NULL); | ||
1477 | fail_unless(strcmp(str, "BLOB(10, [01 02 03 04 05 06 07 08 09 0a])") == 0); | ||
1478 | free(str); | ||
1479 | |||
1480 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_INT)); | ||
1481 | fail_unless(eina_value_set(&other, i)); | ||
1482 | fail_unless(eina_value_convert(&other, value)); | ||
1483 | fail_unless(eina_value_get(value, &out)); | ||
1484 | |||
1485 | fail_unless(out.memory != NULL); | ||
1486 | fail_unless(out.size == sizeof(int)); | ||
1487 | fail_unless(memcmp(&i, out.memory, sizeof(int)) == 0); | ||
1488 | |||
1489 | eina_value_flush(&other); | ||
1490 | |||
1491 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_STRING)); | ||
1492 | fail_unless(eina_value_set(&other, "hi there!")); | ||
1493 | fail_unless(eina_value_convert(&other, value)); | ||
1494 | fail_unless(eina_value_get(value, &out)); | ||
1495 | fail_unless(out.memory != NULL); | ||
1496 | fail_unless(out.size == sizeof("hi there!")); | ||
1497 | fail_unless(strcmp(out.memory, "hi there!") == 0); | ||
1498 | |||
1499 | str = eina_value_to_string(value); | ||
1500 | fail_unless(str != NULL); | ||
1501 | fail_unless(strcmp(str, "BLOB(10, [68 69 20 74 68 65 72 65 21 00])") == 0); | ||
1502 | free(str); | ||
1503 | |||
1504 | eina_value_flush(&other); | ||
1505 | |||
1506 | fail_unless(eina_value_array_setup(&other, EINA_VALUE_TYPE_CHAR, 0)); | ||
1507 | fail_unless(eina_value_array_append(&other, 0xa)); | ||
1508 | fail_unless(eina_value_array_append(&other, 0xb)); | ||
1509 | fail_unless(eina_value_array_append(&other, 0xc)); | ||
1510 | fail_unless(eina_value_convert(&other, value)); | ||
1511 | fail_unless(eina_value_get(value, &out)); | ||
1512 | fail_unless(out.memory != NULL); | ||
1513 | fail_unless(out.size == 3); | ||
1514 | |||
1515 | str = eina_value_to_string(value); | ||
1516 | fail_unless(str != NULL); | ||
1517 | fail_unless(strcmp(str, "BLOB(3, [0a 0b 0c])") == 0); | ||
1518 | free(str); | ||
1519 | |||
1520 | eina_value_flush(&other); | ||
1521 | |||
1522 | fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_BLOB)); | ||
1523 | fail_unless(eina_value_set(&other, in)); | ||
1524 | fail_unless(eina_value_convert(value, &other)); | ||
1525 | fail_unless(eina_value_get(&other, &out)); | ||
1526 | fail_unless(out.memory != NULL); | ||
1527 | fail_unless(out.size == 3); | ||
1528 | |||
1529 | str = eina_value_to_string(&other); | ||
1530 | fail_unless(str != NULL); | ||
1531 | fail_unless(strcmp(str, "BLOB(3, [0a 0b 0c])") == 0); | ||
1532 | free(str); | ||
1533 | |||
1534 | eina_value_flush(&other); | ||
1535 | |||
1536 | eina_value_free(value); | ||
1537 | eina_shutdown(); | ||
1538 | } | ||
1539 | END_TEST | ||
1540 | |||
1541 | |||
1542 | START_TEST(eina_value_test_struct) | ||
1543 | { | ||
1544 | struct mybigst { | ||
1545 | int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, x; | ||
1546 | }; | ||
1547 | const Eina_Value_Struct_Member mybigst_members[] = { | ||
1548 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, a), | ||
1549 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, b), | ||
1550 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, c), | ||
1551 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, d), | ||
1552 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, e), | ||
1553 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, f), | ||
1554 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, g), | ||
1555 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, h), | ||
1556 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, i), | ||
1557 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, j), | ||
1558 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, k), | ||
1559 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, l), | ||
1560 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, m), | ||
1561 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, n), | ||
1562 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, o), | ||
1563 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, p), | ||
1564 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, q), | ||
1565 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, r), | ||
1566 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, s), | ||
1567 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, t), | ||
1568 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, u), | ||
1569 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, v), | ||
1570 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, x), | ||
1571 | EINA_VALUE_STRUCT_MEMBER_SENTINEL | ||
1572 | }; | ||
1573 | const Eina_Value_Struct_Desc mybigst_desc = { | ||
1574 | EINA_VALUE_STRUCT_DESC_VERSION, | ||
1575 | EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH, | ||
1576 | mybigst_members, 23, sizeof(struct mybigst) | ||
1577 | }; | ||
1578 | struct myst { | ||
1579 | int i; | ||
1580 | char c; | ||
1581 | }; | ||
1582 | const Eina_Value_Struct_Member myst_members[] = { | ||
1583 | {"i", EINA_VALUE_TYPE_INT, 0}, | ||
1584 | {"c", EINA_VALUE_TYPE_CHAR, 4}, | ||
1585 | {NULL, NULL, 0} | ||
1586 | }; | ||
1587 | const Eina_Value_Struct_Desc myst_desc = { | ||
1588 | EINA_VALUE_STRUCT_DESC_VERSION, | ||
1589 | NULL, myst_members, 2, sizeof(struct myst) | ||
1590 | }; | ||
1591 | Eina_Value *value, other; | ||
1592 | int i; | ||
1593 | char c; | ||
1594 | char *str; | ||
1595 | |||
1596 | eina_init(); | ||
1597 | |||
1598 | value = eina_value_struct_new(&myst_desc); | ||
1599 | fail_unless(value != NULL); | ||
1600 | |||
1601 | fail_unless(eina_value_struct_set(value, "i", 5678)); | ||
1602 | fail_unless(eina_value_struct_set(value, "c", 0xf)); | ||
1603 | |||
1604 | fail_unless(eina_value_struct_get(value, "i", &i)); | ||
1605 | fail_unless(i == 5678); | ||
1606 | fail_unless(eina_value_struct_get(value, "c", &c)); | ||
1607 | fail_unless(c == 0xf); | ||
1608 | |||
1609 | str = eina_value_to_string(value); | ||
1610 | fail_unless(str != NULL); | ||
1611 | fail_unless(strcmp(str, "{i: 5678, c: 15}") == 0); | ||
1612 | free(str); | ||
1613 | |||
1614 | fail_if(eina_value_struct_get(value, "x", 1234)); | ||
1615 | |||
1616 | i = 0x11223344; | ||
1617 | fail_unless(eina_value_struct_pset(value, "i", &i)); | ||
1618 | i = -1; | ||
1619 | fail_unless(eina_value_struct_pget(value, "i", &i)); | ||
1620 | fail_unless(i == 0x11223344); | ||
1621 | |||
1622 | fail_unless(eina_value_copy(value, &other)); | ||
1623 | str = eina_value_to_string(&other); | ||
1624 | fail_unless(str != NULL); | ||
1625 | fail_unless(strcmp(str, "{i: 287454020, c: 15}") == 0); | ||
1626 | free(str); | ||
1627 | |||
1628 | eina_value_flush(&other); | ||
1629 | |||
1630 | fail_unless(eina_value_struct_setup(&other, &mybigst_desc)); | ||
1631 | fail_unless(eina_value_struct_set(&other, "a", 1) ); | ||
1632 | fail_unless(eina_value_struct_set(&other, "b", 2)); | ||
1633 | fail_unless(eina_value_struct_set(&other, "c", 3)); | ||
1634 | fail_unless(eina_value_struct_set(&other, "d", 4)); | ||
1635 | fail_unless(eina_value_struct_set(&other, "e", 5)); | ||
1636 | fail_unless(eina_value_struct_set(&other, "f", 6)); | ||
1637 | fail_unless(eina_value_struct_set(&other, "g", 7)); | ||
1638 | fail_unless(eina_value_struct_set(&other, "h", 8)); | ||
1639 | fail_unless(eina_value_struct_set(&other, "i", 9)); | ||
1640 | fail_unless(eina_value_struct_set(&other, "j", 10)); | ||
1641 | fail_unless(eina_value_struct_set(&other, "k", 12)); | ||
1642 | fail_unless(eina_value_struct_set(&other, "l", 13)); | ||
1643 | fail_unless(eina_value_struct_set(&other, "m", 14)); | ||
1644 | fail_unless(eina_value_struct_set(&other, "n", 15)); | ||
1645 | fail_unless(eina_value_struct_set(&other, "o", 16)); | ||
1646 | fail_unless(eina_value_struct_set(&other, "p", 17)); | ||
1647 | fail_unless(eina_value_struct_set(&other, "q", 18)); | ||
1648 | fail_unless(eina_value_struct_set(&other, "r", 19)); | ||
1649 | fail_unless(eina_value_struct_set(&other, "s", 20)); | ||
1650 | fail_unless(eina_value_struct_set(&other, "t", 21)); | ||
1651 | fail_unless(eina_value_struct_set(&other, "u", 22)); | ||
1652 | fail_unless(eina_value_struct_set(&other, "v", 23)); | ||
1653 | fail_unless(eina_value_struct_set(&other, "x", 24)); | ||
1654 | |||
1655 | fail_unless(eina_value_struct_get(&other, "a", &i)); | ||
1656 | fail_unless(i == 1); | ||
1657 | fail_unless(eina_value_struct_get(&other, "b", &i)); | ||
1658 | fail_unless(i == 2); | ||
1659 | fail_unless(eina_value_struct_get(&other, "c", &i)); | ||
1660 | fail_unless(i == 3); | ||
1661 | fail_unless(eina_value_struct_get(&other, "d", &i)); | ||
1662 | fail_unless(i == 4); | ||
1663 | fail_unless(eina_value_struct_get(&other, "e", &i)); | ||
1664 | fail_unless(i == 5); | ||
1665 | fail_unless(eina_value_struct_get(&other, "f", &i)); | ||
1666 | fail_unless(i == 6); | ||
1667 | fail_unless(eina_value_struct_get(&other, "g", &i)); | ||
1668 | fail_unless(i == 7); | ||
1669 | fail_unless(eina_value_struct_get(&other, "h", &i)); | ||
1670 | fail_unless(i == 8); | ||
1671 | fail_unless(eina_value_struct_get(&other, "i", &i)); | ||
1672 | fail_unless(i == 9); | ||
1673 | fail_unless(eina_value_struct_get(&other, "j", &i)); | ||
1674 | fail_unless(i == 10); | ||
1675 | fail_unless(eina_value_struct_get(&other, "k", &i)); | ||
1676 | fail_unless(i == 12); | ||
1677 | fail_unless(eina_value_struct_get(&other, "l", &i)); | ||
1678 | fail_unless(i == 13); | ||
1679 | fail_unless(eina_value_struct_get(&other, "m", &i)); | ||
1680 | fail_unless(i == 14); | ||
1681 | fail_unless(eina_value_struct_get(&other, "n", &i)); | ||
1682 | fail_unless(i == 15); | ||
1683 | fail_unless(eina_value_struct_get(&other, "o", &i)); | ||
1684 | fail_unless(i == 16); | ||
1685 | fail_unless(eina_value_struct_get(&other, "p", &i)); | ||
1686 | fail_unless(i == 17); | ||
1687 | fail_unless(eina_value_struct_get(&other, "q", &i)); | ||
1688 | fail_unless(i == 18); | ||
1689 | fail_unless(eina_value_struct_get(&other, "r", &i)); | ||
1690 | fail_unless(i == 19); | ||
1691 | fail_unless(eina_value_struct_get(&other, "s", &i)); | ||
1692 | fail_unless(i == 20); | ||
1693 | fail_unless(eina_value_struct_get(&other, "t", &i)); | ||
1694 | fail_unless(i == 21); | ||
1695 | fail_unless(eina_value_struct_get(&other, "u", &i)); | ||
1696 | fail_unless(i == 22); | ||
1697 | fail_unless(eina_value_struct_get(&other, "v", &i)); | ||
1698 | fail_unless(i == 23); | ||
1699 | fail_unless(eina_value_struct_get(&other, "x", &i)); | ||
1700 | fail_unless(i == 24); | ||
1701 | |||
1702 | str = eina_value_to_string(&other); | ||
1703 | fail_unless(str != NULL); | ||
1704 | fail_unless(strcmp(str, "{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10, k: 12, l: 13, m: 14, n: 15, o: 16, p: 17, q: 18, r: 19, s: 20, t: 21, u: 22, v: 23, x: 24}") == 0); | ||
1705 | free(str); | ||
1706 | |||
1707 | eina_value_free(value); | ||
1708 | eina_shutdown(); | ||
1709 | } | ||
1710 | END_TEST | ||
1711 | |||
1712 | |||
1713 | START_TEST(eina_value_test_array_of_struct) | ||
1714 | { | ||
1715 | struct myst { | ||
1716 | int a, b, c; | ||
1717 | const char *s; | ||
1718 | }; | ||
1719 | const Eina_Value_Struct_Member myst_members[] = { | ||
1720 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct myst, a), | ||
1721 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct myst, b), | ||
1722 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct myst, c), | ||
1723 | EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_STRING, struct myst, s), | ||
1724 | EINA_VALUE_STRUCT_MEMBER_SENTINEL | ||
1725 | }; | ||
1726 | const Eina_Value_Struct_Desc myst_desc = { | ||
1727 | EINA_VALUE_STRUCT_DESC_VERSION, | ||
1728 | EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH, | ||
1729 | myst_members, 4, sizeof(struct myst) | ||
1730 | }; | ||
1731 | Eina_Value *value; | ||
1732 | char *str; | ||
1733 | int i; | ||
1734 | |||
1735 | eina_init(); | ||
1736 | |||
1737 | value = eina_value_array_new(EINA_VALUE_TYPE_STRUCT, 0); | ||
1738 | fail_unless(value != NULL); | ||
1739 | |||
1740 | for (i = 0; i < 10; i++) | ||
1741 | { | ||
1742 | Eina_Value_Struct desc; | ||
1743 | struct myst *st; | ||
1744 | char buf[64]; | ||
1745 | |||
1746 | snprintf(buf, sizeof(buf), "item%02d", i); | ||
1747 | st = malloc(sizeof(struct myst)); | ||
1748 | fail_unless(st != NULL); | ||
1749 | st->a = i; | ||
1750 | st->b = i * 10; | ||
1751 | st->c = i * 100; | ||
1752 | st->s = strdup(buf); | ||
1753 | fail_unless(st->s != NULL); | ||
1754 | |||
1755 | desc.desc = &myst_desc; | ||
1756 | desc.memory = st; | ||
1757 | fail_unless(eina_value_array_append(value, desc)); | ||
1758 | } | ||
1759 | |||
1760 | str = eina_value_to_string(value); | ||
1761 | fail_unless(str != NULL); | ||
1762 | fail_unless(strcmp(str, "[" | ||
1763 | "{a: 0, b: 0, c: 0, s: item00}, " | ||
1764 | "{a: 1, b: 10, c: 100, s: item01}, " | ||
1765 | "{a: 2, b: 20, c: 200, s: item02}, " | ||
1766 | "{a: 3, b: 30, c: 300, s: item03}, " | ||
1767 | "{a: 4, b: 40, c: 400, s: item04}, " | ||
1768 | "{a: 5, b: 50, c: 500, s: item05}, " | ||
1769 | "{a: 6, b: 60, c: 600, s: item06}, " | ||
1770 | "{a: 7, b: 70, c: 700, s: item07}, " | ||
1771 | "{a: 8, b: 80, c: 800, s: item08}, " | ||
1772 | "{a: 9, b: 90, c: 900, s: item09}" | ||
1773 | "]") == 0); | ||
1774 | free(str); | ||
1775 | |||
1776 | eina_value_free(value); | ||
1777 | eina_shutdown(); | ||
1778 | } | ||
1779 | END_TEST | ||
1780 | |||
1781 | void | ||
1782 | eina_test_value(TCase *tc) | ||
1783 | { | ||
1784 | tcase_add_test(tc, eina_value_test_simple); | ||
1785 | tcase_add_test(tc, eina_value_test_string); | ||
1786 | tcase_add_test(tc, eina_value_test_pvariant); | ||
1787 | tcase_add_test(tc, eina_value_test_compare); | ||
1788 | tcase_add_test(tc, eina_value_test_to_string); | ||
1789 | tcase_add_test(tc, eina_value_test_convert_char); | ||
1790 | tcase_add_test(tc, eina_value_test_convert_uchar); | ||
1791 | // TODO: other converters... | ||
1792 | tcase_add_test(tc, eina_value_test_array); | ||
1793 | tcase_add_test(tc, eina_value_test_list); | ||
1794 | tcase_add_test(tc, eina_value_test_hash); | ||
1795 | tcase_add_test(tc, eina_value_test_timeval); | ||
1796 | tcase_add_test(tc, eina_value_test_blob); | ||
1797 | tcase_add_test(tc, eina_value_test_struct); | ||
1798 | tcase_add_test(tc, eina_value_test_array_of_struct); | ||
1799 | } | ||