4 * Babeltrace value objects tests
6 * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
7 * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
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.
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.
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.
23 #include <babeltrace2/babeltrace.h>
24 #include "common/assert.h"
33 ok(bt_value_null
, "bt_value_null is not NULL");
34 ok(bt_value_is_null(bt_value_null
),
35 "bt_value_null is a null value object");
36 bt_value_get_ref(bt_value_null
);
37 pass("getting bt_value_null does not cause a crash");
38 bt_value_put_ref(bt_value_null
);
39 pass("putting bt_value_null does not cause a crash");
48 obj
= bt_value_bool_create();
49 ok(obj
&& bt_value_is_bool(obj
),
50 "bt_value_bool_create() returns a boolean value object");
53 value
= bt_value_bool_get(obj
);
54 ok(!value
, "default boolean value object value is BT_FALSE");
56 bt_value_bool_set(obj
, BT_FALSE
);
57 bt_value_bool_set(obj
, BT_TRUE
);
58 value
= bt_value_bool_get(obj
);
59 ok(value
, "bt_value_bool_set() works");
61 BT_VALUE_PUT_REF_AND_RESET(obj
);
62 pass("putting an existing boolean value object does not cause a crash")
65 obj
= bt_value_bool_create_init(BT_TRUE
);
66 ok(obj
&& bt_value_is_bool(obj
),
67 "bt_value_bool_create_init() returns a boolean value object");
68 value
= bt_value_bool_get(obj
);
70 "bt_value_bool_create_init() sets the appropriate initial value");
72 BT_VALUE_PUT_REF_AND_RESET(obj
);
76 void test_unsigned_integer(void)
81 obj
= bt_value_integer_unsigned_create();
82 ok(obj
&& bt_value_is_unsigned_integer(obj
),
83 "bt_value_integer_unsigned_create() returns an unsigned integer value object");
86 value
= bt_value_integer_unsigned_get(obj
);
87 ok(value
== 0, "default unsigned integer value object value is 0");
89 bt_value_integer_unsigned_set(obj
, 98765);
90 value
= bt_value_integer_unsigned_get(obj
);
91 ok(value
== 98765, "bt_value_integer_unsigned_bool_set() works");
93 BT_VALUE_PUT_REF_AND_RESET(obj
);
94 pass("putting an existing unsigned integer value object does not cause a crash")
96 obj
= bt_value_integer_unsigned_create_init(321456987);
97 ok(obj
&& bt_value_is_unsigned_integer(obj
),
98 "bt_value_integer_unsigned_create_init() returns an unsigned integer value object");
99 value
= bt_value_integer_unsigned_get(obj
);
100 ok(value
== 321456987,
101 "bt_value_integer_unsigned_create_init() sets the appropriate initial value");
103 BT_VALUE_PUT_REF_AND_RESET(obj
);
107 void test_signed_integer(void)
112 obj
= bt_value_integer_signed_create();
113 ok(obj
&& bt_value_is_signed_integer(obj
),
114 "bt_value_integer_signed_create() returns a signed integer value object");
117 value
= bt_value_integer_signed_get(obj
);
118 ok(value
== 0, "default signed integer value object value is 0");
120 bt_value_integer_signed_set(obj
, 98765);
121 value
= bt_value_integer_signed_get(obj
);
122 ok(value
== 98765, "bt_value_integer_signed_bool_set() works");
124 BT_VALUE_PUT_REF_AND_RESET(obj
);
125 pass("putting an existing signed integer value object does not cause a crash")
127 obj
= bt_value_integer_signed_create_init(-321456987);
128 ok(obj
&& bt_value_is_signed_integer(obj
),
129 "bt_value_integer_signed_create_init() returns a signed integer value object");
130 value
= bt_value_integer_signed_get(obj
);
131 ok(value
== -321456987,
132 "bt_value_integer_signed_create_init() sets the appropriate initial value");
134 BT_VALUE_PUT_REF_AND_RESET(obj
);
143 obj
= bt_value_real_create();
144 ok(obj
&& bt_value_is_real(obj
),
145 "bt_value_real_create() returns a real number value object");
148 value
= bt_value_real_get(obj
);
150 "default real number value object value is 0");
152 bt_value_real_set(obj
, -3.1416);
153 value
= bt_value_real_get(obj
);
154 ok(value
== -3.1416, "bt_value_real_set() works");
156 BT_VALUE_PUT_REF_AND_RESET(obj
);
157 pass("putting an existing real number value object does not cause a crash")
159 obj
= bt_value_real_create_init(33.1649758);
160 ok(obj
&& bt_value_is_real(obj
),
161 "bt_value_real_create_init() returns a real number value object");
162 value
= bt_value_real_get(obj
);
163 ok(value
== 33.1649758,
164 "bt_value_real_create_init() sets the appropriate initial value");
166 BT_VALUE_PUT_REF_AND_RESET(obj
);
170 void test_string(void)
175 obj
= bt_value_string_create();
176 ok(obj
&& bt_value_is_string(obj
),
177 "bt_value_string_create() returns a string value object");
179 value
= bt_value_string_get(obj
);
180 ok(value
&& strcmp(value
, "") == 0,
181 "default string value object value is \"\"");
183 bt_value_string_set(obj
, "hello worldz");
184 value
= bt_value_string_get(obj
);
185 ok(value
&& strcmp(value
, "hello worldz") == 0,
186 "bt_value_string_get() works");
188 BT_VALUE_PUT_REF_AND_RESET(obj
);
189 pass("putting an existing string value object does not cause a crash")
191 obj
= bt_value_string_create_init("initial value");
192 ok(obj
&& bt_value_is_string(obj
),
193 "bt_value_string_create_init() returns a string value object");
194 value
= bt_value_string_get(obj
);
195 ok(value
&& strcmp(value
, "initial value") == 0,
196 "bt_value_string_create_init() sets the appropriate initial value");
198 BT_VALUE_PUT_REF_AND_RESET(obj
);
202 void test_array(void)
209 const char *string_value
;
211 bt_value
*appended_obj
;
213 array_obj
= bt_value_array_create();
214 ok(array_obj
&& bt_value_is_array(array_obj
),
215 "bt_value_array_create() returns an array value object");
216 ok(bt_value_array_is_empty(array_obj
),
217 "initial array value object size is 0");
219 obj
= bt_value_integer_unsigned_create_init(345);
220 ret
= bt_value_array_append_element(array_obj
, obj
);
221 BT_VALUE_PUT_REF_AND_RESET(obj
);
222 obj
= bt_value_integer_signed_create_init(-507);
223 ret
|= bt_value_array_append_element(array_obj
, obj
);
224 BT_VALUE_PUT_REF_AND_RESET(obj
);
225 obj
= bt_value_real_create_init(-17.45);
226 ret
|= bt_value_array_append_element(array_obj
, obj
);
227 BT_VALUE_PUT_REF_AND_RESET(obj
);
228 obj
= bt_value_bool_create_init(BT_TRUE
);
229 ret
|= bt_value_array_append_element(array_obj
, obj
);
230 BT_VALUE_PUT_REF_AND_RESET(obj
);
231 ret
|= bt_value_array_append_element(array_obj
,
233 ok(!ret
, "bt_value_array_append_element() succeeds");
234 ok(bt_value_array_get_length(array_obj
) == 5,
235 "appending an element to an array value object increment its size");
237 obj
= bt_value_array_borrow_element_by_index(array_obj
, 0);
238 ok(obj
&& bt_value_is_unsigned_integer(obj
),
239 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (unsigned integer)");
240 int_value
= bt_value_integer_unsigned_get(obj
);
242 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (unsigned integer)");
243 obj
= bt_value_array_borrow_element_by_index(array_obj
, 1);
244 ok(obj
&& bt_value_is_signed_integer(obj
),
245 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (signed integer)");
246 int_value
= bt_value_integer_signed_get(obj
);
247 ok(int_value
== -507,
248 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (signed integer)");
249 obj
= bt_value_array_borrow_element_by_index(array_obj
, 2);
250 ok(obj
&& bt_value_is_real(obj
),
251 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (real number)");
252 real_value
= bt_value_real_get(obj
);
253 ok(real_value
== -17.45,
254 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (real number)");
255 obj
= bt_value_array_borrow_element_by_index(array_obj
, 3);
256 ok(obj
&& bt_value_is_bool(obj
),
257 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (boolean)");
258 bool_value
= bt_value_bool_get(obj
);
260 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (boolean)");
261 obj
= bt_value_array_borrow_element_by_index(array_obj
, 4);
262 ok(obj
== bt_value_null
,
263 "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (null)");
265 obj
= bt_value_integer_signed_create_init(1001);
267 ok(!bt_value_array_set_element_by_index(array_obj
, 2, obj
),
268 "bt_value_array_set_element_by_index() succeeds");
269 BT_VALUE_PUT_REF_AND_RESET(obj
);
270 obj
= bt_value_array_borrow_element_by_index(array_obj
, 2);
271 ok(obj
&& bt_value_is_signed_integer(obj
),
272 "bt_value_array_set_element_by_index() inserts an value object with the appropriate type");
273 int_value
= bt_value_integer_signed_get(obj
);
275 ok(int_value
== 1001,
276 "bt_value_array_set_element_by_index() inserts an value object with the appropriate value");
278 ret
= bt_value_array_append_bool_element(array_obj
,
280 ok(!ret
, "bt_value_array_append_bool_element() succeeds");
281 ret
= bt_value_array_append_unsigned_integer_element(array_obj
,
283 ok(!ret
, "bt_value_array_append_unsigned_integer_element() succeeds");
284 ret
= bt_value_array_append_signed_integer_element(array_obj
,
286 ok(!ret
, "bt_value_array_append_signed_integer_element() succeeds");
287 ret
= bt_value_array_append_real_element(array_obj
,
289 ok(!ret
, "bt_value_array_append_real_element() succeeds");
290 ret
= bt_value_array_append_string_element(array_obj
,
292 ok(!ret
, "bt_value_array_append_string_element() succeeds");
293 ret
= bt_value_array_append_empty_array_element(array_obj
, NULL
);
294 ok(!ret
, "bt_value_array_append_empty_array_element() succeeds");
295 ret
= bt_value_array_append_empty_array_element(array_obj
, &appended_obj
);
296 ok(!ret
, "bt_value_array_append_empty_array_element() with returned value object succeeds");
298 "object returned by bt_value_array_append_empty_array_element() is not NULL");
299 ok(bt_value_is_array(appended_obj
),
300 "object returned by bt_value_array_append_empty_array_element() is an array value");
301 ret
= bt_value_array_append_empty_map_element(array_obj
, NULL
);
302 ok(!ret
, "bt_value_array_append_empty_map_element() succeeds");
303 ret
= bt_value_array_append_empty_map_element(array_obj
, &appended_obj
);
304 ok(!ret
, "bt_value_array_append_empty_map_element() with returned value object succeeds");
306 "object returned by bt_value_array_append_empty_map_element() is not NULL");
307 ok(bt_value_is_map(appended_obj
),
308 "object returned by bt_value_array_append_empty_map_element() is an array value");
310 ok(bt_value_array_get_length(array_obj
) == 14,
311 "the bt_value_array_append_element_*() functions increment the array value object's size");
312 ok(!bt_value_array_is_empty(array_obj
),
313 "map value object is not empty");
315 obj
= bt_value_array_borrow_element_by_index(array_obj
, 5);
316 ok(obj
&& bt_value_is_bool(obj
),
317 "bt_value_array_append_bool_element() appends a boolean value object");
318 bool_value
= bt_value_bool_get(obj
);
320 "bt_value_array_append_bool_element() appends the appropriate value");
321 obj
= bt_value_array_borrow_element_by_index(array_obj
, 6);
322 ok(obj
&& bt_value_is_unsigned_integer(obj
),
323 "bt_value_array_append_unsigned_integer_element() appends an unsigned integer value object");
324 int_value
= bt_value_integer_unsigned_get(obj
);
325 ok(int_value
== 98765,
326 "bt_value_array_append_unsigned_integer_element() appends the appropriate value");
327 obj
= bt_value_array_borrow_element_by_index(array_obj
, 7);
328 ok(obj
&& bt_value_is_signed_integer(obj
),
329 "bt_value_array_append_signed_integer_element() appends a signed integer value object");
330 int_value
= bt_value_integer_signed_get(obj
);
331 ok(int_value
== -10101,
332 "bt_value_array_append_signed_integer_element() appends the appropriate value");
333 obj
= bt_value_array_borrow_element_by_index(array_obj
, 8);
334 ok(obj
&& bt_value_is_real(obj
),
335 "bt_value_array_append_real_element() appends a real number value object");
336 real_value
= bt_value_real_get(obj
);
337 ok(real_value
== 2.49578,
338 "bt_value_array_append_real_element() appends the appropriate value");
339 obj
= bt_value_array_borrow_element_by_index(array_obj
, 9);
340 ok(obj
&& bt_value_is_string(obj
),
341 "bt_value_array_append_string_element() appends a string value object");
342 string_value
= bt_value_string_get(obj
);
343 ok(!ret
&& string_value
&& strcmp(string_value
, "bt_value") == 0,
344 "bt_value_array_append_string_element() appends the appropriate value");
345 obj
= bt_value_array_borrow_element_by_index(array_obj
, 10);
346 ok(obj
&& bt_value_is_array(obj
),
347 "bt_value_array_append_empty_array_element() appends an array value object");
348 ok(bt_value_array_is_empty(obj
),
349 "bt_value_array_append_empty_array_element() an empty array value object");
350 obj
= bt_value_array_borrow_element_by_index(array_obj
, 11);
351 ok(obj
&& bt_value_is_array(obj
),
352 "bt_value_array_append_empty_array_element() appends an array value object");
353 ok(bt_value_array_is_empty(obj
),
354 "bt_value_array_append_empty_array_element() an empty array value object");
355 obj
= bt_value_array_borrow_element_by_index(array_obj
, 12);
356 ok(obj
&& bt_value_is_map(obj
),
357 "bt_value_array_append_empty_map_element() appends a map value object");
358 ok(bt_value_map_is_empty(obj
),
359 "bt_value_array_append_empty_map_element() an empty map value object");
360 obj
= bt_value_array_borrow_element_by_index(array_obj
, 13);
361 ok(obj
&& bt_value_is_map(obj
),
362 "bt_value_array_append_empty_map_element() appends a map value object");
363 ok(bt_value_map_is_empty(obj
),
364 "bt_value_array_append_empty_map_element() an empty map value object");
366 BT_VALUE_PUT_REF_AND_RESET(array_obj
);
367 pass("putting an existing array value object does not cause a crash")
371 bt_bool
test_map_foreach_cb_count(const char *key
, bt_value
*object
,
385 struct map_foreach_checklist
{
402 bt_bool
test_map_foreach_cb_check(const char *key
, bt_value
*object
,
405 struct map_foreach_checklist
*checklist
= data
;
407 if (strcmp(key
, "bt_bool") == 0) {
408 if (checklist
->bool1
) {
409 fail("test_map_foreach_cb_check(): duplicate key \"bt_bool\"");
411 bt_bool val
= BT_FALSE
;
413 val
= bt_value_bool_get(object
);
416 pass("test_map_foreach_cb_check(): \"bt_bool\" value object has the right value");
417 checklist
->bool1
= BT_TRUE
;
419 fail("test_map_foreach_cb_check(): \"bt_bool\" value object has the wrong value");
422 } else if (strcmp(key
, "uint") == 0) {
423 if (checklist
->uint
) {
424 fail("test_map_foreach_cb_check(): duplicate key \"uint\"");
428 val
= bt_value_integer_unsigned_get(object
);
431 pass("test_map_foreach_cb_check(): \"uint\" value object has the right value");
432 checklist
->uint
= BT_TRUE
;
434 fail("test_map_foreach_cb_check(): \"uint\" value object has the wrong value");
437 } else if (strcmp(key
, "int") == 0) {
438 if (checklist
->int1
) {
439 fail("test_map_foreach_cb_check(): duplicate key \"int\"");
443 val
= bt_value_integer_signed_get(object
);
446 pass("test_map_foreach_cb_check(): \"int\" value object has the right value");
447 checklist
->int1
= BT_TRUE
;
449 fail("test_map_foreach_cb_check(): \"int\" value object has the wrong value");
452 } else if (strcmp(key
, "real") == 0) {
453 if (checklist
->real1
) {
454 fail("test_map_foreach_cb_check(): duplicate key \"real\"");
458 val
= bt_value_real_get(object
);
461 pass("test_map_foreach_cb_check(): \"real\" value object has the right value");
462 checklist
->real1
= BT_TRUE
;
464 fail("test_map_foreach_cb_check(): \"real\" value object has the wrong value");
467 } else if (strcmp(key
, "null") == 0) {
468 if (checklist
->null1
) {
469 fail("test_map_foreach_cb_check(): duplicate key \"bt_bool\"");
471 ok(bt_value_is_null(object
), "test_map_foreach_cb_check(): success getting \"null\" value object");
472 checklist
->null1
= BT_TRUE
;
474 } else if (strcmp(key
, "bool2") == 0) {
475 if (checklist
->bool2
) {
476 fail("test_map_foreach_cb_check(): duplicate key \"bool2\"");
478 bt_bool val
= BT_FALSE
;
480 val
= bt_value_bool_get(object
);
483 pass("test_map_foreach_cb_check(): \"bool2\" value object has the right value");
484 checklist
->bool2
= BT_TRUE
;
486 fail("test_map_foreach_cb_check(): \"bool2\" value object has the wrong value");
489 } else if (strcmp(key
, "int2") == 0) {
490 if (checklist
->int2
) {
491 fail("test_map_foreach_cb_check(): duplicate key \"int2\"");
495 val
= bt_value_integer_signed_get(object
);
498 pass("test_map_foreach_cb_check(): \"int2\" value object has the right value");
499 checklist
->int2
= BT_TRUE
;
501 fail("test_map_foreach_cb_check(): \"int2\" value object has the wrong value");
504 } else if (strcmp(key
, "real2") == 0) {
505 if (checklist
->real2
) {
506 fail("test_map_foreach_cb_check(): duplicate key \"real2\"");
510 val
= bt_value_real_get(object
);
512 if (val
== -49.0001) {
513 pass("test_map_foreach_cb_check(): \"real2\" value object has the right value");
514 checklist
->real2
= BT_TRUE
;
516 fail("test_map_foreach_cb_check(): \"real2\" value object has the wrong value");
519 } else if (strcmp(key
, "string2") == 0) {
520 if (checklist
->string2
) {
521 fail("test_map_foreach_cb_check(): duplicate key \"string2\"");
525 val
= bt_value_string_get(object
);
527 if (val
&& strcmp(val
, "bt_value") == 0) {
528 pass("test_map_foreach_cb_check(): \"string2\" value object has the right value");
529 checklist
->string2
= BT_TRUE
;
531 fail("test_map_foreach_cb_check(): \"string2\" value object has the wrong value");
534 } else if (strcmp(key
, "array2") == 0) {
535 if (checklist
->array2
) {
536 fail("test_map_foreach_cb_check(): duplicate key \"array2\"");
538 ok(bt_value_is_array(object
), "test_map_foreach_cb_check(): success getting \"array2\" value object");
539 ok(bt_value_array_is_empty(object
),
540 "test_map_foreach_cb_check(): \"array2\" value object is empty");
541 checklist
->array2
= BT_TRUE
;
543 } else if (strcmp(key
, "array3") == 0) {
544 if (checklist
->array3
) {
545 fail("test_map_foreach_cb_check(): duplicate key \"array3\"");
547 ok(bt_value_is_array(object
), "test_map_foreach_cb_check(): success getting \"array3\" value object");
548 ok(bt_value_array_is_empty(object
),
549 "test_map_foreach_cb_check(): \"array3\" value object is empty");
550 checklist
->array3
= BT_TRUE
;
552 } else if (strcmp(key
, "map3") == 0) {
553 if (checklist
->map3
) {
554 fail("test_map_foreach_cb_check(): duplicate key \"map3\"");
556 ok(bt_value_is_map(object
), "test_map_foreach_cb_check(): success getting \"map3\" value object");
557 ok(bt_value_map_is_empty(object
),
558 "test_map_foreach_cb_check(): \"map3\" value object is empty");
559 checklist
->map3
= BT_TRUE
;
561 } else if (strcmp(key
, "map2") == 0) {
562 if (checklist
->map2
) {
563 fail("test_map_foreach_cb_check(): duplicate key \"map2\"");
565 ok(bt_value_is_map(object
), "test_map_foreach_cb_check(): success getting \"map2\" value object");
566 ok(bt_value_map_is_empty(object
),
567 "test_map_foreach_cb_check(): \"map2\" value object is empty");
568 checklist
->map2
= BT_TRUE
;
571 fail("test_map_foreach_cb_check(): unknown map key \"%s\"",
588 bt_value
*inserted_obj
;
589 struct map_foreach_checklist checklist
;
591 map_obj
= bt_value_map_create();
592 ok(map_obj
&& bt_value_is_map(map_obj
),
593 "bt_value_map_create() returns a map value object");
594 ok(bt_value_map_get_size(map_obj
) == 0,
595 "initial map value object size is 0");
597 obj
= bt_value_integer_unsigned_create_init(19457);
598 ret
= bt_value_map_insert_entry(map_obj
, "uint", obj
);
599 BT_VALUE_PUT_REF_AND_RESET(obj
);
600 obj
= bt_value_integer_signed_create_init(-12345);
601 ret
|= bt_value_map_insert_entry(map_obj
, "int", obj
);
602 BT_VALUE_PUT_REF_AND_RESET(obj
);
603 obj
= bt_value_real_create_init(5.444);
604 ret
|= bt_value_map_insert_entry(map_obj
, "real", obj
);
605 BT_VALUE_PUT_REF_AND_RESET(obj
);
606 obj
= bt_value_bool_create();
607 ret
|= bt_value_map_insert_entry(map_obj
, "bt_bool", obj
);
608 BT_VALUE_PUT_REF_AND_RESET(obj
);
609 ret
|= bt_value_map_insert_entry(map_obj
, "null",
611 ok(!ret
, "bt_value_map_insert_entry() succeeds");
612 ok(bt_value_map_get_size(map_obj
) == 5,
613 "inserting an element into a map value object increment its size");
615 obj
= bt_value_bool_create_init(BT_TRUE
);
616 ret
= bt_value_map_insert_entry(map_obj
, "bt_bool", obj
);
617 BT_VALUE_PUT_REF_AND_RESET(obj
);
618 ok(!ret
, "bt_value_map_insert_entry() accepts an existing key");
620 obj
= bt_value_map_borrow_entry_value(map_obj
, "life");
621 ok(!obj
, "bt_value_map_borrow_entry_value() returns NULL with an non existing key");
622 obj
= bt_value_map_borrow_entry_value(map_obj
, "real");
623 ok(obj
&& bt_value_is_real(obj
),
624 "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (real)");
625 real_value
= bt_value_real_get(obj
);
626 ok(real_value
== 5.444,
627 "bt_value_map_borrow_entry_value() returns an value object with the appropriate value (real)");
628 obj
= bt_value_map_borrow_entry_value(map_obj
, "uint");
629 ok(obj
&& bt_value_is_unsigned_integer(obj
),
630 "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (unsigned integer)");
631 int_value
= bt_value_integer_unsigned_get(obj
);
632 ok(int_value
== 19457,
633 "bt_value_map_borrow_entry_value() returns an value object with the appropriate value (unsigned integer)");
634 obj
= bt_value_map_borrow_entry_value(map_obj
, "int");
635 ok(obj
&& bt_value_is_signed_integer(obj
),
636 "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (signed integer)");
637 int_value
= bt_value_integer_signed_get(obj
);
638 ok(int_value
== -12345,
639 "bt_value_map_borrow_entry_value() returns an value object with the appropriate value (signed integer)");
640 obj
= bt_value_map_borrow_entry_value(map_obj
, "null");
641 ok(obj
&& bt_value_is_null(obj
),
642 "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (null)");
643 obj
= bt_value_map_borrow_entry_value(map_obj
, "bt_bool");
644 ok(obj
&& bt_value_is_bool(obj
),
645 "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (boolean)");
646 bool_value
= bt_value_bool_get(obj
);
648 "bt_value_map_borrow_entry_value() returns an value object with the appropriate value (boolean)");
650 ret
= bt_value_map_insert_bool_entry(map_obj
, "bool2",
652 ok(!ret
, "bt_value_map_insert_bool_entry() succeeds");
653 ret
= bt_value_map_insert_signed_integer_entry(map_obj
, "int2",
655 ok(!ret
, "bt_value_map_insert_signed_integer_entry() succeeds");
656 ret
= bt_value_map_insert_real_entry(map_obj
, "real2",
658 ok(!ret
, "bt_value_map_insert_real_entry() succeeds");
659 ret
= bt_value_map_insert_string_entry(map_obj
, "string2",
661 ok(!ret
, "bt_value_map_insert_string_entry() succeeds");
662 ret
= bt_value_map_insert_empty_array_entry(map_obj
, "array2", NULL
);
663 ok(!ret
, "bt_value_map_insert_empty_array_entry() succeeds");
664 ret
= bt_value_map_insert_empty_array_entry(map_obj
, "array3", &inserted_obj
);
665 ok(!ret
, "bt_value_map_insert_empty_array_entry() with returned value object succeeds");
667 "object returned by bt_value_map_insert_empty_array_entry() is not NULL");
668 ok(bt_value_is_array(inserted_obj
),
669 "object returned by bt_value_map_insert_empty_array_entry() is an array value");
670 ret
= bt_value_map_insert_empty_map_entry(map_obj
, "map2", NULL
);
671 ok(!ret
, "bt_value_map_insert_empty_map_entry() succeeds");
672 ret
= bt_value_map_insert_empty_map_entry(map_obj
, "map3", &inserted_obj
);
673 ok(!ret
, "bt_value_map_insert_empty_map_entry() with returned value object succeeds");
675 "object returned by bt_value_map_insert_empty_map_entry() is not NULL");
676 ok(bt_value_is_map(inserted_obj
),
677 "object returned by bt_value_map_insert_empty_map_entry() is an array value");
679 ok(bt_value_map_get_size(map_obj
) == 13,
680 "the bt_value_map_insert*() functions increment the map value object's size");
682 ok(!bt_value_map_has_entry(map_obj
, "hello"),
683 "map value object does not have key \"hello\"");
684 ok(bt_value_map_has_entry(map_obj
, "bt_bool"),
685 "map value object has key \"bt_bool\"");
686 ok(bt_value_map_has_entry(map_obj
, "uint"),
687 "map value object has key \"uint\"");
688 ok(bt_value_map_has_entry(map_obj
, "int"),
689 "map value object has key \"int\"");
690 ok(bt_value_map_has_entry(map_obj
, "real"),
691 "map value object has key \"real\"");
692 ok(bt_value_map_has_entry(map_obj
, "null"),
693 "map value object has key \"null\"");
694 ok(bt_value_map_has_entry(map_obj
, "bool2"),
695 "map value object has key \"bool2\"");
696 ok(bt_value_map_has_entry(map_obj
, "int2"),
697 "map value object has key \"int2\"");
698 ok(bt_value_map_has_entry(map_obj
, "real2"),
699 "map value object has key \"real2\"");
700 ok(bt_value_map_has_entry(map_obj
, "string2"),
701 "map value object has key \"string2\"");
702 ok(bt_value_map_has_entry(map_obj
, "array2"),
703 "map value object has key \"array2\"");
704 ok(bt_value_map_has_entry(map_obj
, "array3"),
705 "map value object has key \"array3\"");
706 ok(bt_value_map_has_entry(map_obj
, "map2"),
707 "map value object has key \"map2\"");
708 ok(bt_value_map_has_entry(map_obj
, "map3"),
709 "map value object has key \"map3\"");
711 ret
= bt_value_map_foreach_entry(map_obj
, test_map_foreach_cb_count
,
713 ok(ret
== BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED
&& count
== 3,
714 "bt_value_map_foreach_entry() breaks the loop when the user function returns BT_FALSE");
716 memset(&checklist
, 0, sizeof(checklist
));
717 ret
= bt_value_map_foreach_entry(map_obj
, test_map_foreach_cb_check
,
719 ok(ret
== BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK
,
720 "bt_value_map_foreach_entry() succeeds with test_map_foreach_cb_check()");
721 ok(checklist
.bool1
&& checklist
.uint
&& checklist
.int1
&&
722 checklist
.real1
&& checklist
.null1
&& checklist
.bool2
&&
723 checklist
.int2
&& checklist
.real2
&& checklist
.string2
&&
724 checklist
.array2
&& checklist
.map2
,
725 "bt_value_map_foreach_entry() iterates over all the map value object's elements");
727 BT_VALUE_PUT_REF_AND_RESET(map_obj
);
728 pass("putting an existing map value object does not cause a crash")
732 void test_types(void)
736 test_unsigned_integer();
737 test_signed_integer();
745 void test_compare_null(void)
747 ok(bt_value_compare(bt_value_null
, bt_value_null
),
748 "null value objects are equivalent");
752 void test_compare_bool(void)
755 bt_value_bool_create_init(BT_FALSE
);
757 bt_value_bool_create_init(BT_TRUE
);
759 bt_value_bool_create_init(BT_FALSE
);
761 BT_ASSERT(bool1
&& bool2
&& bool3
);
762 ok(!bt_value_compare(bt_value_null
,
764 "cannot compare null value object and bt_bool value object");
765 ok(!bt_value_compare(bool1
,
767 "boolean value objects are not equivalent (BT_FALSE and BT_TRUE)");
768 ok(bt_value_compare(bool1
,
770 "boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
772 BT_VALUE_PUT_REF_AND_RESET(bool1
);
773 BT_VALUE_PUT_REF_AND_RESET(bool2
);
774 BT_VALUE_PUT_REF_AND_RESET(bool3
);
778 void test_compare_unsigned_integer(void)
781 bt_value_integer_unsigned_create_init(10);
783 bt_value_integer_unsigned_create_init(23);
785 bt_value_integer_unsigned_create_init(10);
787 BT_ASSERT(int1
&& int2
&& int3
);
788 ok(!bt_value_compare(bt_value_null
,
790 "cannot compare null value object and unsigned integer value object");
791 ok(!bt_value_compare(int1
, int2
),
792 "unsigned integer value objects are not equivalent (10 and 23)");
793 ok(bt_value_compare(int1
, int3
),
794 "unsigned integer value objects are equivalent (10 and 10)");
796 BT_VALUE_PUT_REF_AND_RESET(int1
);
797 BT_VALUE_PUT_REF_AND_RESET(int2
);
798 BT_VALUE_PUT_REF_AND_RESET(int3
);
801 void test_compare_signed_integer(void)
804 bt_value_integer_signed_create_init(10);
806 bt_value_integer_signed_create_init(-23);
808 bt_value_integer_signed_create_init(10);
810 BT_ASSERT(int1
&& int2
&& int3
);
811 ok(!bt_value_compare(bt_value_null
,
813 "cannot compare null value object and signed integer value object");
814 ok(!bt_value_compare(int1
, int2
),
815 "signed integer value objects are not equivalent (10 and -23)");
816 ok(bt_value_compare(int1
, int3
),
817 "signed integer value objects are equivalent (10 and 10)");
819 BT_VALUE_PUT_REF_AND_RESET(int1
);
820 BT_VALUE_PUT_REF_AND_RESET(int2
);
821 BT_VALUE_PUT_REF_AND_RESET(int3
);
825 void test_compare_real(void)
828 bt_value_real_create_init(17.38);
830 bt_value_real_create_init(-14.23);
832 bt_value_real_create_init(17.38);
834 BT_ASSERT(real1
&& real2
&& real3
);
836 ok(!bt_value_compare(bt_value_null
,
838 "cannot compare null value object and real number value object");
839 ok(!bt_value_compare(real1
,
841 "real number value objects are not equivalent (17.38 and -14.23)");
842 ok(bt_value_compare(real1
,
844 "real number value objects are equivalent (17.38 and 17.38)");
846 BT_VALUE_PUT_REF_AND_RESET(real1
);
847 BT_VALUE_PUT_REF_AND_RESET(real2
);
848 BT_VALUE_PUT_REF_AND_RESET(real3
);
852 void test_compare_string(void)
855 bt_value_string_create_init("hello");
857 bt_value_string_create_init("bt_value");
859 bt_value_string_create_init("hello");
861 BT_ASSERT(string1
&& string2
&& string3
);
863 ok(!bt_value_compare(bt_value_null
,
865 "cannot compare null value object and string value object");
866 ok(!bt_value_compare(string1
,
868 "string value objects are not equivalent (\"hello\" and \"bt_value\")");
869 ok(bt_value_compare(string1
,
871 "string value objects are equivalent (\"hello\" and \"hello\")");
873 BT_VALUE_PUT_REF_AND_RESET(string1
);
874 BT_VALUE_PUT_REF_AND_RESET(string2
);
875 BT_VALUE_PUT_REF_AND_RESET(string3
);
879 void test_compare_array(void)
881 bt_value
*array1
= bt_value_array_create();
882 bt_value
*array2
= bt_value_array_create();
883 bt_value
*array3
= bt_value_array_create();
884 bt_value_array_append_element_status append_status
;
886 BT_ASSERT(array1
&& array2
&& array3
);
888 ok(bt_value_compare(array1
, array2
),
889 "empty array value objects are equivalent");
891 append_status
= bt_value_array_append_signed_integer_element(array1
, 23);
892 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
893 append_status
= bt_value_array_append_real_element(array1
, 14.2);
894 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
895 append_status
= bt_value_array_append_bool_element(array1
, BT_FALSE
);
896 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
897 append_status
= bt_value_array_append_real_element(array2
, 14.2);
898 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
899 append_status
= bt_value_array_append_signed_integer_element(array2
, 23);
900 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
901 append_status
= bt_value_array_append_bool_element(array2
, BT_FALSE
);
902 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
903 append_status
= bt_value_array_append_signed_integer_element(array3
, 23);
904 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
905 append_status
= bt_value_array_append_real_element(array3
, 14.2);
906 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
907 append_status
= bt_value_array_append_bool_element(array3
, BT_FALSE
);
908 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
909 BT_ASSERT(bt_value_array_get_length(array1
) == 3);
910 BT_ASSERT(bt_value_array_get_length(array2
) == 3);
911 BT_ASSERT(bt_value_array_get_length(array3
) == 3);
913 ok(!bt_value_compare(bt_value_null
,
915 "cannot compare null value object and array value object");
916 ok(!bt_value_compare(array1
,
918 "array value objects are not equivalent ([23, 14.2, BT_FALSE] and [14.2, 23, BT_FALSE])");
919 ok(bt_value_compare(array1
,
921 "array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
923 BT_VALUE_PUT_REF_AND_RESET(array1
);
924 BT_VALUE_PUT_REF_AND_RESET(array2
);
925 BT_VALUE_PUT_REF_AND_RESET(array3
);
929 void test_compare_map(void)
931 bt_value
*map1
= bt_value_map_create();
932 bt_value
*map2
= bt_value_map_create();
933 bt_value
*map3
= bt_value_map_create();
934 bt_value_map_insert_entry_status insert_status
;
936 BT_ASSERT(map1
&& map2
&& map3
);
938 ok(bt_value_compare(map1
,
940 "empty map value objects are equivalent");
943 insert_status
= bt_value_map_insert_signed_integer_entry(map1
, "one", 23);
944 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
945 insert_status
= bt_value_map_insert_real_entry(map1
, "two", 14.2);
946 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
947 insert_status
= bt_value_map_insert_bool_entry(map1
, "three",
949 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
950 insert_status
= bt_value_map_insert_real_entry(map2
, "one", 14.2);
951 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
952 insert_status
= bt_value_map_insert_signed_integer_entry(map2
, "two", 23);
953 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
954 insert_status
= bt_value_map_insert_bool_entry(map2
, "three",
956 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
957 insert_status
= bt_value_map_insert_bool_entry(map3
, "three",
959 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
960 insert_status
= bt_value_map_insert_signed_integer_entry(map3
, "one", 23);
961 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
962 insert_status
= bt_value_map_insert_real_entry(map3
, "two", 14.2);
963 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
964 BT_ASSERT(bt_value_map_get_size(map1
) == 3);
965 BT_ASSERT(bt_value_map_get_size(map2
) == 3);
966 BT_ASSERT(bt_value_map_get_size(map3
) == 3);
968 ok(!bt_value_compare(bt_value_null
,
970 "cannot compare null value object and map value object");
971 ok(!bt_value_compare(map1
,
973 "map value objects are not equivalent");
974 ok(bt_value_compare(map1
,
976 "map value objects are equivalent");
978 BT_VALUE_PUT_REF_AND_RESET(map1
);
979 BT_VALUE_PUT_REF_AND_RESET(map2
);
980 BT_VALUE_PUT_REF_AND_RESET(map3
);
984 void test_compare(void)
988 test_compare_unsigned_integer();
989 test_compare_signed_integer();
991 test_compare_string();
992 test_compare_array();
1000 * Here's the deal here. If we make sure that each value object
1001 * of our deep copy has a different address than its source, and
1002 * that bt_value_compare() returns BT_TRUE for the top-level
1003 * value object, taking into account that we test the
1004 * correctness of bt_value_compare() elsewhere, then the deep
1005 * copy is a success.
1007 bt_value
*null_copy_obj
;
1008 bt_value
*bool_obj
, *bool_copy_obj
;
1009 bt_value
*unsigned_integer_obj
, *unsigned_integer_copy_obj
;
1010 bt_value
*signed_integer_obj
, *signed_integer_copy_obj
;
1011 bt_value
*real_obj
, *real_copy_obj
;
1012 bt_value
*string_obj
, *string_copy_obj
;
1013 bt_value
*array_obj
, *array_copy_obj
;
1014 bt_value
*map_obj
, *map_copy_obj
;
1015 bt_value_array_append_element_status append_status
;
1016 bt_value_map_insert_entry_status insert_status
;
1017 bt_value_copy_status copy_status
;
1019 bool_obj
= bt_value_bool_create_init(BT_TRUE
);
1020 unsigned_integer_obj
= bt_value_integer_unsigned_create_init(23);
1021 signed_integer_obj
= bt_value_integer_signed_create_init(-47);
1022 real_obj
= bt_value_real_create_init(-3.1416);
1023 string_obj
= bt_value_string_create_init("test");
1024 array_obj
= bt_value_array_create();
1025 map_obj
= bt_value_map_create();
1027 BT_ASSERT(bool_obj
&& unsigned_integer_obj
&& signed_integer_obj
&&
1028 real_obj
&& string_obj
&& array_obj
&& map_obj
);
1030 append_status
= bt_value_array_append_element(array_obj
, bool_obj
);
1031 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
1032 append_status
= bt_value_array_append_element(array_obj
, unsigned_integer_obj
);
1033 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
1034 append_status
= bt_value_array_append_element(array_obj
, signed_integer_obj
);
1035 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
1036 append_status
= bt_value_array_append_element(array_obj
, real_obj
);
1037 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
1038 append_status
= bt_value_array_append_element(array_obj
, bt_value_null
);
1039 BT_ASSERT(append_status
== BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK
);
1040 insert_status
= bt_value_map_insert_entry(map_obj
, "array", array_obj
);
1041 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1042 insert_status
= bt_value_map_insert_entry(map_obj
, "string", string_obj
);
1043 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1045 copy_status
= bt_value_copy(map_obj
, &map_copy_obj
);
1046 ok(copy_status
== BT_VALUE_COPY_STATUS_OK
&& map_copy_obj
,
1047 "bt_value_copy() succeeds");
1049 ok(map_obj
!= map_copy_obj
,
1050 "bt_value_copy() returns a different pointer (map)");
1051 string_copy_obj
= bt_value_map_borrow_entry_value(map_copy_obj
,
1053 ok(string_copy_obj
!= string_obj
,
1054 "bt_value_copy() returns a different pointer (string)");
1055 array_copy_obj
= bt_value_map_borrow_entry_value(map_copy_obj
,
1057 ok(array_copy_obj
!= array_obj
,
1058 "bt_value_copy() returns a different pointer (array)");
1059 bool_copy_obj
= bt_value_array_borrow_element_by_index(
1061 ok(bool_copy_obj
!= bool_obj
,
1062 "bt_value_copy() returns a different pointer (bool)");
1063 unsigned_integer_copy_obj
= bt_value_array_borrow_element_by_index(
1065 ok(unsigned_integer_copy_obj
!= unsigned_integer_obj
,
1066 "bt_value_copy() returns a different pointer (unsigned integer)");
1067 signed_integer_copy_obj
= bt_value_array_borrow_element_by_index(
1069 ok(signed_integer_copy_obj
!= signed_integer_obj
,
1070 "bt_value_copy() returns a different pointer (signed integer)");
1071 real_copy_obj
= bt_value_array_borrow_element_by_index(
1073 ok(real_copy_obj
!= real_obj
,
1074 "bt_value_copy() returns a different pointer (real)");
1075 null_copy_obj
= bt_value_array_borrow_element_by_index(
1077 ok(null_copy_obj
== bt_value_null
,
1078 "bt_value_copy() returns the same pointer (null)");
1080 ok(bt_value_compare(map_obj
, map_copy_obj
),
1081 "source and destination value objects have the same content");
1083 BT_VALUE_PUT_REF_AND_RESET(map_copy_obj
);
1084 BT_VALUE_PUT_REF_AND_RESET(bool_obj
);
1085 BT_VALUE_PUT_REF_AND_RESET(unsigned_integer_obj
);
1086 BT_VALUE_PUT_REF_AND_RESET(signed_integer_obj
);
1087 BT_VALUE_PUT_REF_AND_RESET(real_obj
);
1088 BT_VALUE_PUT_REF_AND_RESET(string_obj
);
1089 BT_VALUE_PUT_REF_AND_RESET(array_obj
);
1090 BT_VALUE_PUT_REF_AND_RESET(map_obj
);
1094 bt_bool
compare_map_elements(const bt_value
*map_a
, const bt_value
*map_b
,
1097 const bt_value
*elem_a
= NULL
;
1098 const bt_value
*elem_b
= NULL
;
1101 elem_a
= bt_value_map_borrow_entry_value_const(map_a
, key
);
1102 elem_b
= bt_value_map_borrow_entry_value_const(map_b
, key
);
1103 equal
= bt_value_compare(elem_a
, elem_b
);
1108 void test_extend(void)
1110 bt_value
*base_map
= bt_value_map_create();
1111 bt_value
*extension_map
= bt_value_map_create();
1112 bt_value
*extended_map
= NULL
;
1113 bt_value
*array
= bt_value_array_create();
1114 bt_value_map_insert_entry_status insert_status
;
1115 bt_value_map_extend_status extend_status
;
1117 BT_ASSERT(base_map
);
1118 BT_ASSERT(extension_map
);
1120 insert_status
= bt_value_map_insert_bool_entry(base_map
, "file",
1122 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1123 insert_status
= bt_value_map_insert_bool_entry(base_map
, "edit",
1125 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1126 insert_status
= bt_value_map_insert_signed_integer_entry(base_map
,
1128 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1129 insert_status
= bt_value_map_insert_signed_integer_entry(base_map
, "find",
1131 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1132 insert_status
= bt_value_map_insert_bool_entry(extension_map
, "edit",
1134 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1135 insert_status
= bt_value_map_insert_signed_integer_entry(extension_map
,
1137 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1138 insert_status
= bt_value_map_insert_real_entry(extension_map
,
1140 BT_ASSERT(insert_status
== BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK
);
1141 extend_status
= bt_value_map_extend(base_map
, extension_map
, &extended_map
);
1142 ok(extend_status
== BT_VALUE_MAP_EXTEND_STATUS_OK
&&
1143 extended_map
, "bt_value_map_extend() succeeds");
1144 ok(bt_value_map_get_size(extended_map
) == 5,
1145 "bt_value_map_extend() returns a map object with the correct size");
1146 ok(compare_map_elements(base_map
,
1147 extended_map
, "file"),
1148 "bt_value_map_extend() picks the appropriate element (file)");
1149 ok(compare_map_elements(extension_map
,
1150 extended_map
, "edit"),
1151 "bt_value_map_extend() picks the appropriate element (edit)");
1152 ok(compare_map_elements(base_map
,
1153 extended_map
, "selection"),
1154 "bt_value_map_extend() picks the appropriate element (selection)");
1155 ok(compare_map_elements(extension_map
,
1156 extended_map
, "find"),
1157 "bt_value_map_extend() picks the appropriate element (find)");
1158 ok(compare_map_elements(extension_map
,
1159 extended_map
, "project"),
1160 "bt_value_map_extend() picks the appropriate element (project)");
1162 BT_VALUE_PUT_REF_AND_RESET(array
);
1163 BT_VALUE_PUT_REF_AND_RESET(base_map
);
1164 BT_VALUE_PUT_REF_AND_RESET(extension_map
);
1165 BT_VALUE_PUT_REF_AND_RESET(extended_map
);
1170 plan_tests(NR_TESTS
);