X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=tests%2Flib%2Ftest_bt_values.c;h=1dbb9b8d8c60b93cf977c90199522ee580ee57d0;hb=ca914e549e4ff113292102d27edd6af662b860d3;hp=b0cd85931f19108b926017151b15e30e2185df55;hpb=acfa811244c6c27fedf0e2ebfb283ab42cc7e25e;p=babeltrace.git diff --git a/tests/lib/test_bt_values.c b/tests/lib/test_bt_values.c index b0cd8593..1dbb9b8d 100644 --- a/tests/lib/test_bt_values.c +++ b/tests/lib/test_bt_values.c @@ -25,7 +25,7 @@ #include #include "tap/tap.h" -#define NR_TESTS 166 +#define NR_TESTS 188 static void test_null(void) @@ -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); } @@ -208,6 +208,7 @@ void test_array(void) bt_value *obj; const char *string_value; bt_value *array_obj; + bt_value *appended_obj; array_obj = bt_value_array_create(); ok(array_obj && bt_value_is_array(array_obj), @@ -215,10 +216,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); @@ -230,19 +231,19 @@ void test_array(void) 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) == 5, + ok(bt_value_array_get_length(array_obj) == 5, "appending an element to an array value object increment its size"); 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 +262,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 +270,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"); @@ -289,12 +290,24 @@ void test_array(void) ret = bt_value_array_append_string_element(array_obj, "bt_value"); ok(!ret, "bt_value_array_append_string_element() succeeds"); - ret = bt_value_array_append_empty_array_element(array_obj); + ret = bt_value_array_append_empty_array_element(array_obj, NULL); ok(!ret, "bt_value_array_append_empty_array_element() succeeds"); - ret = bt_value_array_append_empty_map_element(array_obj); + ret = bt_value_array_append_empty_array_element(array_obj, &appended_obj); + ok(!ret, "bt_value_array_append_empty_array_element() with returned value object succeeds"); + ok(appended_obj, + "object returned by bt_value_array_append_empty_array_element() is not NULL"); + ok(bt_value_is_array(appended_obj), + "object returned by bt_value_array_append_empty_array_element() is an array value"); + ret = bt_value_array_append_empty_map_element(array_obj, NULL); ok(!ret, "bt_value_array_append_empty_map_element() succeeds"); - - ok(bt_value_array_get_size(array_obj) == 12, + ret = bt_value_array_append_empty_map_element(array_obj, &appended_obj); + ok(!ret, "bt_value_array_append_empty_map_element() with returned value object succeeds"); + ok(appended_obj, + "object returned by bt_value_array_append_empty_map_element() is not NULL"); + ok(bt_value_is_map(appended_obj), + "object returned by bt_value_array_append_empty_map_element() is an array value"); + + ok(bt_value_array_get_length(array_obj) == 14, "the bt_value_array_append_element_*() functions increment the array value object's size"); ok(!bt_value_array_is_empty(array_obj), "map value object is not empty"); @@ -308,13 +321,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); @@ -335,6 +348,16 @@ void test_array(void) ok(bt_value_array_is_empty(obj), "bt_value_array_append_empty_array_element() an empty array value object"); obj = bt_value_array_borrow_element_by_index(array_obj, 11); + ok(obj && bt_value_is_array(obj), + "bt_value_array_append_empty_array_element() appends an array value object"); + ok(bt_value_array_is_empty(obj), + "bt_value_array_append_empty_array_element() an empty array value object"); + obj = bt_value_array_borrow_element_by_index(array_obj, 12); + ok(obj && bt_value_is_map(obj), + "bt_value_array_append_empty_map_element() appends a map value object"); + ok(bt_value_map_is_empty(obj), + "bt_value_array_append_empty_map_element() an empty map value object"); + obj = bt_value_array_borrow_element_by_index(array_obj, 13); ok(obj && bt_value_is_map(obj), "bt_value_array_append_empty_map_element() appends a map value object"); ok(bt_value_map_is_empty(obj), @@ -370,7 +393,9 @@ struct map_foreach_checklist { bt_bool real2; bt_bool string2; bt_bool array2; + bt_bool array3; bt_bool map2; + bt_bool map3; }; static @@ -400,7 +425,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object, } 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"); @@ -415,7 +440,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object, } 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"); @@ -467,7 +492,7 @@ bt_bool test_map_foreach_cb_check(const char *key, bt_value *object, } 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"); @@ -515,6 +540,24 @@ 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, "array3") == 0) { + if (checklist->array3) { + fail("test_map_foreach_cb_check(): duplicate key \"array3\""); + } else { + ok(bt_value_is_array(object), "test_map_foreach_cb_check(): success getting \"array3\" value object"); + ok(bt_value_array_is_empty(object), + "test_map_foreach_cb_check(): \"array3\" value object is empty"); + checklist->array3 = BT_TRUE; + } + } else if (strcmp(key, "map3") == 0) { + if (checklist->map3) { + fail("test_map_foreach_cb_check(): duplicate key \"map3\""); + } else { + ok(bt_value_is_map(object), "test_map_foreach_cb_check(): success getting \"map3\" value object"); + ok(bt_value_map_is_empty(object), + "test_map_foreach_cb_check(): \"map3\" value object is empty"); + checklist->map3 = BT_TRUE; + } } else if (strcmp(key, "map2") == 0) { if (checklist->map2) { fail("test_map_foreach_cb_check(): duplicate key \"map2\""); @@ -542,6 +585,7 @@ void test_map(void) double real_value; bt_value *obj; bt_value *map_obj; + bt_value *inserted_obj; struct map_foreach_checklist checklist; map_obj = bt_value_map_create(); @@ -550,10 +594,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 +628,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"); @@ -615,13 +659,24 @@ void test_map(void) ret = bt_value_map_insert_string_entry(map_obj, "string2", "bt_value"); ok(!ret, "bt_value_map_insert_string_entry() succeeds"); - ret = bt_value_map_insert_empty_array_entry(map_obj, - "array2"); + ret = bt_value_map_insert_empty_array_entry(map_obj, "array2", NULL); ok(!ret, "bt_value_map_insert_empty_array_entry() succeeds"); - ret = bt_value_map_insert_empty_map_entry(map_obj, "map2"); + ret = bt_value_map_insert_empty_array_entry(map_obj, "array3", &inserted_obj); + ok(!ret, "bt_value_map_insert_empty_array_entry() with returned value object succeeds"); + ok(inserted_obj, + "object returned by bt_value_map_insert_empty_array_entry() is not NULL"); + ok(bt_value_is_array(inserted_obj), + "object returned by bt_value_map_insert_empty_array_entry() is an array value"); + ret = bt_value_map_insert_empty_map_entry(map_obj, "map2", NULL); ok(!ret, "bt_value_map_insert_empty_map_entry() succeeds"); - - ok(bt_value_map_get_size(map_obj) == 11, + ret = bt_value_map_insert_empty_map_entry(map_obj, "map3", &inserted_obj); + ok(!ret, "bt_value_map_insert_empty_map_entry() with returned value object succeeds"); + ok(inserted_obj, + "object returned by bt_value_map_insert_empty_map_entry() is not NULL"); + ok(bt_value_is_map(inserted_obj), + "object returned by bt_value_map_insert_empty_map_entry() is an array value"); + + ok(bt_value_map_get_size(map_obj) == 13, "the bt_value_map_insert*() functions increment the map value object's size"); ok(!bt_value_map_has_entry(map_obj, "hello"), @@ -646,12 +701,16 @@ void test_map(void) "map value object has key \"string2\""); ok(bt_value_map_has_entry(map_obj, "array2"), "map value object has key \"array2\""); + ok(bt_value_map_has_entry(map_obj, "array3"), + "map value object has key \"array3\""); ok(bt_value_map_has_entry(map_obj, "map2"), "map value object has key \"map2\""); + ok(bt_value_map_has_entry(map_obj, "map3"), + "map value object has key \"map3\""); 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)); @@ -683,14 +742,14 @@ void test_types(void) } static -void test_compare_null(void) +void test_is_equal_null(void) { - ok(bt_value_compare(bt_value_null, bt_value_null), + ok(bt_value_is_equal(bt_value_null, bt_value_null), "null value objects are equivalent"); } static -void test_compare_bool(void) +void test_is_equal_bool(void) { bt_value *bool1 = bt_value_bool_create_init(BT_FALSE); @@ -700,14 +759,11 @@ void test_compare_bool(void) bt_value_bool_create_init(BT_FALSE); BT_ASSERT(bool1 && bool2 && bool3); - ok(!bt_value_compare(bt_value_null, - bool1), + ok(!bt_value_is_equal(bt_value_null, bool1), "cannot compare null value object and bt_bool value object"); - ok(!bt_value_compare(bool1, - bool2), + ok(!bt_value_is_equal(bool1, bool2), "boolean value objects are not equivalent (BT_FALSE and BT_TRUE)"); - ok(bt_value_compare(bool1, - bool3), + ok(bt_value_is_equal(bool1, bool3), "boolean value objects are equivalent (BT_FALSE and BT_FALSE)"); BT_VALUE_PUT_REF_AND_RESET(bool1); @@ -716,22 +772,21 @@ void test_compare_bool(void) } static -void test_compare_unsigned_integer(void) +void test_is_equal_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, - int1), + ok(!bt_value_is_equal(bt_value_null, int1), "cannot compare null value object and unsigned integer value object"); - ok(!bt_value_compare(int1, int2), + ok(!bt_value_is_equal(int1, int2), "unsigned integer value objects are not equivalent (10 and 23)"); - ok(bt_value_compare(int1, int3), + ok(bt_value_is_equal(int1, int3), "unsigned integer value objects are equivalent (10 and 10)"); BT_VALUE_PUT_REF_AND_RESET(int1); @@ -739,22 +794,21 @@ void test_compare_unsigned_integer(void) BT_VALUE_PUT_REF_AND_RESET(int3); } -void test_compare_signed_integer(void) +void test_is_equal_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, - int1), + ok(!bt_value_is_equal(bt_value_null, int1), "cannot compare null value object and signed integer value object"); - ok(!bt_value_compare(int1, int2), + ok(!bt_value_is_equal(int1, int2), "signed integer value objects are not equivalent (10 and -23)"); - ok(bt_value_compare(int1, int3), + ok(bt_value_is_equal(int1, int3), "signed integer value objects are equivalent (10 and 10)"); BT_VALUE_PUT_REF_AND_RESET(int1); @@ -763,7 +817,7 @@ void test_compare_signed_integer(void) } static -void test_compare_real(void) +void test_is_equal_real(void) { bt_value *real1 = bt_value_real_create_init(17.38); @@ -774,14 +828,11 @@ void test_compare_real(void) BT_ASSERT(real1 && real2 && real3); - ok(!bt_value_compare(bt_value_null, - real1), + ok(!bt_value_is_equal(bt_value_null, real1), "cannot compare null value object and real number value object"); - ok(!bt_value_compare(real1, - real2), + ok(!bt_value_is_equal(real1, real2), "real number value objects are not equivalent (17.38 and -14.23)"); - ok(bt_value_compare(real1, - real3), + ok(bt_value_is_equal(real1, real3), "real number value objects are equivalent (17.38 and 17.38)"); BT_VALUE_PUT_REF_AND_RESET(real1); @@ -790,7 +841,7 @@ void test_compare_real(void) } static -void test_compare_string(void) +void test_is_equal_string(void) { bt_value *string1 = bt_value_string_create_init("hello"); @@ -801,14 +852,11 @@ void test_compare_string(void) BT_ASSERT(string1 && string2 && string3); - ok(!bt_value_compare(bt_value_null, - string1), + ok(!bt_value_is_equal(bt_value_null, string1), "cannot compare null value object and string value object"); - ok(!bt_value_compare(string1, - string2), + ok(!bt_value_is_equal(string1, string2), "string value objects are not equivalent (\"hello\" and \"bt_value\")"); - ok(bt_value_compare(string1, - string3), + ok(bt_value_is_equal(string1, string3), "string value objects are equivalent (\"hello\" and \"hello\")"); BT_VALUE_PUT_REF_AND_RESET(string1); @@ -817,7 +865,7 @@ void test_compare_string(void) } static -void test_compare_array(void) +void test_is_equal_array(void) { bt_value *array1 = bt_value_array_create(); bt_value *array2 = bt_value_array_create(); @@ -826,7 +874,7 @@ void test_compare_array(void) BT_ASSERT(array1 && array2 && array3); - ok(bt_value_compare(array1, array2), + ok(bt_value_is_equal(array1, array2), "empty array value objects are equivalent"); append_status = bt_value_array_append_signed_integer_element(array1, 23); @@ -847,18 +895,15 @@ void test_compare_array(void) BT_ASSERT(append_status == BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK); append_status = bt_value_array_append_bool_element(array3, BT_FALSE); BT_ASSERT(append_status == BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK); - BT_ASSERT(bt_value_array_get_size(array1) == 3); - BT_ASSERT(bt_value_array_get_size(array2) == 3); - BT_ASSERT(bt_value_array_get_size(array3) == 3); + BT_ASSERT(bt_value_array_get_length(array1) == 3); + BT_ASSERT(bt_value_array_get_length(array2) == 3); + BT_ASSERT(bt_value_array_get_length(array3) == 3); - ok(!bt_value_compare(bt_value_null, - array1), + ok(!bt_value_is_equal(bt_value_null, array1), "cannot compare null value object and array value object"); - ok(!bt_value_compare(array1, - array2), + ok(!bt_value_is_equal(array1, array2), "array value objects are not equivalent ([23, 14.2, BT_FALSE] and [14.2, 23, BT_FALSE])"); - ok(bt_value_compare(array1, - array3), + ok(bt_value_is_equal(array1, array3), "array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])"); BT_VALUE_PUT_REF_AND_RESET(array1); @@ -867,7 +912,7 @@ void test_compare_array(void) } static -void test_compare_map(void) +void test_is_equal_map(void) { bt_value *map1 = bt_value_map_create(); bt_value *map2 = bt_value_map_create(); @@ -876,8 +921,7 @@ void test_compare_map(void) BT_ASSERT(map1 && map2 && map3); - ok(bt_value_compare(map1, - map2), + ok(bt_value_is_equal(map1, map2), "empty map value objects are equivalent"); @@ -906,14 +950,11 @@ void test_compare_map(void) BT_ASSERT(bt_value_map_get_size(map2) == 3); BT_ASSERT(bt_value_map_get_size(map3) == 3); - ok(!bt_value_compare(bt_value_null, - map1), + ok(!bt_value_is_equal(bt_value_null, map1), "cannot compare null value object and map value object"); - ok(!bt_value_compare(map1, - map2), + ok(!bt_value_is_equal(map1, map2), "map value objects are not equivalent"); - ok(bt_value_compare(map1, - map3), + ok(bt_value_is_equal(map1, map3), "map value objects are equivalent"); BT_VALUE_PUT_REF_AND_RESET(map1); @@ -922,16 +963,16 @@ void test_compare_map(void) } static -void test_compare(void) +void test_is_equal(void) { - test_compare_null(); - test_compare_bool(); - test_compare_unsigned_integer(); - test_compare_signed_integer(); - test_compare_real(); - test_compare_string(); - test_compare_array(); - test_compare_map(); + test_is_equal_null(); + test_is_equal_bool(); + test_is_equal_unsigned_integer(); + test_is_equal_signed_integer(); + test_is_equal_real(); + test_is_equal_string(); + test_is_equal_array(); + test_is_equal_map(); } static @@ -940,9 +981,9 @@ void test_copy(void) /* * Here's the deal here. If we make sure that each value object * of our deep copy has a different address than its source, and - * that bt_value_compare() returns BT_TRUE for the top-level + * that bt_value_is_equal() returns BT_TRUE for the top-level * value object, taking into account that we test the - * correctness of bt_value_compare() elsewhere, then the deep + * correctness of bt_value_is_equal() elsewhere, then the deep * copy is a success. */ bt_value *null_copy_obj; @@ -958,8 +999,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(); @@ -1018,7 +1059,7 @@ void test_copy(void) ok(null_copy_obj == bt_value_null, "bt_value_copy() returns the same pointer (null)"); - ok(bt_value_compare(map_obj, map_copy_obj), + ok(bt_value_is_equal(map_obj, map_copy_obj), "source and destination value objects have the same content"); BT_VALUE_PUT_REF_AND_RESET(map_copy_obj); @@ -1041,7 +1082,7 @@ bt_bool compare_map_elements(const bt_value *map_a, const bt_value *map_b, elem_a = bt_value_map_borrow_entry_value_const(map_a, key); elem_b = bt_value_map_borrow_entry_value_const(map_b, key); - equal = bt_value_compare(elem_a, elem_b); + equal = bt_value_is_equal(elem_a, elem_b); return equal; } @@ -1053,6 +1094,7 @@ void test_extend(void) bt_value *extended_map = NULL; bt_value *array = bt_value_array_create(); bt_value_map_insert_entry_status insert_status; + bt_value_copy_status copy_status; bt_value_map_extend_status extend_status; BT_ASSERT(base_map); @@ -1079,7 +1121,9 @@ void test_extend(void) insert_status = bt_value_map_insert_real_entry(extension_map, "project", -404); BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK); - extend_status = bt_value_map_extend(base_map, extension_map, &extended_map); + copy_status = bt_value_copy(base_map, &extended_map); + BT_ASSERT(copy_status == BT_VALUE_COPY_STATUS_OK); + extend_status = bt_value_map_extend(extended_map, extension_map); ok(extend_status == BT_VALUE_MAP_EXTEND_STATUS_OK && extended_map, "bt_value_map_extend() succeeds"); ok(bt_value_map_get_size(extended_map) == 5, @@ -1110,7 +1154,7 @@ int main(void) { plan_tests(NR_TESTS); test_types(); - test_compare(); + test_is_equal(); test_copy(); test_extend(); return 0;