tests/test_list.c

changeset 1433
81c301a59b7c
parent 1429
6e0c3a8a914a
child 1435
48ebf22b698e
--- a/tests/test_list.c	Mon Oct 20 19:44:18 2025 +0200
+++ b/tests/test_list.c	Mon Oct 20 20:10:36 2025 +0200
@@ -1686,6 +1686,55 @@
     CX_TEST_ASSERT(*(int *) cxListAt(list, 9) == 42);
 })
 
+roll_out_test_combos_with_defaulted_funcs(emplace_array, {
+    int a[5] = array_init(5, 47, 11, 13, 42);
+    int b[5] = array_init(9, 18, 72, 50, 7);
+
+    CxIterator iter;
+
+    iter = cxListEmplaceArray(list, 5);
+    CX_TEST_ASSERT(cxListSize(list) == 5);
+    CX_TEST_ASSERT(iter.elem_count == 5);
+    CX_TEST_ASSERT(iter.index == 0);
+    if (isptrlist) {
+        cx_foreach(int **, elem, iter) {
+            *elem = a + iter.index;
+        }
+    } else {
+        cx_foreach(int *, elem, iter) {
+            *elem = a[iter.index];
+        }
+    }
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == 5);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == 47);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == 11);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 3) == 13);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 4) == 42);
+    iter = cxListEmplaceArrayAt(list, 3, 5);
+    CX_TEST_ASSERT(cxListSize(list) == 10);
+    CX_TEST_ASSERT(iter.elem_count == 5);
+    CX_TEST_ASSERT(iter.index == 0);
+    if (isptrlist) {
+        cx_foreach(int **, elem, iter) {
+            *elem = b + iter.index;
+        }
+    } else {
+        cx_foreach(int *, elem, iter) {
+            *elem = b[iter.index];
+        }
+    }
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == 5);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == 47);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == 11);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 3) == 9);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 4) == 18);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 5) == 72);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 6) == 50);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 7) == 7);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 8) == 13);
+    CX_TEST_ASSERT(*(int *) cxListAt(list, 9) == 42);
+})
+
 roll_out_test_combos_with_defaulted_funcs(insert_sorted, {
     int d1 = 50;
     int d2 = 80;
@@ -2599,6 +2648,8 @@
     cx_test_register(suite, test_list_parl_emplace);
     cx_test_register(suite, test_list_arl_insert_array);
     cx_test_register(suite, test_list_parl_insert_array);
+    cx_test_register(suite, test_list_arl_emplace_array);
+    cx_test_register(suite, test_list_parl_emplace_array);
     cx_test_register(suite, test_list_arl_insert_sorted);
     cx_test_register(suite, test_list_parl_insert_sorted);
     cx_test_register(suite, test_list_arl_insert_unique);
@@ -2658,6 +2709,8 @@
 
     cx_test_register(suite, test_list_arlm_insert_array);
     cx_test_register(suite, test_list_parlm_insert_array);
+    cx_test_register(suite, test_list_arlm_emplace_array);
+    cx_test_register(suite, test_list_parlm_emplace_array);
     cx_test_register(suite, test_list_arlm_insert_sorted);
     cx_test_register(suite, test_list_parlm_insert_sorted);
     cx_test_register(suite, test_list_arlm_insert_unique);
@@ -2715,6 +2768,8 @@
     cx_test_register(suite, test_list_pll_emplace);
     cx_test_register(suite, test_list_ll_insert_array);
     cx_test_register(suite, test_list_pll_insert_array);
+    cx_test_register(suite, test_list_ll_emplace_array);
+    cx_test_register(suite, test_list_pll_emplace_array);
     cx_test_register(suite, test_list_ll_insert_sorted);
     cx_test_register(suite, test_list_pll_insert_sorted);
     cx_test_register(suite, test_list_ll_insert_unique);
@@ -2773,6 +2828,8 @@
 
     cx_test_register(suite, test_list_llm_insert_array);
     cx_test_register(suite, test_list_pllm_insert_array);
+    cx_test_register(suite, test_list_llm_emplace_array);
+    cx_test_register(suite, test_list_pllm_emplace_array);
     cx_test_register(suite, test_list_llm_insert_sorted);
     cx_test_register(suite, test_list_pllm_insert_sorted);
     cx_test_register(suite, test_list_llm_insert_unique);
@@ -2803,6 +2860,8 @@
     cx_test_register(suite, test_list_pkvl_emplace);
     cx_test_register(suite, test_list_kvl_insert_array);
     cx_test_register(suite, test_list_pkvl_insert_array);
+    cx_test_register(suite, test_list_kvl_emplace_array);
+    cx_test_register(suite, test_list_pkvl_emplace_array);
     cx_test_register(suite, test_list_kvl_insert_sorted);
     cx_test_register(suite, test_list_pkvl_insert_sorted);
     cx_test_register(suite, test_list_kvl_insert_unique);

mercurial