lib: add aliases for Babeltrace structure types
[babeltrace.git] / tests / lib / test_bt_values.c
index 9b9cd3a4a72649c471cad41b3042014144423545..0bc1b1095147086a176bf41ce20375c376a8aeef 100644 (file)
@@ -33,9 +33,9 @@ void test_null(void)
        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_object_get_ref(bt_value_null);
+       bt_value_get_ref(bt_value_null);
        pass("getting bt_value_null does not cause a crash");
-       bt_object_put_ref(bt_value_null);
+       bt_value_put_ref(bt_value_null);
        pass("putting bt_value_null does not cause a crash");
 }
 
@@ -43,7 +43,7 @@ static
 void test_bool(void)
 {
        bt_bool value;
-       struct bt_value *obj;
+       bt_value *obj;
 
        obj = bt_value_bool_create();
        ok(obj && bt_value_is_bool(obj),
@@ -58,7 +58,7 @@ void test_bool(void)
        value = bt_value_bool_get(obj);
        ok(value, "bt_value_bool_set() works");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        pass("putting an existing boolean value object does not cause a crash")
 
        value = BT_FALSE;
@@ -69,14 +69,14 @@ void test_bool(void)
        ok(value,
                "bt_value_bool_create_init() sets the appropriate initial value");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
 }
 
 static
 void test_integer(void)
 {
        int64_t value;
-       struct bt_value *obj;
+       bt_value *obj;
 
        obj = bt_value_integer_create();
        ok(obj && bt_value_is_integer(obj),
@@ -90,7 +90,7 @@ void test_integer(void)
        value = bt_value_integer_get(obj);
        ok(value == -98765, "bt_private_integer_bool_set() works");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        pass("putting an existing integer value object does not cause a crash")
 
        obj = bt_value_integer_create_init(321456987);
@@ -100,14 +100,14 @@ void test_integer(void)
        ok(value == 321456987,
                "bt_value_integer_create_init() sets the appropriate initial value");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
 }
 
 static
 void test_real(void)
 {
        double value;
-       struct bt_value *obj;
+       bt_value *obj;
 
        obj = bt_value_real_create();
        ok(obj && bt_value_is_real(obj),
@@ -122,7 +122,7 @@ void test_real(void)
        value = bt_value_real_get(obj);
        ok(value == -3.1416, "bt_value_real_set() works");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_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);
@@ -132,14 +132,14 @@ void test_real(void)
        ok(value == 33.1649758,
                "bt_value_real_create_init() sets the appropriate initial value");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
 }
 
 static
 void test_string(void)
 {
        const char *value;
-       struct bt_value *obj;
+       bt_value *obj;
 
        obj = bt_value_string_create();
        ok(obj && bt_value_is_string(obj),
@@ -154,7 +154,7 @@ void test_string(void)
        ok(value && !strcmp(value, "hello worldz"),
                "bt_value_string_get() works");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_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");
@@ -164,7 +164,7 @@ void test_string(void)
        ok(value && !strcmp(value, "initial value"),
                "bt_value_string_create_init() sets the appropriate initial value");
 
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
 }
 
 static
@@ -174,9 +174,9 @@ void test_array(void)
        bt_bool bool_value;
        int64_t int_value;
        double real_value;
-       struct bt_value *obj;
+       bt_value *obj;
        const char *string_value;
-       struct bt_value *array_obj;
+       bt_value *array_obj;
 
        array_obj = bt_value_array_create();
        ok(array_obj && bt_value_is_array(array_obj),
@@ -186,13 +186,13 @@ void test_array(void)
 
        obj = bt_value_integer_create_init(345);
        ret = bt_value_array_append_element(array_obj, obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        obj = bt_value_real_create_init(-17.45);
        ret |= bt_value_array_append_element(array_obj, obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        obj = bt_value_bool_create_init(BT_TRUE);
        ret |= bt_value_array_append_element(array_obj, obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        ret |= bt_value_array_append_element(array_obj,
                bt_value_null);
        ok(!ret, "bt_value_array_append_element() succeeds");
@@ -225,7 +225,7 @@ void test_array(void)
        BT_ASSERT(obj);
        ok(!bt_value_array_set_element_by_index(array_obj, 2, obj),
                "bt_value_array_set_element_by_index() succeeds");
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_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");
@@ -291,12 +291,12 @@ void test_array(void)
        ok(bt_value_map_is_empty(obj),
                "bt_value_array_append_empty_map_element() an empty map value object");
 
-       BT_OBJECT_PUT_REF_AND_RESET(array_obj);
+       BT_VALUE_PUT_REF_AND_RESET(array_obj);
        pass("putting an existing array value object does not cause a crash")
 }
 
 static
-bt_bool test_map_foreach_cb_count(const char *key, struct bt_value *object,
+bt_bool test_map_foreach_cb_count(const char *key, bt_value *object,
        void *data)
 {
        int *count = data;
@@ -324,7 +324,7 @@ struct map_foreach_checklist {
 };
 
 static
-bt_bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
+bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
        void *data)
 {
        struct map_foreach_checklist *checklist = data;
@@ -475,8 +475,8 @@ void test_map(void)
        bt_bool bool_value;
        int64_t int_value;
        double real_value;
-       struct bt_value *obj;
-       struct bt_value *map_obj;
+       bt_value *obj;
+       bt_value *map_obj;
        struct map_foreach_checklist checklist;
 
        map_obj = bt_value_map_create();
@@ -487,13 +487,13 @@ void test_map(void)
 
        obj = bt_value_integer_create_init(19457);
        ret = bt_value_map_insert_entry(map_obj, "int", obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        obj = bt_value_real_create_init(5.444);
        ret |= bt_value_map_insert_entry(map_obj, "real", obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_PUT_REF_AND_RESET(obj);
        obj = bt_value_bool_create();
        ret |= bt_value_map_insert_entry(map_obj, "bt_bool", obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_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");
@@ -502,7 +502,7 @@ void test_map(void)
 
        obj = bt_value_bool_create_init(BT_TRUE);
        ret = bt_value_map_insert_entry(map_obj, "bt_bool", obj);
-       BT_OBJECT_PUT_REF_AND_RESET(obj);
+       BT_VALUE_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");
@@ -589,7 +589,7 @@ void test_map(void)
                checklist.array2 && checklist.map2,
                "bt_value_map_foreach_entry() iterates over all the map value object's elements");
 
-       BT_OBJECT_PUT_REF_AND_RESET(map_obj);
+       BT_VALUE_PUT_REF_AND_RESET(map_obj);
        pass("putting an existing map value object does not cause a crash")
 }
 
@@ -615,11 +615,11 @@ void test_compare_null(void)
 static
 void test_compare_bool(void)
 {
-       struct bt_value *bool1 =
+       bt_value *bool1 =
                bt_value_bool_create_init(BT_FALSE);
-       struct bt_value *bool2 =
+       bt_value *bool2 =
                bt_value_bool_create_init(BT_TRUE);
-       struct bt_value *bool3 =
+       bt_value *bool3 =
                bt_value_bool_create_init(BT_FALSE);
 
        BT_ASSERT(bool1 && bool2 && bool3);
@@ -633,19 +633,19 @@ void test_compare_bool(void)
                            bool3),
                "boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
 
-       BT_OBJECT_PUT_REF_AND_RESET(bool1);
-       BT_OBJECT_PUT_REF_AND_RESET(bool2);
-       BT_OBJECT_PUT_REF_AND_RESET(bool3);
+       BT_VALUE_PUT_REF_AND_RESET(bool1);
+       BT_VALUE_PUT_REF_AND_RESET(bool2);
+       BT_VALUE_PUT_REF_AND_RESET(bool3);
 }
 
 static
 void test_compare_integer(void)
 {
-       struct bt_value *int1 =
+       bt_value *int1 =
                bt_value_integer_create_init(10);
-       struct bt_value *int2 =
+       bt_value *int2 =
                bt_value_integer_create_init(-23);
-       struct bt_value *int3 =
+       bt_value *int3 =
                bt_value_integer_create_init(10);
 
        BT_ASSERT(int1 && int2 && int3);
@@ -659,19 +659,19 @@ void test_compare_integer(void)
                            int3),
                "integer value objects are equivalent (10 and 10)");
 
-       BT_OBJECT_PUT_REF_AND_RESET(int1);
-       BT_OBJECT_PUT_REF_AND_RESET(int2);
-       BT_OBJECT_PUT_REF_AND_RESET(int3);
+       BT_VALUE_PUT_REF_AND_RESET(int1);
+       BT_VALUE_PUT_REF_AND_RESET(int2);
+       BT_VALUE_PUT_REF_AND_RESET(int3);
 }
 
 static
 void test_compare_real(void)
 {
-       struct bt_value *real1 =
+       bt_value *real1 =
                bt_value_real_create_init(17.38);
-       struct bt_value *real2 =
+       bt_value *real2 =
                bt_value_real_create_init(-14.23);
-       struct bt_value *real3 =
+       bt_value *real3 =
                bt_value_real_create_init(17.38);
 
        BT_ASSERT(real1 && real2 && real3);
@@ -686,19 +686,19 @@ void test_compare_real(void)
                            real3),
                "real number value objects are equivalent (17.38 and 17.38)");
 
-       BT_OBJECT_PUT_REF_AND_RESET(real1);
-       BT_OBJECT_PUT_REF_AND_RESET(real2);
-       BT_OBJECT_PUT_REF_AND_RESET(real3);
+       BT_VALUE_PUT_REF_AND_RESET(real1);
+       BT_VALUE_PUT_REF_AND_RESET(real2);
+       BT_VALUE_PUT_REF_AND_RESET(real3);
 }
 
 static
 void test_compare_string(void)
 {
-       struct bt_value *string1 =
+       bt_value *string1 =
                bt_value_string_create_init("hello");
-       struct bt_value *string2 =
+       bt_value *string2 =
                bt_value_string_create_init("bt_value");
-       struct bt_value *string3 =
+       bt_value *string3 =
                bt_value_string_create_init("hello");
 
        BT_ASSERT(string1 && string2 && string3);
@@ -713,17 +713,17 @@ void test_compare_string(void)
                            string3),
                "string value objects are equivalent (\"hello\" and \"hello\")");
 
-       BT_OBJECT_PUT_REF_AND_RESET(string1);
-       BT_OBJECT_PUT_REF_AND_RESET(string2);
-       BT_OBJECT_PUT_REF_AND_RESET(string3);
+       BT_VALUE_PUT_REF_AND_RESET(string1);
+       BT_VALUE_PUT_REF_AND_RESET(string2);
+       BT_VALUE_PUT_REF_AND_RESET(string3);
 }
 
 static
 void test_compare_array(void)
 {
-       struct bt_value *array1 = bt_value_array_create();
-       struct bt_value *array2 = bt_value_array_create();
-       struct bt_value *array3 = bt_value_array_create();
+       bt_value *array1 = bt_value_array_create();
+       bt_value *array2 = bt_value_array_create();
+       bt_value *array3 = bt_value_array_create();
        enum bt_value_status status;
 
        BT_ASSERT(array1 && array2 && array3);
@@ -764,17 +764,17 @@ void test_compare_array(void)
                            array3),
                "array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
 
-       BT_OBJECT_PUT_REF_AND_RESET(array1);
-       BT_OBJECT_PUT_REF_AND_RESET(array2);
-       BT_OBJECT_PUT_REF_AND_RESET(array3);
+       BT_VALUE_PUT_REF_AND_RESET(array1);
+       BT_VALUE_PUT_REF_AND_RESET(array2);
+       BT_VALUE_PUT_REF_AND_RESET(array3);
 }
 
 static
 void test_compare_map(void)
 {
-       struct bt_value *map1 = bt_value_map_create();
-       struct bt_value *map2 = bt_value_map_create();
-       struct bt_value *map3 = bt_value_map_create();
+       bt_value *map1 = bt_value_map_create();
+       bt_value *map2 = bt_value_map_create();
+       bt_value *map3 = bt_value_map_create();
        enum bt_value_status status;
 
        BT_ASSERT(map1 && map2 && map3);
@@ -819,9 +819,9 @@ void test_compare_map(void)
                            map3),
                "map value objects are equivalent");
 
