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

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

commit 70c708a9eec67692f6ae11d471c805940daffa95
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Mar 31 10:17:57 2024 -0400

    Rework test fixtures
    
    Next, grow the amount of data tested to find bugs in the tests with
    non-repeatable map ordering
---
 .../multimap/AbstractMultiValuedMapTest.java       | 43 ++++++++++++++--------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
 
b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
index de47f4c68..0788ed48f 100644
--- 
a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
@@ -1217,21 +1217,34 @@ public abstract class AbstractMultiValuedMapTest<K, V> 
extends AbstractObjectTes
         }
         resetFull();
         final MultiValuedMap<K, V> map = getMap();
-        @SuppressWarnings("unchecked")
-        Collection<V> col = map.get((K) "k0");
-        assertEquals(getSampleCountPerKey(), col.size());
-        assertEquals(getSampleTotalValueCount(), map.size());
-        assertTrue(col.remove("v0_0"));
-        assertTrue(col.remove("v0_1"));
-        assertFalse(map.containsKey("k0"));
-        assertFalse(map.containsMapping("k0", "v0_0"));
-        assertFalse(map.containsMapping("k0", "v0_1"));
-        assertFalse(map.containsValue("v0_0"));
-        assertFalse(map.containsValue("v0_1"));
-        assertEquals(4, map.size());
-        col = map.remove("k0");
-        assertNotNull(col);
-        assertEquals(0, col.size());
+        final int cpk = getSampleCountPerKey();
+        int expectedCount = getSampleTotalValueCount();
+        assertEquals(expectedCount, map.size());
+        for (int k = 0; k < getSampleKeySize(); k++) {
+            final Object key = makeKey(k);
+            @SuppressWarnings("unchecked")
+            Collection<V> col = map.get((K) key);
+            assertEquals(cpk, col.size());
+            for (int i = 0; i < cpk; i++) {
+                final Object value = makeValue(k, i);
+                assertTrue(col.remove(value), () -> value.toString());
+            }
+            for (int i = 0; i < cpk; i++) {
+                assertFalse(col.remove(makeValue(k, i)));
+            }
+            assertFalse(map.containsKey(key));
+            for (int i = 0; i < cpk; i++) {
+                assertFalse(map.containsMapping(key, i));
+            }
+            for (int i = 0; i < cpk; i++) {
+                assertFalse(map.containsValue(makeValue(k, i)));
+            }
+            expectedCount -= cpk;
+            assertEquals(expectedCount, map.size());
+            col = map.remove(key);
+            assertNotNull(col);
+            assertEquals(0, col.size());
+        }
     }
 
     @Test

Reply via email to