Added tests to test the growing and shrinking the hashtable.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@756 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: HashIntMapTest.java,v 1.3 2002/04/11 04:07:42 mdb Exp $
|
// $Id: HashIntMapTest.java,v 1.4 2002/05/23 23:29:38 ray Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -89,6 +89,33 @@ public class HashIntMapTest extends TestCase
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail("serialization failure");
|
fail("serialization failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.clear();
|
||||||
|
// now try putting lots and lots of values in the table
|
||||||
|
// so that it grows a bunch
|
||||||
|
for (int ii=1; ii < 12345; ii += 3) {
|
||||||
|
table.put(ii, new Integer(ii));
|
||||||
|
}
|
||||||
|
|
||||||
|
// now check by removing most and seeing if everything's equal
|
||||||
|
for (int ii=1; ii < 12345; ii += 3) {
|
||||||
|
Integer val;
|
||||||
|
// let's keep the ones that are a multiple of 16
|
||||||
|
if ((ii & 15) == 0) {
|
||||||
|
val = (Integer) table.get(ii);
|
||||||
|
} else {
|
||||||
|
val = (Integer) table.remove(ii);
|
||||||
|
}
|
||||||
|
assertTrue("get(" + ii + ") == " + val, val.intValue() == ii);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and then let's also remove the multiples of 16
|
||||||
|
for (int ii=1; ii < 12345; ii += 3) {
|
||||||
|
if ((ii & 15) == 0) {
|
||||||
|
Integer val = (Integer) table.remove(ii);
|
||||||
|
assertTrue("get(" + ii + ") == " + val, val.intValue() == ii);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateTable (HashIntMap table)
|
protected void populateTable (HashIntMap table)
|
||||||
|
|||||||
Reference in New Issue
Block a user