lib: add bt_{graph,query_executor}_add_interrupter()
[babeltrace.git] / tests / lib / test_bt_values.c
index ed7e4049a99b4f8aa3dfd337c3fbfaa9577194d7..39427f46e4b568fb2d03200a5c5dc672300e88bd 100644 (file)
@@ -78,27 +78,27 @@ void test_unsigned_integer(void)
        uint64_t value;
        bt_value *obj;
 
-       obj = bt_value_unsigned_integer_create();
+       obj = bt_value_integer_unsigned_create();
        ok(obj && bt_value_is_unsigned_integer(obj),
-               "bt_value_unsigned_integer_create() returns an unsigned integer value object");
+               "bt_value_integer_unsigned_create() returns an unsigned integer value object");
 
        value = 1961;
-       value = bt_value_unsigned_integer_get(obj);
+       value = bt_value_integer_unsigned_get(obj);
        ok(value == 0, "default unsigned integer value object value is 0");
 
-       bt_value_unsigned_integer_set(obj, 98765);
-       value = bt_value_unsigned_integer_get(obj);
-       ok(value == 98765, "bt_value_unsigned_integer_bool_set() works");
+       bt_value_integer_unsigned_set(obj, 98765);
+       value = bt_value_integer_unsigned_get(obj);
+       ok(value == 98765, "bt_value_integer_unsigned_bool_set() works");
 
        BT_VALUE_PUT_REF_AND_RESET(obj);
        pass("putting an existing unsigned integer value object does not cause a crash")
 
-       obj = bt_value_unsigned_integer_create_init(321456987);
+       obj = bt_value_integer_unsigned_create_init(321456987);
        ok(obj && bt_value_is_unsigned_integer(obj),
-               "bt_value_unsigned_integer_create_init() returns an unsigned integer value object");
-       value = bt_value_unsigned_integer_get(obj);
+               "bt_value_integer_unsigned_create_init() returns an unsigned integer value object");
+       value = bt_value_integer_unsigned_get(obj);
        ok(value == 321456987,
-               "bt_value_unsigned_integer_create_init() sets the appropriate initial value");
+               "bt_value_integer_unsigned_create_init() sets the appropriate initial value");
 
        BT_VALUE_PUT_REF_AND_RESET(obj);
 }
@@ -109,27 +109,27 @@ void test_signed_integer(void)
        int64_t value;
        bt_value *obj;
 
-       obj = bt_value_signed_integer_create();
+       obj = bt_value_integer_signed_create();
        ok(obj && bt_value_is_signed_integer(obj),
-               "bt_value_signed_integer_create() returns a signed integer value object");
+               "bt_value_integer_signed_create() returns a signed integer value object");
 
        value = 1961;
-       value = bt_value_signed_integer_get(obj);
+       value = bt_value_integer_signed_get(obj);
        ok(value == 0, "default signed integer value object value is 0");
 
-       bt_value_signed_integer_set(obj, 98765);
-       value = bt_value_signed_integer_get(obj);
-       ok(value == 98765, "bt_value_signed_integer_bool_set() works");
+       bt_value_integer_signed_set(obj, 98765);
+       value = bt_value_integer_signed_get(obj);
+       ok(value == 98765, "bt_value_integer_signed_bool_set() works");
 
        BT_VALUE_PUT_REF_AND_RESET(obj);
        pass("putting an existing signed integer value object does not cause a crash")
 
-       obj = bt_value_signed_integer_create_init(-321456987);
+       obj = bt_value_integer_signed_create_init(-321456987);
        ok(obj && bt_value_is_signed_integer(obj),
-               "bt_value_signed_integer_create_init() returns a signed integer value object");
-       value = bt_value_signed_integer_get(obj);
+               "bt_value_integer_signed_create_init() returns a signed integer value object");
+       value = bt_value_integer_signed_get(obj);
        ok(value == -321456987,
-               "bt_value_signed_integer_create_init() sets the appropriate initial value");
+               "bt_value_integer_signed_create_init() sets the appropriate initial value");
 
        BT_VALUE_PUT_REF_AND_RESET(obj);
 }
@@ -177,12 +177,12 @@ void test_string(void)
                "bt_value_string_create() returns a string value object");
 
        value = bt_value_string_get(obj);
