* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values.h>
#include <babeltrace/assert-internal.h>
#include <string.h>
ok(bt_value_null, "bt_value_null is not NULL");
ok(bt_value_is_null(bt_value_null),
"bt_value_null is a null value object");
- bt_get(bt_value_null);
+ bt_object_get_ref(bt_value_null);
pass("getting bt_value_null does not cause a crash");
- bt_put(bt_value_null);
+ bt_object_put_ref(bt_value_null);
pass("putting bt_value_null does not cause a crash");
}
ret = bt_value_bool_get(obj, &value);
ok(!ret && value, "bt_value_bool_set() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing boolean value object does not cause a crash")
value = BT_FALSE;
ok(!ret && value,
"bt_value_bool_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
ret = bt_value_integer_get(obj, &value);
ok(!ret && value == -98765, "bt_value_integer_set() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing integer value object does not cause a crash")
obj = bt_value_integer_create_init(321456987);
ok(!ret && value == 321456987,
"bt_value_integer_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
ret = bt_value_real_get(obj, &value);
ok(!ret && value == -3.1416, "bt_value_real_set() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing real number value object does not cause a crash")
obj = bt_value_real_create_init(33.1649758);
ok(!ret && value == 33.1649758,
"bt_value_real_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
ok(!ret && value && !strcmp(value, "hello worldz"),
"bt_value_string_get() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing string value object does not cause a crash")
obj = bt_value_string_create_init("initial value");
ok(!ret && value && !strcmp(value, "initial value"),
"bt_value_string_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
obj = bt_value_integer_create_init(345);
ret = bt_value_array_append_element(array_obj, obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_real_create_init(-17.45);
ret |= bt_value_array_append_element(array_obj, obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_bool_create_init(BT_TRUE);
ret |= bt_value_array_append_element(array_obj, obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ret |= bt_value_array_append_element(array_obj, bt_value_null);
ok(!ret, "bt_value_array_append_element() succeeds");
ok(bt_value_array_get_size(array_obj) == 4,
BT_ASSERT(obj);
ok(!bt_value_array_set_element_by_index(array_obj, 2, obj),
"bt_value_array_set_element_by_index() succeeds");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_array_borrow_element_by_index(array_obj, 2);
ok(obj && bt_value_is_integer(obj),
"bt_value_array_set_element_by_index() inserts an value object with the appropriate type");
ok(bt_value_map_is_empty(obj),
"bt_value_array_append_empty_map_element() an empty map value object");
- BT_PUT(array_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(array_obj);
pass("putting an existing array value object does not cause a crash")
}
obj = bt_value_integer_create_init(19457);
ret = bt_value_map_insert_entry(map_obj, "int", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_real_create_init(5.444);
ret |= bt_value_map_insert_entry(map_obj, "real", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_bool_create();
ret |= bt_value_map_insert_entry(map_obj, "bt_bool", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ret |= bt_value_map_insert_entry(map_obj, "null", bt_value_null);
ok(!ret, "bt_value_map_insert_entry() succeeds");
ok(bt_value_map_get_size(map_obj) == 4,
obj = bt_value_bool_create_init(BT_TRUE);
ret = bt_value_map_insert_entry(map_obj, "bt_bool", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ok(!ret, "bt_value_map_insert_entry() accepts an existing key");
obj = bt_value_map_borrow_entry_value(map_obj, "life");
checklist.array2 && checklist.map2,
"bt_value_map_foreach_entry() iterates over all the map value object's elements");
- BT_PUT(map_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_obj);
pass("putting an existing map value object does not cause a crash")
}
ok(bt_value_compare(bool1, bool3),
"boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
- BT_PUT(bool1);
- BT_PUT(bool2);
- BT_PUT(bool3);
+ BT_OBJECT_PUT_REF_AND_RESET(bool1);
+ BT_OBJECT_PUT_REF_AND_RESET(bool2);
+ BT_OBJECT_PUT_REF_AND_RESET(bool3);
}
static
ok(bt_value_compare(int1, int3),
"integer value objects are equivalent (10 and 10)");
- BT_PUT(int1);
- BT_PUT(int2);
- BT_PUT(int3);
+ BT_OBJECT_PUT_REF_AND_RESET(int1);
+ BT_OBJECT_PUT_REF_AND_RESET(int2);
+ BT_OBJECT_PUT_REF_AND_RESET(int3);
}
static
ok(bt_value_compare(real1, real3),
"real number value objects are equivalent (17.38 and 17.38)");
- BT_PUT(real1);
- BT_PUT(real2);
- BT_PUT(real3);
+ BT_OBJECT_PUT_REF_AND_RESET(real1);
+ BT_OBJECT_PUT_REF_AND_RESET(real2);
+ BT_OBJECT_PUT_REF_AND_RESET(real3);
}
static
ok(bt_value_compare(string1, string3),
"string value objects are equivalent (\"hello\" and \"hello\")");
- BT_PUT(string1);
- BT_PUT(string2);
- BT_PUT(string3);
+ BT_OBJECT_PUT_REF_AND_RESET(string1);
+ BT_OBJECT_PUT_REF_AND_RESET(string2);
+ BT_OBJECT_PUT_REF_AND_RESET(string3);
}
static
ok(bt_value_compare(array1, array3),
"array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
- BT_PUT(array1);
- BT_PUT(array2);
- BT_PUT(array3);
+ BT_OBJECT_PUT_REF_AND_RESET(array1);
+ BT_OBJECT_PUT_REF_AND_RESET(array2);
+ BT_OBJECT_PUT_REF_AND_RESET(array3);
}
static
ok(bt_value_compare(map1, map3),
"map value objects are equivalent");
- BT_PUT(map1);
- BT_PUT(map2);
- BT_PUT(map3);
+ BT_OBJECT_PUT_REF_AND_RESET(map1);
+ BT_OBJECT_PUT_REF_AND_RESET(map2);
+ BT_OBJECT_PUT_REF_AND_RESET(map3);
}
static
ok(bt_value_compare(map_obj, map_copy_obj),
"source and destination value objects have the same content");
- BT_PUT(map_copy_obj);
- BT_PUT(bool_obj);
- BT_PUT(integer_obj);
- BT_PUT(real_obj);
- BT_PUT(string_obj);
- BT_PUT(array_obj);
- BT_PUT(map_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(bool_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(integer_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(real_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(string_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(array_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_obj);
}
static
ok(compare_map_elements(extension_map, extended_map, "project"),
"bt_value_map_extend() picks the appropriate element (project)");
- BT_PUT(array);
- BT_PUT(base_map);
- BT_PUT(extension_map);
- BT_PUT(extended_map);
+ BT_OBJECT_PUT_REF_AND_RESET(array);
+ BT_OBJECT_PUT_REF_AND_RESET(base_map);
+ BT_OBJECT_PUT_REF_AND_RESET(extension_map);
+ BT_OBJECT_PUT_REF_AND_RESET(extended_map);
}
int main(void)