Fix a bug with table resizing. Includes junit test case.

This commit is contained in:
Ian Farmer
2008-01-23 01:21:54 +00:00
parent f55a393fb8
commit 4fa417bdd9
2 changed files with 24 additions and 1 deletions

View File

@@ -30,6 +30,25 @@ public class LTableTest extends TestCase {
}
}
public void testResize() {
LTable t = new LTable();
// NOTE: This order of insertion is important.
t.put(3, LInteger.valueOf(3));
t.put(1, LInteger.valueOf(1));
t.put(5, LInteger.valueOf(5));
t.put(4, LInteger.valueOf(4));
t.put(6, LInteger.valueOf(6));
t.put(2, LInteger.valueOf(2));
for ( int i = 1; i < 6; ++i ) {
assertEquals(LInteger.valueOf(i), t.get(i));
}
assertEquals( 0, t.getHashCapacity() );
assertTrue( t.getArrayCapacity() >= 6 );
}
public void testOutOfOrderIntegerKeyInsertion() {
LTable t = new LTable();