From 1d5610521f5846c1d6f7d0a65f93c384dbf33e8d Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Mon, 20 Aug 2007 14:11:47 +0000 Subject: [PATCH] Applying my test/fix patch from COLLECTIONS-261 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@567711 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/collections/map/Flat3Map.java | 12 ++++++------ .../commons/collections/map/TestFlat3Map.java | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/commons/collections/map/Flat3Map.java b/src/java/org/apache/commons/collections/map/Flat3Map.java index 23ff969fc..1a7bfb58e 100644 --- a/src/java/org/apache/commons/collections/map/Flat3Map.java +++ b/src/java/org/apache/commons/collections/map/Flat3Map.java @@ -416,7 +416,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable { return old; } if (key2 == null) { - Object old = value3; + Object old = value2; hash2 = hash3; key2 = key3; value2 = value3; @@ -427,7 +427,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable { return old; } if (key1 == null) { - Object old = value3; + Object old = value1; hash1 = hash3; key1 = key3; value1 = value3; @@ -448,7 +448,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable { return old; } if (key1 == null) { - Object old = value2; + Object old = value1; hash1 = hash2; key1 = key2; value1 = value2; @@ -483,7 +483,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable { return old; } if (hash2 == hashCode && key.equals(key2)) { - Object old = value3; + Object old = value2; hash2 = hash3; key2 = key3; value2 = value3; @@ -494,7 +494,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable { return old; } if (hash1 == hashCode && key.equals(key1)) { - Object old = value3; + Object old = value1; hash1 = hash3; key1 = key3; value1 = value3; @@ -515,7 +515,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable { return old; } if (hash1 == hashCode && key.equals(key1)) { - Object old = value2; + Object old = value1; hash1 = hash2; key1 = key2; value1 = value2; diff --git a/src/test/org/apache/commons/collections/map/TestFlat3Map.java b/src/test/org/apache/commons/collections/map/TestFlat3Map.java index 9195489cb..a23f97f59 100644 --- a/src/test/org/apache/commons/collections/map/TestFlat3Map.java +++ b/src/test/org/apache/commons/collections/map/TestFlat3Map.java @@ -390,4 +390,20 @@ public class TestFlat3Map extends AbstractTestIterableMap { // (java.io.Serializable) map, // "D:/dev/collections/data/test/Flat3Map.fullCollection.version3.1.obj"); // } + + public void testCollections261() { + Flat3Map m = new Flat3Map(); + m.put( new Integer(1), new Integer(1) ); + m.put( new Integer(0), new Integer(0) ); + assertEquals( new Integer(1), m.remove( new Integer(1) ) ); + assertEquals( new Integer(0), m.remove( new Integer(0) ) ); + + m.put( new Integer(2), new Integer(2) ); + m.put( new Integer(1), new Integer(1) ); + m.put( new Integer(0), new Integer(0) ); + assertEquals( new Integer(2), m.remove( new Integer(2) ) ); + assertEquals( new Integer(1), m.remove( new Integer(1) ) ); + assertEquals( new Integer(0), m.remove( new Integer(0) ) ); + } + }