trove repacked: bug in THashMap.Entry.setValue()

This commit is contained in:
Alexey Kudravtsev
2013-02-05 10:27:40 +04:00
parent 585a32f04a
commit ab2a47cc4d
5 changed files with 66 additions and 37 deletions
+5
View File
@@ -1,3 +1,8 @@
Date: 4 Feb 2013
Changed classes:
gnu.trove.THashMap - fixed bug in the Entry.setValue()
gnu.trove.benchmark.* - moved to the util/gnu.trove.benchmark package
Date: 5 May 2012
Changed classes:
gnu.trove.TPrimitiveHash - fixed manual setUp in constructor (capacity, load_fator) as proper super call will do it properly
Binary file not shown.
BIN
View File
Binary file not shown.
@@ -1,37 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util.containers;
public class TObjectIntHashMapTest extends junit.framework.TestCase {
public void test() {
gnu.trove.TObjectIntHashMap map = new gnu.trove.TObjectIntHashMap();
map.trimToSize();
for (int i = 0; i < 100; i++) {
String key = String.valueOf(i);
map.put(key, i);
map.put(key+"a", i);
}
for (int i = 0; i < 100; i++) {
String key = String.valueOf(i);
junit.framework.Assert.assertEquals(i, map.get(key));
junit.framework.Assert.assertEquals(i, map.get(key+"a"));
}
junit.framework.Assert.assertEquals(200, map.size());
}
}
@@ -0,0 +1,61 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util.containers;
import gnu.trove.THashMap;
import gnu.trove.TObjectIntHashMap;
import junit.framework.Assert;
import junit.framework.TestCase;
import java.util.Map;
public class TroveTest extends TestCase {
public void testObjectInt() {
TObjectIntHashMap<String> map = new TObjectIntHashMap<String>();
map.trimToSize();
for (int i = 0; i < 100; i++) {
String key = String.valueOf(i);
map.put(key, i);
map.put(key+"a", i);
}
for (int i = 0; i < 100; i++) {
String key = String.valueOf(i);
Assert.assertEquals(i, map.get(key));
Assert.assertEquals(i, map.get(key+"a"));
}
Assert.assertEquals(200, map.size());
}
public void testTHashMap_Entry() {
Map<Object, Object> map = new THashMap<Object, Object>();
map.put("1", "2");
Map.Entry<Object, Object> entry = map.entrySet().iterator().next();
assertEquals("1", entry.getKey());
assertEquals("2", entry.getValue());
Object old = entry.setValue("3");
assertEquals("2", old);
assertEquals("1", entry.getKey());
assertEquals("3", entry.getValue());
Map.Entry<Object, Object> refreshed = map.entrySet().iterator().next();
assertEquals("1", refreshed.getKey());
assertEquals("3", refreshed.getValue());
}
}