01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.collections.map;
17:
18: import java.util.Map;
19:
20: import junit.framework.Test;
21: import junit.textui.TestRunner;
22:
23: import org.apache.commons.collections.BulkTest;
24:
25: /**
26: * JUnit tests.
27: *
28: * @version $Revision: 171349 $ $Date: 2005-05-22 18:48:56 +0100 (Sun, 22 May 2005) $
29: *
30: * @author Stephen Colebourne
31: */
32: public class TestHashedMap extends AbstractTestIterableMap {
33:
34: public TestHashedMap(String testName) {
35: super (testName);
36: }
37:
38: public static void main(String[] args) {
39: TestRunner.run(suite());
40: }
41:
42: public static Test suite() {
43: return BulkTest.makeSuite(TestHashedMap.class);
44: }
45:
46: public Map makeEmptyMap() {
47: return new HashedMap();
48: }
49:
50: public String getCompatibilityVersion() {
51: return "3";
52: }
53:
54: public void testClone() {
55: HashedMap map = new HashedMap(10);
56: map.put("1", "1");
57: Map cloned = (Map) map.clone();
58: assertEquals(map.size(), cloned.size());
59: assertSame(map.get("1"), cloned.get("1"));
60: }
61:
62: public void testInternalState() {
63: HashedMap map = new HashedMap(42, 0.75f);
64: assertEquals(0.75f, map.loadFactor, 0.1f);
65: assertEquals(0, map.size);
66: assertEquals(64, map.data.length);
67: assertEquals(48, map.threshold);
68: assertEquals(0, map.modCount);
69: }
70:
71: // public void testCreate() throws Exception {
72: // resetEmpty();
73: // writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/HashedMap.emptyCollection.version3.obj");
74: // resetFull();
75: // writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/HashedMap.fullCollection.version3.obj");
76: // }
77: }
|