From 1c7ffa63facd6017022c2ac32071fa3415f1d4fc Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 26 Nov 2020 10:17:07 -0500 Subject: [PATCH] Sort members. --- .../map/CaseInsensitiveMapTest.java | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java b/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java index 0273dd98a..1f6a0ef0b 100644 --- a/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java @@ -31,17 +31,12 @@ import org.apache.commons.collections4.BulkTest; */ public class CaseInsensitiveMapTest extends AbstractIterableMapTest { - public CaseInsensitiveMapTest(final String testName) { - super(testName); - } - public static Test suite() { return BulkTest.makeSuite(CaseInsensitiveMapTest.class); } - @Override - public CaseInsensitiveMap makeObject() { - return new CaseInsensitiveMap<>(); + public CaseInsensitiveMapTest(final String testName) { + super(testName); } @Override @@ -49,6 +44,11 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest return "4"; } + @Override + public CaseInsensitiveMap makeObject() { + return new CaseInsensitiveMap<>(); + } + @SuppressWarnings("unchecked") public void testCaseInsensitive() { final Map map = makeObject(); @@ -60,6 +60,58 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest assertEquals("Three", map.get("Two")); } + @SuppressWarnings("unchecked") + public void testClone() { + final CaseInsensitiveMap map = new CaseInsensitiveMap<>(10); + map.put((K) "1", (V) "1"); + final CaseInsensitiveMap cloned = map.clone(); + assertEquals(map.size(), cloned.size()); + assertSame(map.get("1"), cloned.get("1")); + } + + /** + * Test for COLLECTIONS-323. + */ + public void testInitialCapacityZero() { + final CaseInsensitiveMap 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 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 map = makeObject(); @@ -95,56 +147,4 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest || !caseInsensitiveMap.containsValue("Three")); // ones collapsed assertEquals("Four", caseInsensitiveMap.get(null)); } - - @SuppressWarnings("unchecked") - public void testClone() { - final CaseInsensitiveMap map = new CaseInsensitiveMap<>(10); - map.put((K) "1", (V) "1"); - final CaseInsensitiveMap 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 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 COLLECTIONS-323. - */ - public void testInitialCapacityZero() { - final CaseInsensitiveMap map = new CaseInsensitiveMap<>(0); - assertEquals(1, map.data.length); - } }