This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-remove-array-list-type-undefined in repository https://gitbox.apache.org/repos/asf/celix.git
commit 6090b7aca1807f2c60cdb2eab9e417372fd02045 Author: Pepijn Noltes <[email protected]> AuthorDate: Sat Jan 4 19:57:03 2025 +0100 gh-674: Fix some wrong array element type issues --- CHANGES.md | 1 + libs/framework/src/framework.c | 2 +- libs/utils/gtest/src/ArrayListTestSuite.cc | 48 +----------------------------- libs/utils/include/celix_array_list.h | 2 +- 4 files changed, 4 insertions(+), 49 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7da716829..0af6bd381 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -80,6 +80,7 @@ limitations under the License. - The manifest format has been changed to JSON, and the manifest attribute names have been changed. The old manifest format is no longer supported. The old manifest attribute names are also no longer defined in `celix_constants.h`. +- The funnction `celix_arrayList_create` has been removed, use the element type specific create functions instead. ## New Features diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c index 7956e5379..8a0a0ac11 100644 --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@ -497,7 +497,7 @@ celix_status_t framework_start(celix_framework_t* framework) { static celix_status_t framework_autoStartConfiguredBundles(celix_framework_t* fw, bool *startedAllBundles) { celix_status_t status = CELIX_SUCCESS; const char* const celixKeys[] = {CELIX_AUTO_START_0, CELIX_AUTO_START_1, CELIX_AUTO_START_2, CELIX_AUTO_START_3, CELIX_AUTO_START_4, CELIX_AUTO_START_5, CELIX_AUTO_START_6, NULL}; - celix_autoptr(celix_array_list_t) installedBundles = celix_arrayList_createPointerArray(); + celix_autoptr(celix_array_list_t) installedBundles = celix_arrayList_createLongArray(); if (!installedBundles) { celix_framework_logTssErrors(fw->logger, CELIX_LOG_LEVEL_ERROR); return ENOMEM; diff --git a/libs/utils/gtest/src/ArrayListTestSuite.cc b/libs/utils/gtest/src/ArrayListTestSuite.cc index c77c3efe6..c16655c64 100644 --- a/libs/utils/gtest/src/ArrayListTestSuite.cc +++ b/libs/utils/gtest/src/ArrayListTestSuite.cc @@ -380,35 +380,10 @@ TEST_F(ArrayListTestSuite, SimpleRemovedCallbacksForArrayListTest) { celix_arrayList_destroy(list); //will call free for every entry } -TEST_F(ArrayListTestSuite, AddStringToArrayListOfUndefinedTypeTest) { - celix_array_list_create_options_t opts{}; - opts.simpleRemovedCallback = free; - auto* list = celix_arrayList_createWithOptions(&opts); - celix_arrayList_addString(list, celix_utils_strdup("value")); - celix_arrayList_addString(list, celix_utils_strdup("value")); - celix_arrayList_addString(list, celix_utils_strdup("value")); - celix_arrayList_addString(list, celix_utils_strdup("value")); - EXPECT_EQ(celix_arrayList_size(list), 4); - celix_arrayList_destroy(list); //will call free for every entry -} - -TEST_F(ArrayListTestSuite, AddVersionToArrayListOfUndefinedTypeTest) { - celix_array_list_create_options_t opts{}; - opts.simpleRemovedCallback = [](void* data) { - celix_version_destroy((celix_version_t*)data); - }; - auto* list = celix_arrayList_createWithOptions(&opts); - celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr)); - celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr)); - celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr)); - celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr)); - EXPECT_EQ(celix_arrayList_size(list), 4); - celix_arrayList_destroy(list); //will call free for every entry -} - TEST_F(ArrayListTestSuite, RemovedCallbacksForArrayListTest) { int count = 0 ; celix_array_list_create_options_t opts{}; + opts.elementType = CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG; opts.removedCallbackData = &count; opts.removedCallback = [](void *data, celix_array_list_entry_t entry) { int* c = (int*)data; @@ -454,27 +429,6 @@ TEST_F(ArrayListTestSuite, SortForArrayListTest) { celix_arrayList_destroy(list); } -TEST_F(ArrayListTestSuite, ReturnStatusAddFunctionsTest) { - auto* list = celix_arrayList_createLongArray(); - ASSERT_TRUE(list != nullptr); - EXPECT_EQ(0, celix_arrayList_size(list)); - - //no error, return status is CELIX_SUCCESS - EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addLong(list, 2L)); - EXPECT_EQ(1, celix_arrayList_size(list)); - - EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addDouble(list, 4.0)); - EXPECT_EQ(2, celix_arrayList_size(list)); - - EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addBool(list, true)); - EXPECT_EQ(3, celix_arrayList_size(list)); - - EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_add(list, (void*)0x42)); - EXPECT_EQ(4, celix_arrayList_size(list)); - - celix_arrayList_destroy(list); -} - TEST_F(ArrayListTestSuite, AutoCleanupTest) { celix_autoptr(celix_array_list_t) list = celix_arrayList_createPointerArray(); EXPECT_NE(nullptr, list); diff --git a/libs/utils/include/celix_array_list.h b/libs/utils/include/celix_array_list.h index d1390c759..630a6b65d 100644 --- a/libs/utils/include/celix_array_list.h +++ b/libs/utils/include/celix_array_list.h @@ -170,7 +170,7 @@ celix_array_list_t* celix_arrayList_createVersionArray(); */ typedef struct celix_array_list_create_options { /** - * The element type of the array list. Default is CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. + * The element type of the array list. Default is CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER. */ celix_array_list_element_type_t elementType CELIX_OPTS_INIT;
