You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/11/27 19:33:10 UTC

[commons-collections] 04/06: Sort members.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 1c7ffa63facd6017022c2ac32071fa3415f1d4fc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Nov 26 10:17:07 2020 -0500

    Sort members.
---
 .../collections4/map/CaseInsensitiveMapTest.java   | 110 ++++++++++-----------
 1 file changed, 55 insertions(+), 55 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 0273dd9..1f6a0ef 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<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();
@@ -61,42 +61,6 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
     }
 
     @SuppressWarnings("unchecked")
-    public void testNullHandling() {
-        final Map<K, V> map = makeObject();
-        map.put((K) "One", (V) "One");
-        map.put((K) "Two", (V) "Two");
-        map.put(null, (V) "Three");
-        assertEquals("Three", map.get(null));
-        map.put(null, (V) "Four");
-        assertEquals("Four", map.get(null));
-        final Set<K> keys = map.keySet();
-        assertTrue(keys.contains("one"));
-        assertTrue(keys.contains("two"));
-        assertTrue(keys.contains(null));
-        assertEquals(3, keys.size());
-    }
-
-    public void testPutAll() {
-        final Map<Object, String> map = new HashMap<>();
-        map.put("One", "One");
-        map.put("Two", "Two");
-        map.put("one", "Three");
-        map.put(null, "Four");
-        map.put(Integer.valueOf(20), "Five");
-        final Map<Object, String> caseInsensitiveMap = new CaseInsensitiveMap<>(map);
-        assertEquals(4, caseInsensitiveMap.size()); // ones collapsed
-        final Set<Object> keys = caseInsensitiveMap.keySet();
-        assertTrue(keys.contains("one"));
-        assertTrue(keys.contains("two"));
-        assertTrue(keys.contains(null));
-        assertTrue(keys.contains(Integer.toString(20)));
-        assertEquals(4, keys.size());
-        assertTrue(!caseInsensitiveMap.containsValue("One")
-            || !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");
@@ -105,12 +69,13 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
         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");
-//    }
+    /**
+     * 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() {
@@ -140,11 +105,46 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
         }
     }
 
-    /**
-     * 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);
+//    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();
+        map.put((K) "One", (V) "One");
+        map.put((K) "Two", (V) "Two");
+        map.put(null, (V) "Three");
+        assertEquals("Three", map.get(null));
+        map.put(null, (V) "Four");
+        assertEquals("Four", map.get(null));
+        final Set<K> keys = map.keySet();
+        assertTrue(keys.contains("one"));
+        assertTrue(keys.contains("two"));
+        assertTrue(keys.contains(null));
+        assertEquals(3, keys.size());
+    }
+
+    public void testPutAll() {
+        final Map<Object, String> map = new HashMap<>();
+        map.put("One", "One");
+        map.put("Two", "Two");
+        map.put("one", "Three");
+        map.put(null, "Four");
+        map.put(Integer.valueOf(20), "Five");
+        final Map<Object, String> caseInsensitiveMap = new CaseInsensitiveMap<>(map);
+        assertEquals(4, caseInsensitiveMap.size()); // ones collapsed
+        final Set<Object> keys = caseInsensitiveMap.keySet();
+        assertTrue(keys.contains("one"));
+        assertTrue(keys.contains("two"));
+        assertTrue(keys.contains(null));
+        assertTrue(keys.contains(Integer.toString(20)));
+        assertEquals(4, keys.size());
+        assertTrue(!caseInsensitiveMap.containsValue("One")
+            || !caseInsensitiveMap.containsValue("Three")); // ones collapsed
+        assertEquals("Four", caseInsensitiveMap.get(null));
     }
 }