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

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git


The following commit(s) were added to refs/heads/master by this push:
     new 87c54525 Better test for list.remove() and check for double add
87c54525 is described below

commit 87c545251ca76b42cc3a6f339e6c3d2dbc26bc3a
Author: Thomas Vandahl <[email protected]>
AuthorDate: Thu Oct 1 19:49:40 2026 +0200

    Better test for list.remove() and check for double add
---
 .../apache/commons/jcs4/utils/struct/DoubleLinkedListUnitTest.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/struct/DoubleLinkedListUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/struct/DoubleLinkedListUnitTest.java
index bc6cf419..ad19f4a5 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/struct/DoubleLinkedListUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/struct/DoubleLinkedListUnitTest.java
@@ -20,6 +20,7 @@ package org.apache.commons.jcs4.utils.struct;
  */
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -200,19 +201,23 @@ class DoubleLinkedListUnitTest
 
         final DoubleLinkedListNode node1 = new DoubleLinkedListNode();
         final DoubleLinkedListNode node2 = new DoubleLinkedListNode();
+        final DoubleLinkedListNode node3 = new DoubleLinkedListNode();
 
         list.addFirst(node1);
         list.addFirst(node2);
         assertEquals(2, list.size(), "Wrong size");
 
         // DO WORK
-        list.remove(node1);
+        assertTrue(list.remove(node1), "Should be removed");
+        assertFalse(list.remove(node3), "Should not be removed");
 
         // VERIFY
         assertEquals(1, list.size(), "Wrong size");
         assertEquals(node2, list.getLast(), "Wrong last");
         assertEquals(node2, list.getFirst(), "Wrong first");
 
+        list.addFirst(node1);
+        assertEquals(2, list.size(), "Wrong size");
         list.addFirst(node1);
         assertEquals(2, list.size(), "Wrong size");
         assertEquals(node1, list.getFirst(), "Wrong first");

Reply via email to