mirror of
https://github.com/apache/commons-collections.git
synced 2025-03-03 07:19:21 +00:00
* add ArrayUnsignedIntList and tests
* deprecate some test cases to reduce the number of deprecation warnings git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d77ea4efc
commit
9bbaba8bcd
@ -0,0 +1,319 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/ArrayUnsignedIntList.java,v 1.1 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||
* Foundation" must not be used to endorse or promote products derived
|
||||
* from this software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache"
|
||||
* nor may "Apache" appear in their names without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections.primitives;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An {@link IntList} backed by an array of unsigned
|
||||
* <code>int</code> values.
|
||||
* This list stores <code>int</code> values
|
||||
* in the range [{@link #MIN_VALUE <code>0</code>},
|
||||
* {@link #MAX_VALUE <code>65535</code>}] in 16-bits
|
||||
* per element. Attempts to use elements outside this
|
||||
* range may cause an
|
||||
* {@link IllegalArgumentException IllegalArgumentException}
|
||||
* to be thrown.
|
||||
* <p />
|
||||
* This implementation supports all optional methods.
|
||||
*
|
||||
* @since Commons Collections 2.2
|
||||
* @version $Revision: 1.1 $ $Date: 2003/04/09 06:44:34 $
|
||||
*
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class ArrayUnsignedIntList extends AbstractRandomAccessLongList implements LongList, Serializable {
|
||||
|
||||
// constructors
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Construct an empty list with the default
|
||||
* initial capacity.
|
||||
*/
|
||||
protected ArrayUnsignedIntList() {
|
||||
this(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an empty list with the given
|
||||
* initial capacity.
|
||||
* @throws IllegalArgumentException when <i>initialCapacity</i> is negative
|
||||
*/
|
||||
protected ArrayUnsignedIntList(int initialCapacity) {
|
||||
if(initialCapacity < 0) {
|
||||
throw new IllegalArgumentException("capacity " + initialCapacity);
|
||||
}
|
||||
_data = new int[initialCapacity];
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a list containing the elements of the given collection,
|
||||
* in the order they are returned by that collection's iterator.
|
||||
*
|
||||
* @see ArrayIntList#addAll(org.apache.commons.collections.primitives.LongCollection)
|
||||
* @param that the non-<code>null</code> collection of <code>int</code>s
|
||||
* to add
|
||||
* @throws NullPointerException if <i>that</i> is <code>null</code>
|
||||
*/
|
||||
public ArrayUnsignedIntList(LongCollection that) {
|
||||
this(that.size());
|
||||
addAll(that);
|
||||
}
|
||||
|
||||
// IntList methods
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the element at the specified position within
|
||||
* me.
|
||||
* By construction, the returned value will be
|
||||
* between {@link #MIN_VALUE} and {@link #MAX_VALUE}, inclusive.
|
||||
*
|
||||
* @param index the index of the element to return
|
||||
* @return the value of the element at the specified position
|
||||
* @throws IndexOutOfBoundsException if the specified index is out of range
|
||||
*/
|
||||
public long get(int index) {
|
||||
checkRange(index);
|
||||
return toLong(_data[index]);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return _size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the element at the specified position in
|
||||
* (optional operation). Any subsequent elements
|
||||
* are shifted to the left, subtracting one from their
|
||||
* indices. Returns the element that was removed.
|
||||
* By construction, the returned value will be
|
||||
* between {@link #MIN_VALUE} and {@link #MAX_VALUE}, inclusive.
|
||||
*
|
||||
* @param index the index of the element to remove
|
||||
* @return the value of the element that was removed
|
||||
*
|
||||
* @throws UnsupportedOperationException when this operation is not
|
||||
* supported
|
||||
* @throws IndexOutOfBoundsException if the specified index is out of range
|
||||
*/
|
||||
public long removeElementAt(int index) {
|
||||
checkRange(index);
|
||||
incrModCount();
|
||||
int oldval = _data[index];
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
}
|
||||
_size--;
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the element at the specified
|
||||
* position in me with the specified element
|
||||
* (optional operation).
|
||||
* Throws {@link IllegalArgumentException} if <i>element</i>
|
||||
* is less than {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}.
|
||||
*
|
||||
* @param index the index of the element to change
|
||||
* @param element the value to be stored at the specified position
|
||||
* @return the value previously stored at the specified position
|
||||
*
|
||||
* @throws UnsupportedOperationException when this operation is not
|
||||
* supported
|
||||
* @throws IndexOutOfBoundsException if the specified index is out of range
|
||||
*/
|
||||
public long set(int index, long element) {
|
||||
assertValidUnsignedInt(element);
|
||||
checkRange(index);
|
||||
incrModCount();
|
||||
long oldval = toLong(_data[index]);
|
||||
_data[index] = fromLong(element);
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the specified element at the specified position
|
||||
* (optional operation). Shifts the element currently
|
||||
* at that position (if any) and any subsequent elements to the
|
||||
* right, increasing their indices.
|
||||
* Throws {@link IllegalArgumentException} if <i>element</i>
|
||||
* is less than {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}.
|
||||
*
|
||||
* @param index the index at which to insert the element
|
||||
* @param element the value to insert
|
||||
*
|
||||
* @throws UnsupportedOperationException when this operation is not
|
||||
* supported
|
||||
* @throws IllegalArgumentException if some aspect of the specified element
|
||||
* prevents it from being added to me
|
||||
* @throws IndexOutOfBoundsException if the specified index is out of range
|
||||
*/
|
||||
public void add(int index, long element) {
|
||||
assertValidUnsignedInt(element);
|
||||
checkRangeIncludingEndpoint(index);
|
||||
incrModCount();
|
||||
ensureCapacity(_size+1);
|
||||
int numtomove = _size-index;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromLong(element);
|
||||
_size++;
|
||||
}
|
||||
|
||||
// capacity methods
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Increases my capacity, if necessary, to ensure that I can hold at
|
||||
* least the number of elements specified by the minimum capacity
|
||||
* argument without growing.
|
||||
*/
|
||||
public void ensureCapacity(int mincap) {
|
||||
incrModCount();
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
int[] olddata = _data;
|
||||
_data = new int[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce my capacity, if necessary, to match my
|
||||
* current {@link #size size}.
|
||||
*/
|
||||
public void trimToSize() {
|
||||
incrModCount();
|
||||
if(_size < _data.length) {
|
||||
int[] olddata = _data;
|
||||
_data = new int[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
// private methods
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
private final long toLong(int value) {
|
||||
return ((long)value)&MAX_VALUE;
|
||||
}
|
||||
|
||||
private final int fromLong(long value) {
|
||||
return (int)(value&MAX_VALUE);
|
||||
}
|
||||
|
||||
private final void assertValidUnsignedInt(long value) throws IllegalArgumentException {
|
||||
if(value > MAX_VALUE) {
|
||||
throw new IllegalArgumentException(value + " > " + MAX_VALUE);
|
||||
}
|
||||
if(value < MIN_VALUE) {
|
||||
throw new IllegalArgumentException(value + " < " + MIN_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException{
|
||||
out.defaultWriteObject();
|
||||
out.writeInt(_data.length);
|
||||
for(int i=0;i<_size;i++) {
|
||||
out.writeInt(_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
_data = new int[in.readInt()];
|
||||
for(int i=0;i<_size;i++) {
|
||||
_data[i] = in.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
private final void checkRange(int index) {
|
||||
if(index < 0 || index >= _size) {
|
||||
throw new IndexOutOfBoundsException("Should be at least 0 and less than " + _size + ", found " + index);
|
||||
}
|
||||
}
|
||||
|
||||
private final void checkRangeIncludingEndpoint(int index) {
|
||||
if(index < 0 || index > _size) {
|
||||
throw new IndexOutOfBoundsException("Should be at least 0 and at most " + _size + ", found " + index);
|
||||
}
|
||||
}
|
||||
|
||||
// attributes
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The maximum possible unsigned 32-bit value.
|
||||
*/
|
||||
public static final long MAX_VALUE = 0xFFFFFFFFL;
|
||||
|
||||
/**
|
||||
* The minimum possible unsigned 32-bit value.
|
||||
*/
|
||||
public static final long MIN_VALUE = 0L;
|
||||
|
||||
private transient int[] _data = null;
|
||||
private int _size = 0;
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedIntArrayList.java,v 1.8 2003/01/11 21:28:02 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedIntArrayList.java,v 1.9 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -71,8 +71,9 @@ import java.io.Serializable;
|
||||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.8 $ $Date: 2003/01/11 21:28:02 $
|
||||
* @version $Revision: 1.9 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
* @deprecated use ArrayUnsignedIntList or another LongList implementation instead.
|
||||
*/
|
||||
public class UnsignedIntArrayList extends AbstractLongArrayList implements Serializable {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestAbstractIntArrayList.java,v 1.6 2003/03/05 19:10:50 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestAbstractIntArrayList.java,v 1.7 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -62,8 +62,9 @@ import java.util.List;
|
||||
import org.apache.commons.collections.TestList;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.6 $ $Date: 2003/03/05 19:10:50 $
|
||||
* @version $Revision: 1.7 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
* @deprecated as the tested classes are deprecated also
|
||||
*/
|
||||
public abstract class TestAbstractIntArrayList extends TestList {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestAll.java,v 1.10 2003/04/08 18:24:34 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestAll.java,v 1.11 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -62,7 +62,7 @@ import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.10 $ $Date: 2003/04/08 18:24:34 $
|
||||
* @version $Revision: 1.11 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestAll extends TestCase {
|
||||
@ -86,6 +86,7 @@ public class TestAll extends TestCase {
|
||||
suite.addTest(TestAbstractLongCollection.suite());
|
||||
suite.addTest(TestAbstractRandomAccessLongList.suite());
|
||||
suite.addTest(TestArrayLongList.suite());
|
||||
suite.addTest(TestArrayUnsignedIntList.suite());
|
||||
|
||||
suite.addTest(org.apache.commons.collections.primitives.adapters.TestAll.suite());
|
||||
|
||||
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestArrayUnsignedIntList.java,v 1.1 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||
* Foundation" must not be used to endorse or promote products derived
|
||||
* from this software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache"
|
||||
* nor may "Apache" appear in their names without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections.primitives;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.1 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestArrayUnsignedIntList extends TestLongList {
|
||||
|
||||
// conventional
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public TestArrayUnsignedIntList(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = BulkTest.makeSuite(TestArrayUnsignedIntList.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
// collections testing framework
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
protected LongList makeEmptyLongList() {
|
||||
return new ArrayUnsignedIntList();
|
||||
}
|
||||
|
||||
public String[] ignoredSimpleTests() {
|
||||
// sublists are not serializable
|
||||
return new String[] {
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testFullListSerialization",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testEmptyListSerialization",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testCanonicalEmptyCollectionExists",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testCanonicalFullCollectionExists",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testEmptyListCompatibility",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testFullListCompatibility",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testSerializeDeserializeThenCompare",
|
||||
"TestArrayUnsignedLongList.bulkTestSubList.testSimpleSerialization"
|
||||
};
|
||||
}
|
||||
|
||||
protected long[] getFullLongs() {
|
||||
long[] result = new long[19];
|
||||
for(int i = 0; i < result.length; i++) {
|
||||
result[i] = ((long)Integer.MAX_VALUE - 1L - (long)i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// tests
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// @TODO need to add serialized form to cvs
|
||||
public void testCanonicalEmptyCollectionExists() {
|
||||
// XXX FIX ME XXX
|
||||
// need to add a serialized form to cvs
|
||||
}
|
||||
|
||||
public void testCanonicalFullCollectionExists() {
|
||||
// XXX FIX ME XXX
|
||||
// need to add a serialized form to cvs
|
||||
}
|
||||
|
||||
public void testEmptyListCompatibility() {
|
||||
// XXX FIX ME XXX
|
||||
// need to add a serialized form to cvs
|
||||
}
|
||||
|
||||
public void testFullListCompatibility() {
|
||||
// XXX FIX ME XXX
|
||||
// need to add a serialized form to cvs
|
||||
}
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
ArrayUnsignedIntList list = new ArrayUnsignedIntList(0);
|
||||
}
|
||||
|
||||
public void testIllegalArgumentExceptionWhenElementOutOfRange() {
|
||||
ArrayUnsignedIntList list = new ArrayUnsignedIntList();
|
||||
list.add(ArrayUnsignedIntList.MIN_VALUE);
|
||||
list.add(ArrayUnsignedIntList.MAX_VALUE);
|
||||
try {
|
||||
list.add(-1);
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
list.add(ArrayUnsignedIntList.MAX_VALUE+1);
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testNegativeInitialCapacityIsInvalid() {
|
||||
try {
|
||||
ArrayUnsignedIntList list = new ArrayUnsignedIntList(-1);
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testCopyConstructor() {
|
||||
ArrayUnsignedIntList expected = new ArrayUnsignedIntList();
|
||||
for(int i=0;i<10;i++) {
|
||||
expected.add(i);
|
||||
}
|
||||
ArrayUnsignedIntList list = new ArrayUnsignedIntList(expected);
|
||||
assertEquals(10,list.size());
|
||||
assertEquals(expected,list);
|
||||
}
|
||||
|
||||
public void testCopyConstructorWithNull() {
|
||||
try {
|
||||
ArrayUnsignedIntList list = new ArrayUnsignedIntList(null);
|
||||
fail("Expected NullPointerException");
|
||||
} catch(NullPointerException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testTrimToSize() {
|
||||
ArrayUnsignedIntList list = new ArrayUnsignedIntList();
|
||||
for(int j=0;j<3;j++) {
|
||||
assertTrue(list.isEmpty());
|
||||
|
||||
list.trimToSize();
|
||||
|
||||
assertTrue(list.isEmpty());
|
||||
|
||||
for(int i=0;i<10;i++) {
|
||||
list.add(i);
|
||||
}
|
||||
|
||||
for(int i=0;i<10;i++) {
|
||||
assertEquals(i,list.get(i));
|
||||
}
|
||||
|
||||
list.trimToSize();
|
||||
|
||||
for(int i=0;i<10;i++) {
|
||||
assertEquals(i,list.get(i));
|
||||
}
|
||||
|
||||
for(int i=0;i<10;i+=2) {
|
||||
list.removeElement(i);
|
||||
}
|
||||
|
||||
for(int i=0;i<5;i++) {
|
||||
assertEquals((2*i)+1,list.get(i));
|
||||
}
|
||||
|
||||
list.trimToSize();
|
||||
|
||||
for(int i=0;i<5;i++) {
|
||||
assertEquals((2*i)+1,list.get(i));
|
||||
}
|
||||
|
||||
list.trimToSize();
|
||||
|
||||
for(int i=0;i<5;i++) {
|
||||
assertEquals((2*i)+1,list.get(i));
|
||||
}
|
||||
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntArrayList.java,v 1.6 2003/01/12 15:23:20 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntArrayList.java,v 1.7 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -63,8 +63,9 @@ import junit.framework.TestSuite;
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.6 $ $Date: 2003/01/12 15:23:20 $
|
||||
* @version $Revision: 1.7 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
* @deprecated as the tested classes are deprecated also
|
||||
*/
|
||||
public class TestIntArrayList extends TestAbstractIntArrayList {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestLongArrayList.java,v 1.6 2003/01/12 15:23:20 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestLongArrayList.java,v 1.7 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -63,8 +63,9 @@ import junit.framework.TestSuite;
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.6 $ $Date: 2003/01/12 15:23:20 $
|
||||
* @version $Revision: 1.7 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
* @deprecated as the tested classes are deprecated also
|
||||
*/
|
||||
public class TestLongArrayList extends TestAbstractLongArrayList {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedIntArrayList.java,v 1.6 2003/01/12 15:23:20 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedIntArrayList.java,v 1.7 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -63,8 +63,9 @@ import junit.framework.TestSuite;
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.6 $ $Date: 2003/01/12 15:23:20 $
|
||||
* @version $Revision: 1.7 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
* @deprecated as the tested classes are deprecated also
|
||||
*/
|
||||
public class TestUnsignedIntArrayList extends TestAbstractLongArrayList {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedShortArrayList.java,v 1.6 2003/01/12 15:23:20 rwaldhoff Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedShortArrayList.java,v 1.7 2003/04/09 06:44:34 rwaldhoff Exp $
|
||||
* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
@ -63,8 +63,9 @@ import junit.framework.TestSuite;
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.6 $ $Date: 2003/01/12 15:23:20 $
|
||||
* @version $Revision: 1.7 $ $Date: 2003/04/09 06:44:34 $
|
||||
* @author Rodney Waldhoff
|
||||
* @deprecated as the tested classes are deprecated also
|
||||
*/
|
||||
public class TestUnsignedShortArrayList extends TestAbstractIntArrayList {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user