-       BT_OBJECT_PUT_REF_AND_RESET(map1);
-       BT_OBJECT_PUT_REF_AND_RESET(map2);
-       BT_OBJECT_PUT_REF_AND_RESET(map3);
+       BT_VALUE_PUT_REF_AND_RESET(map1);
+       BT_VALUE_PUT_REF_AND_RESET(map2);
+       BT_VALUE_PUT_REF_AND_RESET(map3);
 }
 
 static
@@ -847,13 +847,13 @@ void test_copy(void)
         * bt_value_compare() elsewhere, then the deep copy is a
         * success.
         */
-       struct bt_value *null_copy_obj;
-       struct bt_value *bool_obj, *bool_copy_obj;
-       struct bt_value *integer_obj, *integer_copy_obj;
-       struct bt_value *real_obj, *real_copy_obj;
-       struct bt_value *string_obj, *string_copy_obj;
-       struct bt_value *array_obj, *array_copy_obj;
-       struct bt_value *map_obj, *map_copy_obj;
+       bt_value *null_copy_obj;
+       bt_value *bool_obj, *bool_copy_obj;
+       bt_value *integer_obj, *integer_copy_obj;
+       bt_value *real_obj, *real_copy_obj;
+       bt_value *string_obj, *string_copy_obj;
+       bt_value *array_obj, *array_copy_obj;
+       bt_value *map_obj, *map_copy_obj;
        enum bt_value_status status;
 
        bool_obj = bt_value_bool_create_init(BT_TRUE);
