2323
2424import junit .framework .TestCase ;
2525
26- public class IntBitSetAllocatorTests extends TestCase {
26+ public class IntAllocatorTests extends TestCase {
2727
2828 private static final int TEST_ITERATIONS = 50000 ;
2929 private static final int HI_RANGE = 100000 ;
3030 private static final int LO_RANGE = 100 ;
31- private IntBitSetAllocator iAll = new IntBitSetAllocator (LO_RANGE , HI_RANGE );
31+ private IntAllocator iAll = new IntAllocator (LO_RANGE , HI_RANGE );
3232
3333 private Random rand = new Random (70608L );
3434
@@ -40,15 +40,13 @@ public void testReserveAndFree() throws Exception {
4040 iAll .free (trial );
4141 set .remove (trial );
4242 } else {
43- assertTrue ("Did not reserve free integer " + trial ,
44- iAll .reserve (trial ));
43+ assertTrue ("Did not reserve free integer " + trial , iAll .reserve (trial ));
4544 set .add (trial );
4645 }
4746 }
4847
4948 for (int trial : set ) {
50- assertFalse ("Integer " + trial + " not allocated!" ,
51- iAll .reserve (trial ));
49+ assertFalse ("Integer " + trial + " not allocated!" , iAll .reserve (trial ));
5250 }
5351 }
5452
@@ -62,31 +60,28 @@ public void testAllocateAndFree() throws Exception {
6260 } else {
6361 if (!set .isEmpty ()) {
6462 int trial = extractOne (set );
65- assertFalse ("Allocator agreed to reserve " + trial ,
66- iAll .reserve (trial ));
63+ assertFalse ("Allocator agreed to reserve " + trial , iAll .reserve (trial ));
6764 iAll .free (trial );
6865 }
6966 }
7067 }
7168
7269 for (int trial : set ) {
73- assertFalse ("Integer " + trial + " should be allocated!" ,
74- iAll .reserve (trial ));
70+ assertFalse ("Integer " + trial + " should be allocated!" , iAll .reserve (trial ));
7571 }
7672 }
7773
7874 public void testToString () throws Exception {
79- IntBitSetAllocator ibs = new IntBitSetAllocator (LO_RANGE , HI_RANGE );
80- assertEquals ("IntBitSetAllocator {allocated = []}" , ibs .toString ());
75+ IntAllocator ibs = new IntAllocator (LO_RANGE , HI_RANGE );
76+ assertEquals ("IntAllocator {allocated = []}" , ibs .toString ());
8177 ibs .allocate ();
82- assertEquals ("IntBitSetAllocator {allocated = [100]}" , ibs .toString ());
78+ assertEquals ("IntAllocator {allocated = [100]}" , ibs .toString ());
8379 for (int i = 200 ; i <211 ; i =i +4 ) {
8480 ibs .reserve (i );
8581 ibs .reserve (i +1 );
8682 ibs .reserve (i +2 );
8783 }
88- assertEquals ("IntBitSetAllocator{allocated = "
89- + "[100, 200..202, 204..206, 208..210]}"
84+ assertEquals ("IntAllocator{allocated = [100, 200..202, 204..206, 208..210]}"
9085 , ibs .toString ());
9186 }
9287
0 commit comments