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 e5c95c2 commit eab18e9
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down Expand Up @@ -52,9 +55,21 @@ public UnmodifiableMultiValuedMapTest() {
* @param map the MultiValuedMap<K, V> to check
*/
private void assertMapContainsAllValues(final MultiValuedMap<K, V> map) {
assertEquals("[v0_0, v0_1]", map.get((K) "k0").toString());
assertEquals("[v1_0, v1_1]", map.get((K) "k1").toString());
assertEquals("[v2_0, v2_1]", map.get((K) "k2").toString());
final int maxK = getSampleKeySize();
final int cpk = getSampleCountPerKey();
for (int k = 0; k < maxK; k++) {
final K key = makeKey(k);
final Collection<V> collection = map.get((K) key);
assertEquals(cpk, collection.size());
final String toString = collection.toString();
final List<V> expected = new ArrayList<>(cpk);
for (int j = 0; j < cpk; j++) {
expected.add(makeValue(k, j));
}
assertEquals(expected.size(), collection.size());
assertEquals(expected, new ArrayList<>(collection));
assertEquals(expected.toString(), toString);
}
}

@Override
Expand Down

0 comments on commit eab18e9

Please sign in to comment.