Commit | Line | Data |
---|---|---|
4f29b187 PP |
1 | /* |
2 | * test_bt_objects.c | |
3 | * | |
4 | * Babeltrace basic object system tests | |
5 | * | |
6 | * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation | |
7 | * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; under version 2 of the License. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License along | |
19 | * with this program; if not, write to the Free Software Foundation, Inc., | |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 | */ | |
22 | ||
23 | #define _GNU_SOURCE | |
24 | #include <babeltrace/objects.h> | |
25 | #include <assert.h> | |
26 | #include <string.h> | |
27 | #include "tap/tap.h" | |
28 | ||
29 | static | |
30 | void test_null(void) | |
31 | { | |
32 | ok(bt_object_null, "bt_object_null is not NULL"); | |
33 | ok(bt_object_is_null(bt_object_null), | |
34 | "bt_object_null is a null object"); | |
35 | bt_object_get(bt_object_null); | |
36 | pass("getting bt_object_null does not cause a crash"); | |
37 | bt_object_put(bt_object_null); | |
38 | pass("putting bt_object_null does not cause a crash"); | |
39 | ||
40 | bt_object_get(NULL); | |
41 | pass("getting NULL does not cause a crash"); | |
42 | bt_object_put(NULL); | |
43 | pass("putting NULL does not cause a crash"); | |
44 | ||
45 | ok(bt_object_get_type(NULL) == BT_OBJECT_TYPE_UNKNOWN, | |
46 | "bt_object_get_type(NULL) returns BT_OBJECT_TYPE_UNKNOWN"); | |
47 | } | |
48 | ||
49 | static | |
50 | void test_bool(void) | |
51 | { | |
52 | int ret; | |
53 | bool value; | |
54 | struct bt_object *obj; | |
55 | ||
56 | obj = bt_object_bool_create(); | |
57 | ok(obj && bt_object_is_bool(obj), | |
58 | "bt_object_bool_create() returns a boolean object"); | |
59 | ||
60 | value = true; | |
61 | ret = bt_object_bool_get(obj, &value); | |
62 | ok(!ret && !value, "default boolean object value is false"); | |
63 | ||
64 | ret = bt_object_bool_set(NULL, true); | |
65 | ok(ret, "bt_object_bool_set() fails with an object set to NULL"); | |
66 | ret = bt_object_bool_get(NULL, &value); | |
67 | ok(ret, "bt_object_bool_get() fails with an object set to NULL"); | |
68 | ||
69 | ret = bt_object_bool_set(obj, true); | |
70 | ok(!ret, "bt_object_bool_set() succeeds"); | |
71 | ret = bt_object_bool_get(obj, &value); | |
72 | ok(!ret && value, "bt_object_bool_set() works"); | |
73 | ||
74 | BT_OBJECT_PUT(obj); | |
75 | pass("putting an existing boolean object does not cause a crash") | |
76 | ||
77 | obj = bt_object_bool_create_init(true); | |
78 | ok(obj && bt_object_is_bool(obj), | |
79 | "bt_object_bool_create_init() returns a boolean object"); | |
80 | ret = bt_object_bool_get(obj, &value); | |
81 | ok(!ret && value, | |
82 | "bt_object_bool_create_init() sets the appropriate initial value"); | |
83 | ||
84 | BT_OBJECT_PUT(obj); | |
85 | } | |
86 | ||
87 | static | |
88 | void test_integer(void) | |
89 | { | |
90 | int ret; | |
91 | int64_t value; | |
92 | struct bt_object *obj; | |
93 | ||
94 | obj = bt_object_integer_create(); | |
95 | ok(obj && bt_object_is_integer(obj), | |
96 | "bt_object_integer_create() returns an integer object"); | |
97 | ||
98 | ret = bt_object_integer_set(NULL, -12345); | |
99 | ok(ret, "bt_object_integer_set() fails with an object set to NULL"); | |
100 | ret = bt_object_integer_get(NULL, &value); | |
101 | ok(ret, "bt_object_integer_get() fails with an object set to NULL"); | |
102 | ||
103 | value = 1961; | |
104 | ret = bt_object_integer_get(obj, &value); | |
105 | ok(!ret && value == 0, "default integer object value is 0"); | |
106 | ||
107 | ret = bt_object_integer_set(obj, -12345); | |
108 | ok(!ret, "bt_object_integer_set() succeeds"); | |
109 | ret = bt_object_integer_get(obj, &value); | |
110 | ok(!ret && value == -12345, "bt_object_integer_set() works"); | |
111 | ||
112 | BT_OBJECT_PUT(obj); | |
113 | pass("putting an existing integer object does not cause a crash") | |
114 | ||
115 | obj = bt_object_integer_create_init(321456987); | |
116 | ok(obj && bt_object_is_integer(obj), | |
117 | "bt_object_integer_create_init() returns an integer object"); | |
118 | ret = bt_object_integer_get(obj, &value); | |
119 | ok(!ret && value == 321456987, | |
120 | "bt_object_integer_create_init() sets the appropriate initial value"); | |
121 | ||
122 | BT_OBJECT_PUT(obj); | |
123 | } | |
124 | ||
125 | static | |
126 | void test_float(void) | |
127 | { | |
128 | int ret; | |
129 | double value; | |
130 | struct bt_object *obj; | |
131 | ||
132 | obj = bt_object_float_create(); | |
133 | ok(obj && bt_object_is_float(obj), | |
134 | "bt_object_float_create() returns a floating point number object"); | |
135 | ||
136 | ret = bt_object_float_set(NULL, 1.2345); | |
137 | ok(ret, "bt_object_float_set() fails with an object set to NULL"); | |
138 | ret = bt_object_float_get(NULL, &value); | |
139 | ok(ret, "bt_object_float_get() fails with an object set to NULL"); | |
140 | ||
141 | value = 17.34; | |
142 | ret = bt_object_float_get(obj, &value); | |
143 | ok(!ret && value == 0., "default floating point number object value is 0"); | |
144 | ||
145 | ret = bt_object_float_set(obj, -3.1416); | |
146 | ok(!ret, "bt_object_float_set() succeeds"); | |
147 | ret = bt_object_float_get(obj, &value); | |
148 | ok(!ret && value == -3.1416, "bt_object_float_set() works"); | |
149 | ||
150 | BT_OBJECT_PUT(obj); | |
151 | pass("putting an existing floating point number object does not cause a crash") | |
152 | ||
153 | obj = bt_object_float_create_init(33.1649758); | |
154 | ok(obj && bt_object_is_float(obj), | |
155 | "bt_object_float_create_init() returns a floating point number object"); | |
156 | ret = bt_object_float_get(obj, &value); | |
157 | ok(!ret && value == 33.1649758, | |
158 | "bt_object_float_create_init() sets the appropriate initial value"); | |
159 | ||
160 | BT_OBJECT_PUT(obj); | |
161 | } | |
162 | ||
163 | static | |
164 | void test_string(void) | |
165 | { | |
166 | int ret; | |
167 | const char *value; | |
168 | struct bt_object *obj; | |
169 | ||
170 | obj = bt_object_string_create(); | |
171 | ok(obj && bt_object_is_string(obj), | |
172 | "bt_object_string_create() returns a string object"); | |
173 | ||
174 | ret = bt_object_string_set(NULL, "hoho"); | |
175 | ok(ret, "bt_object_string_set() fails with an object set to NULL"); | |
176 | value = bt_object_string_get(NULL); | |
177 | ok(!value, "bt_object_string_get() fails with an object set to NULL"); | |
178 | ||
179 | value = bt_object_string_get(obj); | |
180 | ok(value && !strcmp(value, ""), | |
181 | "default string object value is \"\""); | |
182 | ||
183 | ret = bt_object_string_set(obj, "hello worldz"); | |
184 | ok(!ret, "bt_object_string_set() succeeds"); | |
185 | value = bt_object_string_get(obj); | |
186 | ok(value && !strcmp(value, "hello worldz"), | |
187 | "bt_object_string_set() works"); | |
188 | ret = bt_object_string_set(obj, NULL); | |
189 | ok(ret, "bt_object_string_set() does not accept a NULL value"); | |
190 | ||
191 | BT_OBJECT_PUT(obj); | |
192 | pass("putting an existing string object does not cause a crash") | |
193 | ||
194 | obj = bt_object_string_create_init(NULL); | |
195 | ok(!obj, "bt_object_string_create_init() fails with an initial value set to NULL"); | |
196 | obj = bt_object_string_create_init("initial value"); | |
197 | ok(obj && bt_object_is_string(obj), | |
198 | "bt_object_string_create_init() returns a string object"); | |
199 | value = bt_object_string_get(obj); | |
200 | ok(value && !strcmp(value, "initial value"), | |
201 | "bt_object_string_create_init() sets the appropriate initial value"); | |
202 | ||
203 | BT_OBJECT_PUT(obj); | |
204 | } | |
205 | ||
206 | static | |
207 | void test_array(void) | |
208 | { | |
209 | int ret; | |
210 | bool bool_value; | |
211 | int64_t int_value; | |
212 | double float_value; | |
213 | struct bt_object *obj; | |
214 | const char *string_value; | |
215 | struct bt_object *array_obj; | |
216 | ||
217 | array_obj = bt_object_array_create(); | |
218 | ok(array_obj && bt_object_is_array(array_obj), | |
219 | "bt_object_array_create() returns an array object"); | |
220 | ok(bt_object_array_is_empty(array_obj), | |
221 | "initial array object size is 0"); | |
222 | ok(bt_object_array_size(NULL) < 0, | |
223 | "bt_object_array_size() fails with an array object set to NULL"); | |
224 | ||
225 | ok(bt_object_array_append(NULL, bt_object_null), | |
226 | "bt_object_array_append() fails with an array object set to NULL"); | |
227 | ||
228 | obj = bt_object_integer_create_init(345); | |
229 | ret = bt_object_array_append(array_obj, obj); | |
230 | BT_OBJECT_PUT(obj); | |
231 | obj = bt_object_float_create_init(-17.45); | |
232 | ret |= bt_object_array_append(array_obj, obj); | |
233 | BT_OBJECT_PUT(obj); | |
234 | obj = bt_object_bool_create_init(true); | |
235 | ret |= bt_object_array_append(array_obj, obj); | |
236 | BT_OBJECT_PUT(obj); | |
237 | ret |= bt_object_array_append(array_obj, bt_object_null); | |
238 | ok(!ret, "bt_object_array_append() succeeds"); | |
239 | ret = bt_object_array_append(NULL, bt_object_null); | |
240 | ok(ret, "bt_object_array_append() fails with an array object set to NULL"); | |
241 | ret = bt_object_array_append(array_obj, NULL); | |
242 | ok(ret, "bt_object_array_append() fails with an element object set to NULL"); | |
243 | ok(bt_object_array_size(array_obj) == 4, | |
244 | "appending an element to an array object increment its size"); | |
245 | ||
246 | obj = bt_object_array_get(array_obj, 4); | |
247 | ok(!obj, "getting an array object's element at an index equal to its size fails"); | |
248 | obj = bt_object_array_get(array_obj, 5); | |
249 | ok(!obj, "getting an array object's element at a larger index fails"); | |
250 | ||
251 | obj = bt_object_array_get(NULL, 2); | |
252 | ok(!obj, "bt_object_array_get() fails with an array object set to NULL"); | |
253 | ||
254 | obj = bt_object_array_get(array_obj, 0); | |
255 | ok(obj && bt_object_is_integer(obj), | |
256 | "bt_object_array_get() returns an object with the appropriate type (integer)"); | |
257 | ret = bt_object_integer_get(obj, &int_value); | |
258 | ok(!ret && int_value == 345, | |
259 | "bt_object_array_get() returns an object with the appropriate value (integer)"); | |
260 | BT_OBJECT_PUT(obj); | |
261 | obj = bt_object_array_get(array_obj, 1); | |
262 | ok(obj && bt_object_is_float(obj), | |
263 | "bt_object_array_get() returns an object with the appropriate type (floating point number)"); | |
264 | ret = bt_object_float_get(obj, &float_value); | |
265 | ok(!ret && float_value == -17.45, | |
266 | "bt_object_array_get() returns an object with the appropriate value (floating point number)"); | |
267 | BT_OBJECT_PUT(obj); | |
268 | obj = bt_object_array_get(array_obj, 2); | |
269 | ok(obj && bt_object_is_bool(obj), | |
270 | "bt_object_array_get() returns an object with the appropriate type (boolean)"); | |
271 | ret = bt_object_bool_get(obj, &bool_value); | |
272 | ok(!ret && bool_value, | |
273 | "bt_object_array_get() returns an object with the appropriate value (boolean)"); | |
274 | BT_OBJECT_PUT(obj); | |
275 | obj = bt_object_array_get(array_obj, 3); | |
276 | ok(obj == bt_object_null, | |
277 | "bt_object_array_get() returns an object with the appropriate type (null)"); | |
278 | ||
5a5029c6 PP |
279 | ok(bt_object_array_set(NULL, 0, bt_object_null), |
280 | "bt_object_array_set() fails with an array object set to NULL"); | |
281 | ok(bt_object_array_set(array_obj, 0, NULL), | |
282 | "bt_object_array_set() fails with an element object set to NULL"); | |
283 | ok(bt_object_array_set(array_obj, 4, bt_object_null), | |
284 | "bt_object_array_set() fails with an invalid index"); | |
285 | obj = bt_object_integer_create_init(1001); | |
286 | assert(obj); | |
287 | ok(!bt_object_array_set(array_obj, 2, obj), | |
288 | "bt_object_array_set() succeeds"); | |
289 | BT_OBJECT_PUT(obj); | |
290 | obj = bt_object_array_get(array_obj, 2); | |
291 | ok(obj && bt_object_is_integer(obj), | |
292 | "bt_object_array_set() inserts an object with the appropriate type"); | |
293 | ret = bt_object_integer_get(obj, &int_value); | |
294 | assert(!ret); | |
295 | ok(int_value == 1001, | |
296 | "bt_object_array_set() inserts an object with the appropriate value"); | |
297 | BT_OBJECT_PUT(obj); | |
298 | ||
4f29b187 PP |
299 | ret = bt_object_array_append_bool(array_obj, false); |
300 | ok(!ret, "bt_object_array_append_bool() succeeds"); | |
301 | ret = bt_object_array_append_bool(NULL, true); | |
302 | ok(ret, "bt_object_array_append_bool() fails with an array object set to NULL"); | |
303 | ret = bt_object_array_append_integer(array_obj, 98765); | |
304 | ok(!ret, "bt_object_array_append_integer() succeeds"); | |
305 | ret = bt_object_array_append_integer(NULL, 18765); | |
306 | ok(ret, "bt_object_array_append_integer() fails with an array object set to NULL"); | |
307 | ret = bt_object_array_append_float(array_obj, 2.49578); | |
308 | ok(!ret, "bt_object_array_append_float() succeeds"); | |
309 | ret = bt_object_array_append_float(NULL, 1.49578); | |
310 | ok(ret, "bt_object_array_append_float() fails with an array object set to NULL"); | |
311 | ret = bt_object_array_append_string(array_obj, "bt_object"); | |
312 | ok(!ret, "bt_object_array_append_string() succeeds"); | |
313 | ret = bt_object_array_append_string(NULL, "bt_obj"); | |
314 | ok(ret, "bt_object_array_append_string() fails with an array object set to NULL"); | |
315 | ret = bt_object_array_append_array(array_obj); | |
316 | ok(!ret, "bt_object_array_append_array() succeeds"); | |
317 | ret = bt_object_array_append_array(NULL); | |
318 | ok(ret, "bt_object_array_append_array() fails with an array object set to NULL"); | |
319 | ret = bt_object_array_append_map(array_obj); | |
320 | ok(!ret, "bt_object_array_append_map() succeeds"); | |
321 | ret = bt_object_array_append_map(NULL); | |
322 | ok(ret, "bt_object_array_append_map() fails with an array object set to NULL"); | |
323 | ||
324 | ok(bt_object_array_size(array_obj) == 10, | |
325 | "the bt_object_array_append_*() functions increment the array object's size"); | |
326 | ok(!bt_object_array_is_empty(array_obj), | |
327 | "map object is not empty"); | |
328 | ||
329 | obj = bt_object_array_get(array_obj, 4); | |
330 | ok(obj && bt_object_is_bool(obj), | |
331 | "bt_object_array_append_bool() appends a boolean object"); | |
332 | ret = bt_object_bool_get(obj, &bool_value); | |
333 | ok(!ret && !bool_value, | |
334 | "bt_object_array_append_bool() appends the appropriate value"); | |
335 | BT_OBJECT_PUT(obj); | |
336 | obj = bt_object_array_get(array_obj, 5); | |
337 | ok(obj && bt_object_is_integer(obj), | |
338 | "bt_object_array_append_integer() appends an integer object"); | |
339 | ret = bt_object_integer_get(obj, &int_value); | |
340 | ok(!ret && int_value == 98765, | |
341 | "bt_object_array_append_integer() appends the appropriate value"); | |
342 | BT_OBJECT_PUT(obj); | |
343 | obj = bt_object_array_get(array_obj, 6); | |
344 | ok(obj && bt_object_is_float(obj), | |
345 | "bt_object_array_append_float() appends a floating point number object"); | |
346 | ret = bt_object_float_get(obj, &float_value); | |
347 | ok(!ret && float_value == 2.49578, | |
348 | "bt_object_array_append_float() appends the appropriate value"); | |
349 | BT_OBJECT_PUT(obj); | |
350 | obj = bt_object_array_get(array_obj, 7); | |
351 | ok(obj && bt_object_is_string(obj), | |
352 | "bt_object_array_append_string() appends a string object"); | |
353 | string_value = bt_object_string_get(obj); | |
354 | ok(string_value && !strcmp(string_value, "bt_object"), | |
355 | "bt_object_array_append_string() appends the appropriate value"); | |
356 | BT_OBJECT_PUT(obj); | |
357 | obj = bt_object_array_get(array_obj, 8); | |
358 | ok(obj && bt_object_is_array(obj), | |
359 | "bt_object_array_append_array() appends an array object"); | |
360 | ok(bt_object_array_is_empty(obj), | |
361 | "bt_object_array_append_array() an empty array object"); | |
362 | BT_OBJECT_PUT(obj); | |
363 | obj = bt_object_array_get(array_obj, 9); | |
364 | ok(obj && bt_object_is_map(obj), | |
365 | "bt_object_array_append_map() appends a map object"); | |
366 | ok(bt_object_map_is_empty(obj), | |
367 | "bt_object_array_append_map() an empty map object"); | |
368 | BT_OBJECT_PUT(obj); | |
369 | ||
370 | BT_OBJECT_PUT(array_obj); | |
371 | pass("putting an existing array object does not cause a crash") | |
372 | } | |
373 | ||
374 | static | |
375 | bool test_map_foreach_cb_count(const char *key, struct bt_object *object, | |
376 | void *data) | |
377 | { | |
378 | int *count = data; | |
379 | ||
380 | if (*count == 3) { | |
381 | return false; | |
382 | } | |
383 | ||
384 | (*count)++; | |
385 | ||
386 | return true; | |
387 | } | |
388 | ||
389 | struct map_foreach_checklist { | |
390 | bool bool1; | |
391 | bool int1; | |
392 | bool float1; | |
393 | bool null1; | |
394 | bool bool2; | |
395 | bool int2; | |
396 | bool float2; | |
397 | bool string2; | |
398 | bool array2; | |
399 | bool map2; | |
400 | }; | |
401 | ||
402 | static | |
403 | bool test_map_foreach_cb_check(const char *key, struct bt_object *object, | |
404 | void *data) | |
405 | { | |
406 | int ret; | |
407 | struct map_foreach_checklist *checklist = data; | |
408 | ||
409 | if (!strcmp(key, "bool")) { | |
410 | if (checklist->bool1) { | |
411 | fail("test_map_foreach_cb_check(): duplicate key \"bool\""); | |
412 | } else { | |
413 | bool val = false; | |
414 | ||
415 | ret = bt_object_bool_get(object, &val); | |
416 | ok(!ret, "test_map_foreach_cb_check(): success getting \"bool\" value"); | |
417 | ||
418 | if (val) { | |
419 | pass("test_map_foreach_cb_check(): \"bool\" object has the right value"); | |
420 | checklist->bool1 = true; | |
421 | } | |
422 | } | |
423 | } else if (!strcmp(key, "int")) { | |
424 | if (checklist->int1) { | |
425 | fail("test_map_foreach_cb_check(): duplicate key \"int\""); | |
426 | } else { | |
427 | int64_t val = 0; | |
428 | ||
429 | ret = bt_object_integer_get(object, &val); | |
430 | ok(!ret, "test_map_foreach_cb_check(): success getting \"int\" value"); | |
431 | ||
432 | if (val == 19457) { | |
433 | pass("test_map_foreach_cb_check(): \"int\" object has the right value"); | |
434 | checklist->int1 = true; | |
435 | } | |
436 | } | |
437 | } else if (!strcmp(key, "float")) { | |
438 | if (checklist->float1) { | |
439 | fail("test_map_foreach_cb_check(): duplicate key \"float\""); | |
440 | } else { | |
441 | double val = 0; | |
442 | ||
443 | ret = bt_object_float_get(object, &val); | |
444 | ok(!ret, "test_map_foreach_cb_check(): success getting \"float\" value"); | |
445 | ||
446 | if (val == 5.444) { | |
447 | pass("test_map_foreach_cb_check(): \"float\" object has the right value"); | |
448 | checklist->float1 = true; | |
449 | } | |
450 | } | |
451 | } else if (!strcmp(key, "null")) { | |
452 | if (checklist->null1) { | |
453 | fail("test_map_foreach_cb_check(): duplicate key \"bool\""); | |
454 | } else { | |
455 | ok(bt_object_is_null(object), "test_map_foreach_cb_check(): success getting \"null\" object"); | |
456 | checklist->null1 = true; | |
457 | } | |
458 | } else if (!strcmp(key, "bool2")) { | |
459 | if (checklist->bool2) { | |
460 | fail("test_map_foreach_cb_check(): duplicate key \"bool2\""); | |
461 | } else { | |
462 | bool val = false; | |
463 | ||
464 | ret = bt_object_bool_get(object, &val); | |
465 | ok(!ret, "test_map_foreach_cb_check(): success getting \"bool2\" value"); | |
466 | ||
467 | if (val) { | |
468 | pass("test_map_foreach_cb_check(): \"bool2\" object has the right value"); | |
469 | checklist->bool2 = true; | |
470 | } | |
471 | } | |
472 | } else if (!strcmp(key, "int2")) { | |
473 | if (checklist->int2) { | |
474 | fail("test_map_foreach_cb_check(): duplicate key \"int2\""); | |
475 | } else { | |
476 | int64_t val = 0; | |
477 | ||
478 | ret = bt_object_integer_get(object, &val); | |
479 | ok(!ret, "test_map_foreach_cb_check(): success getting \"int2\" value"); | |
480 | ||
481 | if (val == 98765) { | |
482 | pass("test_map_foreach_cb_check(): \"int2\" object has the right value"); | |
483 | checklist->int2 = true; | |
484 | } | |
485 | } | |
486 | } else if (!strcmp(key, "float2")) { | |
487 | if (checklist->float2) { | |
488 | fail("test_map_foreach_cb_check(): duplicate key \"float2\""); | |
489 | } else { | |
490 | double val = 0; | |
491 | ||
492 | ret = bt_object_float_get(object, &val); | |
493 | ok(!ret, "test_map_foreach_cb_check(): success getting \"float2\" value"); | |
494 | ||
495 | if (val == -49.0001) { | |
496 | pass("test_map_foreach_cb_check(): \"float2\" object has the right value"); | |
497 | checklist->float2 = true; | |
498 | } | |
499 | } | |
500 | } else if (!strcmp(key, "string2")) { | |
501 | if (checklist->string2) { | |
502 | fail("test_map_foreach_cb_check(): duplicate key \"string2\""); | |
503 | } else { | |
504 | const char *val = bt_object_string_get(object); | |
505 | ||
506 | ok(val, "test_map_foreach_cb_check(): success getting \"string2\" value"); | |
507 | ||
508 | if (val && !strcmp(val, "bt_object")) { | |
509 | pass("test_map_foreach_cb_check(): \"string2\" object has the right value"); | |
510 | checklist->string2 = true; | |
511 | } | |
512 | } | |
513 | } else if (!strcmp(key, "array2")) { | |
514 | if (checklist->array2) { | |
515 | fail("test_map_foreach_cb_check(): duplicate key \"array2\""); | |
516 | } else { | |
517 | ok(bt_object_is_array(object), "test_map_foreach_cb_check(): success getting \"array2\" object"); | |
518 | ok(bt_object_array_is_empty(object), | |
519 | "test_map_foreach_cb_check(): \"array2\" object is empty"); | |
520 | checklist->array2 = true; | |
521 | } | |
522 | } else if (!strcmp(key, "map2")) { | |
523 | if (checklist->map2) { | |
524 | fail("test_map_foreach_cb_check(): duplicate key \"map2\""); | |
525 | } else { | |
526 | ok(bt_object_is_map(object), "test_map_foreach_cb_check(): success getting \"map2\" object"); | |
527 | ok(bt_object_map_is_empty(object), | |
528 | "test_map_foreach_cb_check(): \"map2\" object is empty"); | |
529 | checklist->map2 = true; | |
530 | } | |
531 | } else { | |
532 | diag("test_map_foreach_cb_check(): unknown map key \"%s\"", | |
533 | key); | |
534 | fail("test_map_foreach_cb_check(): unknown map key"); | |
535 | } | |
536 | ||
537 | return true; | |
538 | } | |
539 | ||
540 | static | |
541 | void test_map(void) | |
542 | { | |
543 | int ret; | |
544 | int count = 0; | |
545 | bool bool_value; | |
546 | int64_t int_value; | |
547 | double float_value; | |
548 | struct bt_object *obj; | |
549 | struct bt_object *map_obj; | |
550 | struct map_foreach_checklist checklist; | |
551 | ||
552 | map_obj = bt_object_map_create(); | |
553 | ok(map_obj && bt_object_is_map(map_obj), | |
554 | "bt_object_map_create() returns a map object"); | |
555 | ok(bt_object_map_size(map_obj) == 0, | |
556 | "initial map object size is 0"); | |
557 | ok(bt_object_map_size(NULL) < 0, | |
558 | "bt_object_map_size() fails with a map object set to NULL"); | |
559 | ||
560 | ok(bt_object_map_insert(NULL, "hello", bt_object_null), | |
561 | "bt_object_array_insert() fails with a map object set to NULL"); | |
562 | ||
563 | ok(bt_object_map_insert(map_obj, NULL, bt_object_null), | |
564 | "bt_object_array_insert() fails with a key set to NULL"); | |
565 | ok(bt_object_map_insert(map_obj, "yeah", NULL), | |
566 | "bt_object_array_insert() fails with an element object set to NULL"); | |
567 | ||
568 | obj = bt_object_integer_create_init(19457); | |
569 | ret = bt_object_map_insert(map_obj, "int", obj); | |
570 | BT_OBJECT_PUT(obj); | |
571 | obj = bt_object_float_create_init(5.444); | |
572 | ret |= bt_object_map_insert(map_obj, "float", obj); | |
573 | BT_OBJECT_PUT(obj); | |
574 | obj = bt_object_bool_create(); | |
575 | ret |= bt_object_map_insert(map_obj, "bool", obj); | |
576 | BT_OBJECT_PUT(obj); | |
577 | ret |= bt_object_map_insert(map_obj, "null", bt_object_null); | |
578 | ok(!ret, "bt_object_map_insert() succeeds"); | |
579 | ok(bt_object_map_size(map_obj) == 4, | |
580 | "inserting an element into a map object increment its size"); | |
581 | ||
582 | obj = bt_object_bool_create_init(true); | |
583 | ret = bt_object_map_insert(map_obj, "bool", obj); | |
584 | BT_OBJECT_PUT(obj); | |
585 | ok(!ret, "bt_object_map_insert() accepts an existing key"); | |
586 | ||
587 | obj = bt_object_map_get(map_obj, NULL); | |
588 | ok(!obj, "bt_object_map_get() fails with a key set to NULL"); | |
589 | obj = bt_object_map_get(NULL, "bool"); | |
590 | ok(!obj, "bt_object_map_get() fails with a map object set to NULL"); | |
591 | ||
592 | obj = bt_object_map_get(map_obj, "life"); | |
593 | ok(!obj, "bt_object_map_get() fails with an non existing key"); | |
594 | obj = bt_object_map_get(map_obj, "float"); | |
595 | ok(obj && bt_object_is_float(obj), | |
596 | "bt_object_map_get() returns an object with the appropriate type (float)"); | |
597 | ret = bt_object_float_get(obj, &float_value); | |
598 | ok(!ret && float_value == 5.444, | |
599 | "bt_object_map_get() returns an object with the appropriate value (float)"); | |
600 | BT_OBJECT_PUT(obj); | |
601 | obj = bt_object_map_get(map_obj, "int"); | |
602 | ok(obj && bt_object_is_integer(obj), | |
603 | "bt_object_map_get() returns an object with the appropriate type (integer)"); | |
604 | ret = bt_object_integer_get(obj, &int_value); | |
605 | ok(!ret && int_value == 19457, | |
606 | "bt_object_map_get() returns an object with the appropriate value (integer)"); | |
607 | BT_OBJECT_PUT(obj); | |
608 | obj = bt_object_map_get(map_obj, "null"); | |
609 | ok(obj && bt_object_is_null(obj), | |
610 | "bt_object_map_get() returns an object with the appropriate type (null)"); | |
611 | obj = bt_object_map_get(map_obj, "bool"); | |
612 | ok(obj && bt_object_is_bool(obj), | |
613 | "bt_object_map_get() returns an object with the appropriate type (boolean)"); | |
614 | ret = bt_object_bool_get(obj, &bool_value); | |
615 | ok(!ret && bool_value, | |
616 | "bt_object_map_get() returns an object with the appropriate value (boolean)"); | |
617 | BT_OBJECT_PUT(obj); | |
618 | ||
619 | ret = bt_object_map_insert_bool(map_obj, "bool2", true); | |
620 | ok(!ret, "bt_object_map_insert_bool() succeeds"); | |
621 | ret = bt_object_map_insert_bool(NULL, "bool2", false); | |
622 | ok(ret, "bt_object_map_insert_bool() fails with a map object set to NULL"); | |
623 | ret = bt_object_map_insert_integer(map_obj, "int2", 98765); | |
624 | ok(!ret, "bt_object_map_insert_integer() succeeds"); | |
625 | ret = bt_object_map_insert_integer(NULL, "int2", 1001); | |
626 | ok(ret, "bt_object_map_insert_integer() fails with a map object set to NULL"); | |
627 | ret = bt_object_map_insert_float(map_obj, "float2", -49.0001); | |
628 | ok(!ret, "bt_object_map_insert_float() succeeds"); | |
629 | ret = bt_object_map_insert_float(NULL, "float2", 495); | |
630 | ok(ret, "bt_object_map_insert_float() fails with a map object set to NULL"); | |
631 | ret = bt_object_map_insert_string(map_obj, "string2", "bt_object"); | |
632 | ok(!ret, "bt_object_map_insert_string() succeeds"); | |
633 | ret = bt_object_map_insert_string(NULL, "string2", "bt_obj"); | |
634 | ok(ret, "bt_object_map_insert_string() fails with a map object set to NULL"); | |
635 | ret = bt_object_map_insert_array(map_obj, "array2"); | |
636 | ok(!ret, "bt_object_map_insert_array() succeeds"); | |
637 | ret = bt_object_map_insert_array(NULL, "array2"); | |
638 | ok(ret, "bt_object_map_insert_array() fails with a map object set to NULL"); | |
639 | ret = bt_object_map_insert_map(map_obj, "map2"); | |
640 | ok(!ret, "bt_object_map_insert_map() succeeds"); | |
641 | ret = bt_object_map_insert_map(NULL, "map2"); | |
642 | ok(ret, "bt_object_map_insert_map() fails with a map object set to NULL"); | |
643 | ||
644 | ok(bt_object_map_size(map_obj) == 10, | |
645 | "the bt_object_map_insert*() functions increment the map object's size"); | |
646 | ||
647 | ok(!bt_object_map_has_key(map_obj, "hello"), | |
648 | "map object does not have key \"hello\""); | |
649 | ok(bt_object_map_has_key(map_obj, "bool"), | |
650 | "map object has key \"bool\""); | |
651 | ok(bt_object_map_has_key(map_obj, "int"), | |
652 | "map object has key \"int\""); | |
653 | ok(bt_object_map_has_key(map_obj, "float"), | |
654 | "map object has key \"float\""); | |
655 | ok(bt_object_map_has_key(map_obj, "null"), | |
656 | "map object has key \"null\""); | |
657 | ok(bt_object_map_has_key(map_obj, "bool2"), | |
658 | "map object has key \"bool2\""); | |
659 | ok(bt_object_map_has_key(map_obj, "int2"), | |
660 | "map object has key \"int2\""); | |
661 | ok(bt_object_map_has_key(map_obj, "float2"), | |
662 | "map object has key \"float2\""); | |
663 | ok(bt_object_map_has_key(map_obj, "string2"), | |
664 | "map object has key \"string2\""); | |
665 | ok(bt_object_map_has_key(map_obj, "array2"), | |
666 | "map object has key \"array2\""); | |
667 | ok(bt_object_map_has_key(map_obj, "map2"), | |
668 | "map object has key \"map2\""); | |
669 | ||
670 | ret = bt_object_map_foreach(NULL, test_map_foreach_cb_count, &count); | |
671 | ok(ret, "bt_object_map_foreach() fails with a map object set to NULL"); | |
672 | ret = bt_object_map_foreach(map_obj, NULL, &count); | |
673 | ok(ret, "bt_object_map_foreach() fails with a user function set to NULL"); | |
674 | ret = bt_object_map_foreach(map_obj, test_map_foreach_cb_count, &count); | |
675 | ok(!ret && count == 3, | |
676 | "bt_object_map_foreach() breaks the loop when the user function returns false"); | |
677 | ||
678 | memset(&checklist, 0, sizeof(checklist)); | |
679 | ret = bt_object_map_foreach(map_obj, test_map_foreach_cb_check, | |
680 | &checklist); | |
681 | ok(!ret, "bt_object_map_foreach() succeeds with test_map_foreach_cb_check()"); | |
682 | ok(checklist.bool1 && checklist.int1 && checklist.float1 && | |
683 | checklist.null1 && checklist.bool2 && checklist.int2 && | |
684 | checklist.float2 && checklist.string2 && | |
685 | checklist.array2 && checklist.map2, | |
686 | "bt_object_map_foreach() iterates over all the map object's elements"); | |
687 | ||
688 | BT_OBJECT_PUT(map_obj); | |
689 | pass("putting an existing map object does not cause a crash") | |
690 | } | |
691 | ||
692 | static | |
693 | void test_types(void) | |
694 | { | |
695 | test_null(); | |
696 | test_bool(); | |
697 | test_integer(); | |
698 | test_float(); | |
699 | test_string(); | |
700 | test_array(); | |
701 | test_map(); | |
702 | } | |
703 | ||
704 | static | |
705 | void test_compare_null(void) | |
706 | { | |
707 | ok(!bt_object_compare(bt_object_null, NULL), | |
708 | "cannot compare null object and NULL"); | |
709 | ok(!bt_object_compare(NULL, bt_object_null), | |
710 | "cannot compare NULL and null object"); | |
711 | ok(bt_object_compare(bt_object_null, bt_object_null), | |
712 | "null objects are equivalent"); | |
713 | } | |
714 | ||
715 | static | |
716 | void test_compare_bool(void) | |
717 | { | |
718 | struct bt_object *bool1 = bt_object_bool_create_init(false); | |
719 | struct bt_object *bool2 = bt_object_bool_create_init(true); | |
720 | struct bt_object *bool3 = bt_object_bool_create_init(false); | |
721 | ||
722 | assert(bool1 && bool2 && bool3); | |
723 | ok(!bt_object_compare(bt_object_null, bool1), | |
724 | "cannot compare null object and bool object"); | |
725 | ok(!bt_object_compare(bool1, bool2), | |
726 | "integer objects are not equivalent (false and true)"); | |
727 | ok(bt_object_compare(bool1, bool3), | |
728 | "integer objects are equivalent (false and false)"); | |
729 | ||
730 | BT_OBJECT_PUT(bool1); | |
731 | BT_OBJECT_PUT(bool2); | |
732 | BT_OBJECT_PUT(bool3); | |
733 | } | |
734 | ||
735 | static | |
736 | void test_compare_integer(void) | |
737 | { | |
738 | struct bt_object *int1 = bt_object_integer_create_init(10); | |
739 | struct bt_object *int2 = bt_object_integer_create_init(-23); | |
740 | struct bt_object *int3 = bt_object_integer_create_init(10); | |
741 | ||
742 | assert(int1 && int2 && int3); | |
743 | ok(!bt_object_compare(bt_object_null, int1), | |
744 | "cannot compare null object and integer object"); | |
745 | ok(!bt_object_compare(int1, int2), | |
746 | "integer objects are not equivalent (10 and -23)"); | |
747 | ok(bt_object_compare(int1, int3), | |
748 | "integer objects are equivalent (10 and 10)"); | |
749 | ||
750 | BT_OBJECT_PUT(int1); | |
751 | BT_OBJECT_PUT(int2); | |
752 | BT_OBJECT_PUT(int3); | |
753 | } | |
754 | ||
755 | static | |
756 | void test_compare_float(void) | |
757 | { | |
758 | struct bt_object *float1 = bt_object_float_create_init(17.38); | |
759 | struct bt_object *float2 = bt_object_float_create_init(-14.23); | |
760 | struct bt_object *float3 = bt_object_float_create_init(17.38); | |
761 | ||
762 | assert(float1 && float2 && float3); | |
763 | ||
764 | ok(!bt_object_compare(bt_object_null, float1), | |
765 | "cannot compare null object and floating point number object"); | |
766 | ok(!bt_object_compare(float1, float2), | |
767 | "floating point number objects are not equivalent (17.38 and -14.23)"); | |
768 | ok(bt_object_compare(float1, float3), | |
769 | "floating point number objects are equivalent (17.38 and 17.38)"); | |
770 | ||
771 | BT_OBJECT_PUT(float1); | |
772 | BT_OBJECT_PUT(float2); | |
773 | BT_OBJECT_PUT(float3); | |
774 | } | |
775 | ||
776 | static | |
777 | void test_compare_string(void) | |
778 | { | |
779 | struct bt_object *string1 = bt_object_string_create_init("hello"); | |
780 | struct bt_object *string2 = bt_object_string_create_init("bt_object"); | |
781 | struct bt_object *string3 = bt_object_string_create_init("hello"); | |
782 | ||
783 | assert(string1 && string2 && string3); | |
784 | ||
785 | ok(!bt_object_compare(bt_object_null, string1), | |
786 | "cannot compare null object and string object"); | |
787 | ok(!bt_object_compare(string1, string2), | |
788 | "string objects are not equivalent (\"hello\" and \"bt_object\")"); | |
789 | ok(bt_object_compare(string1, string3), | |
790 | "string objects are equivalent (\"hello\" and \"hello\")"); | |
791 | ||
792 | BT_OBJECT_PUT(string1); | |
793 | BT_OBJECT_PUT(string2); | |
794 | BT_OBJECT_PUT(string3); | |
795 | } | |
796 | ||
797 | static | |
798 | void test_compare_array(void) | |
799 | { | |
800 | struct bt_object *array1 = bt_object_array_create(); | |
801 | struct bt_object *array2 = bt_object_array_create(); | |
802 | struct bt_object *array3 = bt_object_array_create(); | |
803 | ||
804 | assert(array1 && array2 && array3); | |
805 | ||
806 | ok(bt_object_compare(array1, array2), | |
807 | "empty array objects are equivalent"); | |
808 | ||
809 | assert(!bt_object_array_append_integer(array1, 23)); | |
810 | assert(!bt_object_array_append_float(array1, 14.2)); | |
811 | assert(!bt_object_array_append_bool(array1, false)); | |
812 | assert(!bt_object_array_append_float(array2, 14.2)); | |
813 | assert(!bt_object_array_append_integer(array2, 23)); | |
814 | assert(!bt_object_array_append_bool(array2, false)); | |
815 | assert(!bt_object_array_append_integer(array3, 23)); | |
816 | assert(!bt_object_array_append_float(array3, 14.2)); | |
817 | assert(!bt_object_array_append_bool(array3, false)); | |
818 | assert(bt_object_array_size(array1) == 3); | |
819 | assert(bt_object_array_size(array2) == 3); | |
820 | assert(bt_object_array_size(array3) == 3); | |
821 | ||
822 | ok(!bt_object_compare(bt_object_null, array1), | |
823 | "cannot compare null object and array object"); | |
824 | ok(!bt_object_compare(array1, array2), | |
825 | "array objects are not equivalent ([23, 14.2, false] and [14.2, 23, false])"); | |
826 | ok(bt_object_compare(array1, array3), | |
827 | "array objects are equivalent ([23, 14.2, false] and [23, 14.2, false])"); | |
828 | ||
829 | BT_OBJECT_PUT(array1); | |
830 | BT_OBJECT_PUT(array2); | |
831 | BT_OBJECT_PUT(array3); | |
832 | } | |
833 | ||
834 | static | |
835 | void test_compare_map(void) | |
836 | { | |
837 | struct bt_object *map1 = bt_object_map_create(); | |
838 | struct bt_object *map2 = bt_object_map_create(); | |
839 | struct bt_object *map3 = bt_object_map_create(); | |
840 | ||
841 | assert(map1 && map2 && map3); | |
842 | ||
843 | ok(bt_object_compare(map1, map2), | |
844 | "empty map objects are equivalent"); | |
845 | ||
846 | assert(!bt_object_map_insert_integer(map1, "one", 23)); | |
847 | assert(!bt_object_map_insert_float(map1, "two", 14.2)); | |
848 | assert(!bt_object_map_insert_bool(map1, "three", false)); | |
849 | assert(!bt_object_map_insert_float(map2, "one", 14.2)); | |
850 | assert(!bt_object_map_insert_integer(map2, "two", 23)); | |
851 | assert(!bt_object_map_insert_bool(map2, "three", false)); | |
852 | assert(!bt_object_map_insert_bool(map3, "three", false)); | |
853 | assert(!bt_object_map_insert_integer(map3, "one", 23)); | |
854 | assert(!bt_object_map_insert_float(map3, "two", 14.2)); | |
855 | assert(bt_object_map_size(map1) == 3); | |
856 | assert(bt_object_map_size(map2) == 3); | |
857 | assert(bt_object_map_size(map3) == 3); | |
858 | ||
859 | ok(!bt_object_compare(bt_object_null, map1), | |
860 | "cannot compare null object and map object"); | |
861 | ok(!bt_object_compare(map1, map2), | |
862 | "map objects are not equivalent"); | |
863 | ok(bt_object_compare(map1, map3), | |
864 | "map objects are equivalent"); | |
865 | ||
866 | BT_OBJECT_PUT(map1); | |
867 | BT_OBJECT_PUT(map2); | |
868 | BT_OBJECT_PUT(map3); | |
869 | } | |
870 | ||
871 | static | |
872 | void test_compare(void) | |
873 | { | |
874 | ok(!bt_object_compare(NULL, NULL), "cannot compare NULL and NULL"); | |
875 | test_compare_null(); | |
876 | test_compare_bool(); | |
877 | test_compare_integer(); | |
878 | test_compare_float(); | |
879 | test_compare_string(); | |
880 | test_compare_array(); | |
881 | test_compare_map(); | |
882 | } | |
883 | ||
884 | static | |
885 | void test_copy(void) | |
886 | { | |
887 | /* | |
888 | * Here's the deal here. If we make sure that each object | |
889 | * of our deep copy has a different address than its source, | |
890 | * and that bt_object_compare() returns true for the top-level | |
891 | * object, taking into account that we test the correctness of | |
892 | * bt_object_compare() elsewhere, then the deep copy is a | |
893 | * success. | |
894 | */ | |
895 | struct bt_object *null_copy_obj; | |
896 | struct bt_object *bool_obj, *bool_copy_obj; | |
897 | struct bt_object *integer_obj, *integer_copy_obj; | |
898 | struct bt_object *float_obj, *float_copy_obj; | |
899 | struct bt_object *string_obj, *string_copy_obj; | |
900 | struct bt_object *array_obj, *array_copy_obj; | |
901 | struct bt_object *map_obj, *map_copy_obj; | |
902 | ||
903 | bool_obj = bt_object_bool_create_init(true); | |
904 | integer_obj = bt_object_integer_create_init(23); | |
905 | float_obj = bt_object_float_create_init(-3.1416); | |
906 | string_obj = bt_object_string_create_init("test"); | |
907 | array_obj = bt_object_array_create(); | |
908 | map_obj = bt_object_map_create(); | |
909 | ||
910 | assert(bool_obj && integer_obj && float_obj && string_obj && | |
911 | array_obj && map_obj); | |
912 | ||
913 | assert(!bt_object_array_append(array_obj, bool_obj)); | |
914 | assert(!bt_object_array_append(array_obj, integer_obj)); | |
915 | assert(!bt_object_array_append(array_obj, float_obj)); | |
916 | assert(!bt_object_array_append(array_obj, bt_object_null)); | |
917 | assert(!bt_object_map_insert(map_obj, "array", array_obj)); | |
918 | assert(!bt_object_map_insert(map_obj, "string", string_obj)); | |
919 | ||
920 | map_copy_obj = bt_object_copy(NULL); | |
921 | ok(!map_copy_obj, | |
922 | "bt_object_copy() fails with a source object set to NULL"); | |
923 | ||
924 | map_copy_obj = bt_object_copy(map_obj); | |
925 | ok(map_copy_obj, | |
926 | "bt_object_copy() succeeds"); | |
927 | ||
928 | ok(map_obj != map_copy_obj, | |
929 | "bt_object_copy() returns a different pointer (map)"); | |
930 | string_copy_obj = bt_object_map_get(map_copy_obj, "string"); | |
931 | ok(string_copy_obj != string_obj, | |
932 | "bt_object_copy() returns a different pointer (string)"); | |
933 | array_copy_obj = bt_object_map_get(map_copy_obj, "array"); | |
934 | ok(array_copy_obj != array_obj, | |
935 | "bt_object_copy() returns a different pointer (array)"); | |
936 | bool_copy_obj = bt_object_array_get(array_copy_obj, 0); | |
937 | ok(bool_copy_obj != bool_obj, | |
938 | "bt_object_copy() returns a different pointer (bool)"); | |
939 | integer_copy_obj = bt_object_array_get(array_copy_obj, 1); | |
940 | ok(integer_copy_obj != integer_obj, | |
941 | "bt_object_copy() returns a different pointer (integer)"); | |
942 | float_copy_obj = bt_object_array_get(array_copy_obj, 2); | |
943 | ok(float_copy_obj != float_obj, | |
944 | "bt_object_copy() returns a different pointer (float)"); | |
945 | null_copy_obj = bt_object_array_get(array_copy_obj, 3); | |
946 | ok(null_copy_obj == bt_object_null, | |
947 | "bt_object_copy() returns the same pointer (null)"); | |
948 | ||
949 | ok(bt_object_compare(map_obj, map_copy_obj), | |
950 | "source and destination objects have the same content"); | |
951 | ||
952 | BT_OBJECT_PUT(bool_copy_obj); | |
953 | BT_OBJECT_PUT(integer_copy_obj); | |
954 | BT_OBJECT_PUT(float_copy_obj); | |
955 | BT_OBJECT_PUT(string_copy_obj); | |
956 | BT_OBJECT_PUT(array_copy_obj); | |
957 | BT_OBJECT_PUT(map_copy_obj); | |
958 | BT_OBJECT_PUT(bool_obj); | |
959 | BT_OBJECT_PUT(integer_obj); | |
960 | BT_OBJECT_PUT(float_obj); | |
961 | BT_OBJECT_PUT(string_obj); | |
962 | BT_OBJECT_PUT(array_obj); | |
963 | BT_OBJECT_PUT(map_obj); | |
964 | } | |
965 | ||
966 | static | |
967 | void test_macros(void) | |
968 | { | |
969 | struct bt_object *obj = bt_object_bool_create(); | |
970 | struct bt_object *src; | |
971 | struct bt_object *dst; | |
972 | ||
973 | assert(obj); | |
974 | BT_OBJECT_PUT(obj); | |
975 | ok(!obj, "BT_OBJECT_PUT() resets the variable to NULL"); | |
976 | ||
977 | obj = bt_object_bool_create(); | |
978 | assert(obj); | |
979 | src = obj; | |
980 | BT_OBJECT_MOVE(dst, src); | |
981 | ok(!src, "BT_OBJECT_MOVE() resets the source variable to NULL"); | |
982 | ok(dst == obj, "BT_OBJECT_MOVE() moves the ownership"); | |
983 | ||
984 | BT_OBJECT_PUT(dst); | |
985 | } | |
986 | ||
987 | int main(void) | |
988 | { | |
989 | plan_no_plan(); | |
990 | ||
991 | test_macros(); | |
992 | test_types(); | |
993 | test_compare(); | |
994 | test_copy(); | |
995 | ||
996 | return 0; | |
997 | } |