@@ -920,21 +920,21 @@ void test_copy(void)
                            map_copy_obj),
                "source and destination value objects have the same content");
 
-       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);
+       BT_VALUE_PUT_REF_AND_RESET(map_copy_obj);
+       BT_VALUE_PUT_REF_AND_RESET(bool_obj);
+       BT_VALUE_PUT_REF_AND_RESET(integer_obj);
+       BT_VALUE_PUT_REF_AND_RESET(real_obj);
+       BT_VALUE_PUT_REF_AND_RESET(string_obj);
+       BT_VALUE_PUT_REF_AND_RESET(array_obj);
+       BT_VALUE_PUT_REF_AND_RESET(map_obj);
 }
 
 static
-bt_bool compare_map_elements(const struct bt_value *map_a, const struct bt_value *map_b,
+bt_bool compare_map_elements(const bt_value *map_a, const bt_value *map_b,
                const char *key)
 {
-       const struct bt_value *elem_a = NULL;
-       const struct bt_value *elem_b = NULL;
+       const bt_value *elem_a = NULL;
+       const bt_value *elem_b = NULL;
        bt_bool equal;
 
        elem_a = bt_value_map_borrow_entry_value_const(map_a, key);
@@ -946,10 +946,10 @@ bt_bool compare_map_elements(const struct bt_value *map_a, const struct bt_value
 static
 void test_extend(void)
 {
-       struct bt_value *base_map = bt_value_map_create();
-       struct bt_value *extension_map = bt_value_map_create();
-       struct bt_value *extended_map = NULL;
-       struct bt_value *array = bt_value_array_create();
+       bt_value *base_map = bt_value_map_create();
+       bt_value *extension_map = bt_value_map_create();
+       bt_value *extended_map = NULL;
+       bt_value *array = bt_value_array_create();
        enum bt_value_status status;
 
        BT_ASSERT(base_map);
@@ -997,10 +997,10 @@ void test_extend(void)
                                extended_map, "project"),
                "bt_value_map_extend() picks the appropriate element (project)");
 
-       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);
+       BT_VALUE_PUT_REF_AND_RESET(array);
+       BT_VALUE_PUT_REF_AND_RESET(base_map);
+       BT_VALUE_PUT_REF_AND_RESET(extension_map);
+       BT_VALUE_PUT_REF_AND_RESET(extended_map);
 }
 
 int main(void)
This page took 0.043212 seconds and 4 git commands to generate.