Skip to content

Commit

Permalink
Rework test fixtures
Browse files Browse the repository at this point in the history
Next, grow the amount of data tested to find bugs in the tests with
non-repeatable map ordering
  • Loading branch information
garydgregory committed Mar 31, 2024
1 parent cff3638 commit 8cae451
Showing 1 changed file with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1030,33 +1030,26 @@ public void testMultipleValues() {
public void testMultiValuedMapIterator() {
final MultiValuedMap<K, V> map = makeFullMap();
final MapIterator<K, V> it = map.mapIterator();

assertThrows(IllegalStateException.class, () -> it.getKey());
assertThrows(IllegalStateException.class, () -> it.getValue());
if (isAddSupported()) {
assertThrows(IllegalStateException.class, () -> it.setValue((V) "V"));
}

if (!isHashSetValue() && isAddSupported()) {
assertTrue(it.hasNext() );
assertEquals("k0", it.next());
assertEquals("k0", it.getKey());
assertEquals("v0_0", it.getValue());
assertEquals("k0", it.next());
assertEquals("k0", it.getKey());
assertEquals("v0_1", it.getValue());
assertEquals("k1", it.next());
assertEquals("k1", it.getKey());
assertEquals("v1_0", it.getValue());
assertEquals("k1", it.next());
assertEquals("k1", it.getKey());
assertEquals("v1_1", it.getValue());
assertEquals("k2", it.next());
assertEquals("k2", it.getKey());
assertEquals("v2_0", it.getValue());
assertEquals("k2", it.next());
assertEquals("k2", it.getKey());
assertEquals("v2_1", it.getValue());
assertTrue(it.hasNext());
final int maxK = getSampleKeySize();
final int maxV = getSampleCountPerKey();
for (int k = 0; k < maxK; k++) {
final Object key = makeKey(k);
for (int v = 0; v < maxV; v++) {
final Object value = makeValue(k, v);
assertTrue(it.hasNext());
assertEquals(key, it.next());
assertEquals(key, it.getKey());
assertEquals(value, it.getValue());
assertThrows(UnsupportedOperationException.class, () -> it.setValue((V) "threetrois"));
}
}
assertThrows(UnsupportedOperationException.class, () -> it.setValue((V) "threetrois"));
}
}
Expand Down

0 comments on commit 8cae451

Please sign in to comment.