make find_remove tests robust against possible duplicates in the random test data

Tue, 23 Dec 2025 10:00:02 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 23 Dec 2025 10:00:02 +0100
changeset 1659
a726281c809f
parent 1658
71aa6e28a2d7
child 1660
802ab24f67aa

make find_remove tests robust against possible duplicates in the random test data

resolves #791

tests/test_list.c file | annotate | diff | comparison | revisions
--- a/tests/test_list.c	Mon Dec 22 16:59:48 2025 +0100
+++ b/tests/test_list.c	Tue Dec 23 10:00:02 2025 +0100
@@ -2533,7 +2533,13 @@
     CX_TEST_ASSERT(cxListFind(list, x) == exp);
     CX_TEST_ASSERT(cxListFindRemove(list, x) == exp);
     CX_TEST_ASSERT(cxListSize(list) == testdata_len - 1);
-    CX_TEST_ASSERT(cxListFind(list, x) != exp);
+    for (unsigned i = 0, j = 0 ; i < testdata_len - 1 ; i++,j++) {
+        if (i == exp) {
+            j++;
+            continue;
+        }
+        CX_TEST_ASSERT(*(int*)cxListAt(list, i) == testdata[j]);
+    }
 
     int notinlist = -1;
     CX_TEST_ASSERT(cxListFindRemove(list, &notinlist) == cxListSize(list));
@@ -2599,7 +2605,13 @@
     CX_TEST_ASSERT(cxListFind(list, &val) == exp);
     CX_TEST_ASSERT(cxListFindRemove(list, &val) == exp);
     CX_TEST_ASSERT(cxListSize(list) == testdata_len - 1);
-    CX_TEST_ASSERT(cxListFind(list, &val) != exp);
+    for (unsigned i = 0, j = 0 ; i < testdata_len - 1 ; i++,j++) {
+        if (i == exp) {
+            j++;
+            continue;
+        }
+        CX_TEST_ASSERT(*(int*)cxListAt(list, i) == testdata[j]);
+    }
 
     int notinlist = -1;
     CX_TEST_ASSERT(cxListFindRemove(list, &notinlist) == cxListSize(list));

mercurial