From: Philippe Proulx Date: Thu, 19 Mar 2015 18:12:04 +0000 (-0400) Subject: objects tests: bt_object_array_set() X-Git-Tag: v2.0.0-pre1~1303 X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=5a5029c6ef4f3c425e5ebe9e50f945462bf0c244;p=babeltrace.git objects tests: bt_object_array_set() Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/tests/lib/test_bt_objects.c b/tests/lib/test_bt_objects.c index 684194e2..1589057d 100644 --- a/tests/lib/test_bt_objects.c +++ b/tests/lib/test_bt_objects.c @@ -276,6 +276,26 @@ void test_array(void) ok(obj == bt_object_null, "bt_object_array_get() returns an object with the appropriate type (null)"); + ok(bt_object_array_set(NULL, 0, bt_object_null), + "bt_object_array_set() fails with an array object set to NULL"); + ok(bt_object_array_set(array_obj, 0, NULL), + "bt_object_array_set() fails with an element object set to NULL"); + ok(bt_object_array_set(array_obj, 4, bt_object_null), + "bt_object_array_set() fails with an invalid index"); + obj = bt_object_integer_create_init(1001); + assert(obj); + ok(!bt_object_array_set(array_obj, 2, obj), + "bt_object_array_set() succeeds"); + BT_OBJECT_PUT(obj); + obj = bt_object_array_get(array_obj, 2); + ok(obj && bt_object_is_integer(obj), + "bt_object_array_set() inserts an object with the appropriate type"); + ret = bt_object_integer_get(obj, &int_value); + assert(!ret); + ok(int_value == 1001, + "bt_object_array_set() inserts an object with the appropriate value"); + BT_OBJECT_PUT(obj); + ret = bt_object_array_append_bool(array_obj, false); ok(!ret, "bt_object_array_append_bool() succeeds"); ret = bt_object_array_append_bool(NULL, true);