This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/fix-array-list-initial-capability-bug
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to 
refs/heads/feature/fix-array-list-initial-capability-bug by this push:
     new f8bc2991e Add array list initial cap options usage test
f8bc2991e is described below

commit f8bc2991e6a95074f1c4ae4c77bab6462cbcf9cd
Author: Pepijn Noltes <[email protected]>
AuthorDate: Thu Dec 18 20:16:10 2025 +0100

    Add array list initial cap options usage test
---
 libs/utils/gtest/src/ArrayListTestSuite.cc | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libs/utils/gtest/src/ArrayListTestSuite.cc 
b/libs/utils/gtest/src/ArrayListTestSuite.cc
index c9219b9fb..b35b0a235 100644
--- a/libs/utils/gtest/src/ArrayListTestSuite.cc
+++ b/libs/utils/gtest/src/ArrayListTestSuite.cc
@@ -507,3 +507,15 @@ TEST_F(ArrayListTestSuite, ElementTypeToStringTest) {
     EXPECT_STREQ("Undefined",
                  
celix_arrayList_elementTypeToString((celix_array_list_element_type_t)100 /*non 
existing*/));
 }
+
+TEST_F(ArrayListTestSuite, InitialCapacityOptionTest) {
+    celix_array_list_create_options_t opts{};
+    opts.elementType = CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING;
+    opts.initialCapacity = 1; // smaller than number of elements we will add
+    celix_autoptr(celix_array_list_t) list = 
celix_arrayList_createWithOptions(&opts);
+
+    // First add fits in initial capacity
+    EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addString(list, "v1"));
+    // Second add requires realloc
+    EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addString(list, "v2"));
+}

Reply via email to