Rework test fixtures

Next, grow the amount of data tested to find bugs in the tests with
non-repeatable map ordering
This commit is contained in:
Gary Gregory 2024-03-31 11:06:49 -04:00
parent 6d3740fb48
commit 42ae7b98c2
1 changed files with 12 additions and 13 deletions

View File

@ -557,7 +557,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
} }
public int getSampleKeySize() { public int getSampleKeySize() {
return 3; return 256;
} }
public int getSampleTotalValueCount() { public int getSampleTotalValueCount() {
@ -1037,19 +1037,18 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
} }
if (!isHashSetValue() && isAddSupported()) { if (!isHashSetValue() && isAddSupported()) {
assertTrue(it.hasNext()); assertTrue(it.hasNext());
final int maxK = getSampleKeySize(); final MultiValuedMap<K, V> dejaVu = makeObject();
final int maxV = getSampleCountPerKey(); while (it.hasNext()) {
for (int k = 0; k < maxK; k++) { final K next = it.next();
final Object key = makeKey(k); assertNotNull(next);
for (int v = 0; v < maxV; v++) { final K itKey = it.getKey();
final Object value = makeValue(k, v); assertEquals(next, itKey);
assertTrue(it.hasNext()); final V itValue = it.getValue();
assertEquals(key, it.next()); dejaVu.put(itKey, itValue);
assertEquals(key, it.getKey()); assertThrows(UnsupportedOperationException.class, () -> it.setValue((V) "threetrois"));
assertEquals(value, it.getValue());
assertThrows(UnsupportedOperationException.class, () -> it.setValue((V) "threetrois"));
}
} }
assertEquals(map, dejaVu);
assertEquals(dejaVu, map);
assertThrows(UnsupportedOperationException.class, () -> it.setValue((V) "threetrois")); assertThrows(UnsupportedOperationException.class, () -> it.setValue((V) "threetrois"));
} }
} }