gnu.trove.TCollectionsTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
High performance collections for Java
The newest version!
package gnu.trove;
import gnu.trove.list.TIntList;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.TIntSet;
import gnu.trove.set.hash.TIntHashSet;
import junit.framework.TestCase;
/**
*
*/
public class TCollectionsTest extends TestCase {
public void testUnmodifiableList() {
final TIntArrayList one = new TIntArrayList( new int[]{ 1, 2, 3, 4 } );
final TIntArrayList two = new TIntArrayList( new int[]{ 1, 2, 3, 4 } );
TIntList uOne = TCollections.unmodifiableList( one );
TIntList uTwo = TCollections.unmodifiableList( two );
assertEquals( one, two );
assertEquals( uOne, uTwo );
}
public void testUnmodifiableSet() {
final TIntSet one = new TIntHashSet( new int[]{ 1, 2, 3, 4 } );
final TIntSet two = new TIntHashSet( new int[]{ 1, 2, 3, 4 } );
TIntSet uOne = TCollections.unmodifiableSet( one );
TIntSet uTwo = TCollections.unmodifiableSet( two );
assertEquals( one, two );
assertEquals( uOne, uTwo );
}
public void testUnmodifiableMap() {
final TIntObjectMap one = new TIntObjectHashMap();
one.put( 0, Integer.valueOf( 0 ) );
one.put( 1, Integer.valueOf( 1 ) );
one.put( 2, Integer.valueOf( 2 ) );
one.put( 3, Integer.valueOf( 3 ) );
final TIntObjectMap two = new TIntObjectHashMap( one );
TIntObjectMap uOne = TCollections.unmodifiableMap( one );
TIntObjectMap uTwo = TCollections.unmodifiableMap( two );
assertEquals( one, two );
assertEquals( uOne, uTwo );
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy