Sort members.

This commit is contained in:
Gary Gregory 2020-11-26 10:17:07 -05:00
parent 743af0bb1f
commit 1c7ffa63fa
1 changed files with 59 additions and 59 deletions

View File

@ -31,17 +31,12 @@ import org.apache.commons.collections4.BulkTest;
*/
public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V> {
public CaseInsensitiveMapTest(final String testName) {
super(testName);
}
public static Test suite() {
return BulkTest.makeSuite(CaseInsensitiveMapTest.class);
}
@Override
public CaseInsensitiveMap<K, V> makeObject() {
return new CaseInsensitiveMap<>();
public CaseInsensitiveMapTest(final String testName) {
super(testName);
}
@Override
@ -49,6 +44,11 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
return "4";
}
@Override
public CaseInsensitiveMap<K, V> makeObject() {
return new CaseInsensitiveMap<>();
}
@SuppressWarnings("unchecked")
public void testCaseInsensitive() {
final Map<K, V> map = makeObject();
@ -60,6 +60,58 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
assertEquals("Three", map.get("Two"));
}
@SuppressWarnings("unchecked")
public void testClone() {
final CaseInsensitiveMap<K, V> map = new CaseInsensitiveMap<>(10);
map.put((K) "1", (V) "1");
final CaseInsensitiveMap<K, V> cloned = map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
/**
* Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>.
*/
public void testInitialCapacityZero() {
final CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<>(0);
assertEquals(1, map.data.length);
}
// COLLECTIONS-294
public void testLocaleIndependence() {
final Locale orig = Locale.getDefault();
final Locale[] locales = { Locale.ENGLISH, new Locale("tr", "", ""), Locale.getDefault() };
final String[][] data = {
{ "i", "I" },
{ "\u03C2", "\u03C3" },
{ "\u03A3", "\u03C2" },
{ "\u03A3", "\u03C3" },
};
try {
for (final Locale locale : locales) {
Locale.setDefault(locale);
for (int j = 0; j < data.length; j++) {
assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1]));
final CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<>();
map.put(data[j][0], "value");
assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1]));
}
}
} finally {
Locale.setDefault(orig);
}
}
// public void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk((java.io.Serializable) map, "src/test/resources/data/test/CaseInsensitiveMap.emptyCollection.version4.obj");
// resetFull();
// writeExternalFormToDisk((java.io.Serializable) map, "src/test/resources/data/test/CaseInsensitiveMap.fullCollection.version4.obj");
// }
@SuppressWarnings("unchecked")
public void testNullHandling() {
final Map<K, V> map = makeObject();
@ -95,56 +147,4 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
|| !caseInsensitiveMap.containsValue("Three")); // ones collapsed
assertEquals("Four", caseInsensitiveMap.get(null));
}
@SuppressWarnings("unchecked")
public void testClone() {
final CaseInsensitiveMap<K, V> map = new CaseInsensitiveMap<>(10);
map.put((K) "1", (V) "1");
final CaseInsensitiveMap<K, V> cloned = map.clone();
assertEquals(map.size(), cloned.size());
assertSame(map.get("1"), cloned.get("1"));
}
// public void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk((java.io.Serializable) map, "src/test/resources/data/test/CaseInsensitiveMap.emptyCollection.version4.obj");
// resetFull();
// writeExternalFormToDisk((java.io.Serializable) map, "src/test/resources/data/test/CaseInsensitiveMap.fullCollection.version4.obj");
// }
// COLLECTIONS-294
public void testLocaleIndependence() {
final Locale orig = Locale.getDefault();
final Locale[] locales = { Locale.ENGLISH, new Locale("tr", "", ""), Locale.getDefault() };
final String[][] data = {
{ "i", "I" },
{ "\u03C2", "\u03C3" },
{ "\u03A3", "\u03C2" },
{ "\u03A3", "\u03C3" },
};
try {
for (final Locale locale : locales) {
Locale.setDefault(locale);
for (int j = 0; j < data.length; j++) {
assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1]));
final CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<>();
map.put(data[j][0], "value");
assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1]));
}
}
} finally {
Locale.setDefault(orig);
}
}
/**
* Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>.
*/
public void testInitialCapacityZero() {
final CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<>(0);
assertEquals(1, map.data.length);
}
}