void () { for (int size : new int[]{0, 1, 2, 3, 4, 10, 11, 12}) { UnmodifiableHashMap<Integer, String> map = create(size); String actual = map.toString(); assertTrue(actual.startsWith("{")); assertTrue(actual.endsWith("}")); String content = actual.substring(1, actual.length() - 1); if (size == 0) { assertTrue(content.isEmpty()); continue; } Set<String> parts = Set.of(content.split(", ", -1)); assertEquals(size, parts.size()); assertEquals(IntStreamEx.range(size).mapToObj(i -> i + "=" + i).toSet(), parts); } }