-       ok(value && !strcmp(value, ""),
+       ok(value && strcmp(value, "") == 0,
                "default string value object value is \"\"");
 
        bt_value_string_set(obj, "hello worldz");
        value = bt_value_string_get(obj);
-       ok(value && !strcmp(value, "hello worldz"),
+       ok(value && strcmp(value, "hello worldz") == 0,
                "bt_value_string_get() works");
 
        BT_VALUE_PUT_REF_AND_RESET(obj);
@@ -192,7 +192,7 @@ void test_string(void)
        ok(obj && bt_value_is_string(obj),
                "bt_value_string_create_init() returns a string value object");
        value = bt_value_string_get(obj);
-       ok(value && !strcmp(value, "initial value"),
+       ok(value && strcmp(value, "initial value") == 0,
                "bt_value_string_create_init() sets the appropriate initial value");
 
        BT_VALUE_PUT_REF_AND_RESET(obj);
@@ -215,10 +215,10 @@ void test_array(void)
        ok(bt_value_array_is_empty(array_obj),
                "initial array value object size is 0");
 
-       obj = bt_value_unsigned_integer_create_init(345);
+       obj = bt_value_integer_unsigned_create_init(345);
        ret = bt_value_array_append_element(array_obj, obj);
        BT_VALUE_PUT_REF_AND_RESET(obj);
-       obj = bt_value_signed_integer_create_init(-507);
+       obj = bt_value_integer_signed_create_init(-507);
        ret |= bt_value_array_append_element(array_obj, obj);
        BT_VALUE_PUT_REF_AND_RESET(obj);
        obj = bt_value_real_create_init(-17.45);
@@ -236,13 +236,13 @@ void test_array(void)
        obj = bt_value_array_borrow_element_by_index(array_obj, 0);
        ok(obj && bt_value_is_unsigned_integer(obj),
                "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (unsigned integer)");
-       int_value = bt_value_unsigned_integer_get(obj);
+       int_value = bt_value_integer_unsigned_get(obj);
        ok(int_value == 345,
                "bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (unsigned integer)");
        obj = bt_value_array_borrow_element_by_index(array_obj, 1);
        ok(obj && bt_value_is_signed_integer(obj),
                "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (signed integer)");
-       int_value = bt_value_signed_integer_get(obj);
+       int_value = bt_value_integer_signed_get(obj);
        ok(int_value == -507,
                "bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (signed integer)");
        obj = bt_value_array_borrow_element_by_index(array_obj, 2);
@@ -261,7 +261,7 @@ void test_array(void)
        ok(obj == bt_value_null,
                "bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (null)");
 
-       obj = bt_value_signed_integer_create_init(1001);
+       obj = bt_value_integer_signed_create_init(1001);
        BT_ASSERT(obj);
        ok(!bt_value_array_set_element_by_index(array_obj, 2, obj),
                "bt_value_array_set_element_by_index() succeeds");
@@ -269,7 +269,7 @@ void test_array(void)
        obj = bt_value_array_borrow_element_by_index(array_obj, 2);
        ok(obj && bt_value_is_signed_integer(obj),
                "bt_value_array_set_element_by_index() inserts an value object with the appropriate type");
-       int_value = bt_value_signed_integer_get(obj);
+       int_value = bt_value_integer_signed_get(obj);
        BT_ASSERT(!ret);
        ok(int_value == 1001,
                "bt_value_array_set_element_by_index() inserts an value object with the appropriate value");
@@ -308,13 +308,13 @@ void test_array(void)
        obj = bt_value_array_borrow_element_by_index(array_obj, 6);
        ok(obj && bt_value_is_unsigned_integer(obj),
                "bt_value_array_append_unsigned_integer_element() appends an unsigned integer value object");
-       int_value = bt_value_unsigned_integer_get(obj);
+       int_value = bt_value_integer_unsigned_get(obj);
        ok(int_value == 98765,
                "bt_value_array_append_unsigned_integer_element() appends the appropriate value");
        obj = bt_value_array_borrow_element_by_index(array_obj, 7);
        ok(obj && bt_value_is_signed_integer(obj),
                "bt_value_array_append_signed_integer_element() appends a signed integer value object");
-       int_value = bt_value_signed_integer_get(obj);
+       int_value = bt_value_integer_signed_get(obj);
        ok(int_value == -10101,
                "bt_value_array_append_signed_integer_element() appends the appropriate value");
        obj = bt_value_array_borrow_element_by_index(array_obj, 8);
@@ -327,7 +327,7 @@ void test_array(void)
        ok(obj && bt_value_is_string(obj),
                "bt_value_array_append_string_element() appends a string value object");
        string_value = bt_value_string_get(obj);
-       ok(!ret && string_value && !strcmp(string_value, "bt_value"),
+       ok(!ret && string_value && strcmp(string_value, "bt_value") == 0,
                "bt_value_array_append_string_element() appends the appropriate value");
        obj = bt_value_array_borrow_element_by_index(array_obj, 10);
        ok(obj && bt_value_is_array(obj),
@@ -379,7 +379,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
 {
        struct map_foreach_checklist *checklist = data;
 
-       if (!strcmp(key, "bt_bool")) {
+       if (strcmp(key, "bt_bool") == 0) {
                if (checklist->bool1) {
                        fail("test_map_foreach_cb_check(): duplicate key \"bt_bool\"");
                } else {
@@ -394,13 +394,13 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"bt_bool\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "uint")) {
+       } else if (strcmp(key, "uint") == 0) {
                if (checklist->uint) {
                        fail("test_map_foreach_cb_check(): duplicate key \"uint\"");
                } else {
                        uint64_t val = 0;
 
-                       val = bt_value_unsigned_integer_get(object);
+                       val = bt_value_integer_unsigned_get(object);
 
                        if (val == 19457) {
                                pass("test_map_foreach_cb_check(): \"uint\" value object has the right value");
@@ -409,13 +409,13 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"uint\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "int")) {
+       } else if (strcmp(key, "int") == 0) {
                if (checklist->int1) {
                        fail("test_map_foreach_cb_check(): duplicate key \"int\"");
                } else {
                        int64_t val = 0;
 
-                       val = bt_value_signed_integer_get(object);
+                       val = bt_value_integer_signed_get(object);
 
                        if (val == -12345) {
                                pass("test_map_foreach_cb_check(): \"int\" value object has the right value");
@@ -424,7 +424,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"int\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "real")) {
+       } else if (strcmp(key, "real") == 0) {
                if (checklist->real1) {
                        fail("test_map_foreach_cb_check(): duplicate key \"real\"");
                } else {
@@ -439,14 +439,14 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"real\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "null")) {
+       } else if (strcmp(key, "null") == 0) {
                if (checklist->null1) {
                        fail("test_map_foreach_cb_check(): duplicate key \"bt_bool\"");
                } else {
                        ok(bt_value_is_null(object), "test_map_foreach_cb_check(): success getting \"null\" value object");
                        checklist->null1 = BT_TRUE;
                }
-       } else if (!strcmp(key, "bool2")) {
+       } else if (strcmp(key, "bool2") == 0) {
                if (checklist->bool2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"bool2\"");
                } else {
@@ -461,13 +461,13 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"bool2\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "int2")) {
+       } else if (strcmp(key, "int2") == 0) {
                if (checklist->int2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"int2\"");
                } else {
                        int64_t val = 0;
 
-                       val = bt_value_signed_integer_get(object);
+                       val = bt_value_integer_signed_get(object);
 
                        if (val == 98765) {
                                pass("test_map_foreach_cb_check(): \"int2\" value object has the right value");
@@ -476,7 +476,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"int2\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "real2")) {
+       } else if (strcmp(key, "real2") == 0) {
                if (checklist->real2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"real2\"");
                } else {
@@ -491,7 +491,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                fail("test_map_foreach_cb_check(): \"real2\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "string2")) {
+       } else if (strcmp(key, "string2") == 0) {
                if (checklist->string2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"string2\"");
                } else {
@@ -499,14 +499,14 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
 
                        val = bt_value_string_get(object);
 
-                       if (val && !strcmp(val, "bt_value")) {
+                       if (val && strcmp(val, "bt_value") == 0) {
                                pass("test_map_foreach_cb_check(): \"string2\" value object has the right value");
                                checklist->string2 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"string2\" value object has the wrong value");
                        }
                }
-       } else if (!strcmp(key, "array2")) {
+       } else if (strcmp(key, "array2") == 0) {
                if (checklist->array2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"array2\"");
                } else {
@@ -515,7 +515,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
                                "test_map_foreach_cb_check(): \"array2\" value object is empty");
                        checklist->array2 = BT_TRUE;
                }
-       } else if (!strcmp(key, "map2")) {
+       } else if (strcmp(key, "map2") == 0) {
                if (checklist->map2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"map2\"");
                } else {
@@ -550,10 +550,10 @@ void test_map(void)
        ok(bt_value_map_get_size(map_obj) == 0,
                "initial map value object size is 0");
 
-       obj = bt_value_unsigned_integer_create_init(19457);
+       obj = bt_value_integer_unsigned_create_init(19457);
        ret = bt_value_map_insert_entry(map_obj, "uint", obj);
        BT_VALUE_PUT_REF_AND_RESET(obj);
-       obj = bt_value_signed_integer_create_init(-12345);
+       obj = bt_value_integer_signed_create_init(-12345);
        ret |= bt_value_map_insert_entry(map_obj, "int", obj);
        BT_VALUE_PUT_REF_AND_RESET(obj);
        obj = bt_value_real_create_init(5.444);
@@ -584,13 +584,13 @@ void test_map(void)
        obj = bt_value_map_borrow_entry_value(map_obj, "uint");
        ok(obj && bt_value_is_unsigned_integer(obj),
                "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (unsigned integer)");
-       int_value = bt_value_unsigned_integer_get(obj);
+       int_value = bt_value_integer_unsigned_get(obj);
        ok(int_value == 19457,
                "bt_value_map_borrow_entry_value() returns an value object with the appropriate value (unsigned integer)");
        obj = bt_value_map_borrow_entry_value(map_obj, "int");
        ok(obj && bt_value_is_signed_integer(obj),
                "bt_value_map_borrow_entry_value() returns an value object with the appropriate type (signed integer)");
-       int_value = bt_value_signed_integer_get(obj);
+       int_value = bt_value_integer_signed_get(obj);
        ok(int_value == -12345,
                "bt_value_map_borrow_entry_value() returns an value object with the appropriate value (signed integer)");
        obj = bt_value_map_borrow_entry_value(map_obj, "null");
@@ -651,7 +651,7 @@ void test_map(void)
 
        ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_count,
                &count);
-       ok(ret == BT_VALUE_MAP_FOREACH_ENTRY_STATUS_CANCELED && count == 3,
+       ok(ret == BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED && count == 3,
                "bt_value_map_foreach_entry() breaks the loop when the user function returns BT_FALSE");
 
        memset(&checklist, 0, sizeof(checklist));
@@ -719,11 +719,11 @@ static
 void test_compare_unsigned_integer(void)
 {
        bt_value *int1 =
-               bt_value_unsigned_integer_create_init(10);
+               bt_value_integer_unsigned_create_init(10);
        bt_value *int2 =
-               bt_value_unsigned_integer_create_init(23);
+               bt_value_integer_unsigned_create_init(23);
        bt_value *int3 =
-               bt_value_unsigned_integer_create_init(10);
+               bt_value_integer_unsigned_create_init(10);
 
        BT_ASSERT(int1 && int2 && int3);
        ok(!bt_value_compare(bt_value_null,
@@ -742,11 +742,11 @@ void test_compare_unsigned_integer(void)
 void test_compare_signed_integer(void)
 {
        bt_value *int1 =
-               bt_value_signed_integer_create_init(10);
+               bt_value_integer_signed_create_init(10);
        bt_value *int2 =
-               bt_value_signed_integer_create_init(-23);
+               bt_value_integer_signed_create_init(-23);
        bt_value *int3 =
-               bt_value_signed_integer_create_init(10);
+               bt_value_integer_signed_create_init(10);
 
        BT_ASSERT(int1 && int2 && int3);
        ok(!bt_value_compare(bt_value_null,
@@ -958,8 +958,8 @@ void test_copy(void)
        bt_value_copy_status copy_status;
 
        bool_obj = bt_value_bool_create_init(BT_TRUE);
-       unsigned_integer_obj = bt_value_unsigned_integer_create_init(23);
-       signed_integer_obj = bt_value_signed_integer_create_init(-47);
+       unsigned_integer_obj = bt_value_integer_unsigned_create_init(23);
+       signed_integer_obj = bt_value_integer_signed_create_init(-47);
        real_obj = bt_value_real_create_init(-3.1416);
        string_obj = bt_value_string_create_init("test");
        array_obj = bt_value_array_create();
This page took 0.031396 seconds and 4 git commands to generate.