Methods Summary |
---|
public void | testAddPastFull()
final int capacity = 10;
final int count = capacity * 10 + 1;
final CircularList<Integer> list = new CircularList<Integer>( Integer.class, capacity );
for( int i = 0; i < count; ++i )
{
list.add( new Integer( i ) );
Integer value = (Integer)list.get( list.size() - 1 );
assertEquals( i, value.intValue() );
if ( i >= capacity )
{
value = (Integer)list.get( 0 );
assertEquals( 1 + (i - capacity), value.intValue() );
}
}
assert( list.capacity() == capacity );
|
public void | testAddUntilFull()
final int capacity = 10;
final CircularList<Integer> list = new CircularList<Integer>( Integer.class, capacity );
assertEquals( capacity, list.capacity() );
for( int i = 0; i < capacity; ++i )
{
list.add( new Integer( i ) );
assert( list.size() == i + 1 );
assert( ((Integer)list.get( i )).intValue() == i );
}
assert( list.capacity() == capacity );
|
public void | testClear()
final CircularList<Object> list = new CircularList<Object>( Object.class, 10 );
assertEquals( 0, list.size() );
list.add( "hello" );
assertEquals( 1, list.size() );
list.clear();
assertEquals( 0, list.size() );
assertEquals( 10, list.capacity() );
|
public void | testCreate()
new CircularList<Object>( Object.class, 10 );
|
public void | testCreateIllegal()
try
{
new CircularList<Object>( Object.class, 0 );
assert( false );
}
catch( IllegalArgumentException e )
{
}
|
public void | testEquals()
final int capacity = 2;
final CircularList<String> list1 = new CircularList<String>( String.class, capacity );
final CircularList<String> list2 = new CircularList<String>( String.class, capacity );
assert( list1.equals( list2 ) );
list1.add( "hello" );
list1.add( "there" );
list2.add( "hello" );
list2.add( "there" );
assert( list1.equals( list2 ) );
|
public void | testRemoveFirst()
final int capacity = 100;
final CircularList<Integer> list = new CircularList<Integer>( Integer.class, capacity );
for( int i = 0; i < capacity; ++i )
{
list.add( new Integer( i ) );
}
for( int i = 0; i < capacity; ++i )
{
final Integer value = (Integer)list.removeFirst();
assertEquals( i, value.intValue() );
}
|
public void | testRemoveFirstLast()
final int capacity = 3;
final CircularList<String> list = new CircularList<String>( String.class, capacity );
list.add( "hello" );
list.add( "xxx" );
list.add( "there" );
assertEquals( "hello", list.removeFirst() );
assertEquals( "there", list.removeLast() );
assertEquals( 1, list.size() );
|
public void | testSet()
final int capacity = 100;
final CircularList<Integer> list = new CircularList<Integer>( Integer.class, capacity );
for( int i = 0; i < capacity; ++i )
{
list.add( new Integer( i ) );
}
for( int i = 0; i < capacity; ++i )
{
final Integer value = (Integer)list.get( i );
list.set( i, value );
assertEquals( value, list.get( i ) );
}
|
public void | testSizeAndCapacity()
final CircularList<Object> list = new CircularList<Object>( Object.class, 10 );
assertEquals( 0, list.size() );
assertEquals( 10, list.capacity() );
|