Remove "filling" in IntList as this has no effect whatsoever as far as I could see
Fix some IntelliJ warnings, missing JavaDoc, typos, Findbugs issues git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1811793 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a21c09fd61
commit
673b223f61
@ -202,15 +202,12 @@ public class CustomProperties implements Map<String,Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof CustomProperties)) {
|
return obj instanceof CustomProperties && props.equals(((CustomProperties) obj).props);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return props.equals(((CustomProperties)obj).props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(Map<? extends String, ? extends Object> m) {
|
public void putAll(Map<? extends String, ?> m) {
|
||||||
for (Map.Entry<? extends String, ? extends Object> me : m.entrySet()) {
|
for (Map.Entry<? extends String, ?> me : m.entrySet()) {
|
||||||
put(me.getKey(), me.getValue());
|
put(me.getKey(), me.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,7 +362,7 @@ public class CustomProperties implements Map<String,Object> {
|
|||||||
* <li>Otherwise find the highest ID and use its value plus one.
|
* <li>Otherwise find the highest ID and use its value plus one.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param customProperty
|
* @param customProperty The {@link CustomProperty} to add.
|
||||||
* @return If there was already a property with the same name, the old property
|
* @return If there was already a property with the same name, the old property
|
||||||
* @throws ClassCastException
|
* @throws ClassCastException
|
||||||
*/
|
*/
|
||||||
|
@ -754,8 +754,8 @@ public class PropertySet {
|
|||||||
* #getPropertyIntValue} or {@link #getProperty} tried to access
|
* #getPropertyIntValue} or {@link #getProperty} tried to access
|
||||||
* was available or not. This information might be important for
|
* was available or not. This information might be important for
|
||||||
* callers of {@link #getPropertyIntValue} since the latter
|
* callers of {@link #getPropertyIntValue} since the latter
|
||||||
* returns 0 if the property does not exist. Using {@link
|
* returns 0 if the property does not exist. Using wasNull,
|
||||||
* #wasNull}, the caller can distiguish this case from a
|
* the caller can distinguish this case from a
|
||||||
* property's real value of 0.
|
* property's real value of 0.
|
||||||
*
|
*
|
||||||
* @return {@code true} if the last call to {@link
|
* @return {@code true} if the last call to {@link
|
||||||
|
@ -516,10 +516,7 @@ public class Section {
|
|||||||
*/
|
*/
|
||||||
protected boolean getPropertyBooleanValue(final int id) {
|
protected boolean getPropertyBooleanValue(final int id) {
|
||||||
final Boolean b = (Boolean) getProperty(id);
|
final Boolean b = (Boolean) getProperty(id);
|
||||||
if (b == null) {
|
return b != null && b.booleanValue();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return b.booleanValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -560,8 +557,8 @@ public class Section {
|
|||||||
* properties) and the properties themselves.
|
* properties) and the properties themselves.
|
||||||
*
|
*
|
||||||
* @return the section's length in bytes.
|
* @return the section's length in bytes.
|
||||||
* @throws WritingNotSupportedException
|
* @throws WritingNotSupportedException If the document is opened read-only.
|
||||||
* @throws IOException
|
* @throws IOException If an error happens while writing.
|
||||||
*/
|
*/
|
||||||
private int calcSize() throws WritingNotSupportedException, IOException {
|
private int calcSize() throws WritingNotSupportedException, IOException {
|
||||||
sectionBytes.reset();
|
sectionBytes.reset();
|
||||||
@ -765,9 +762,6 @@ public class Section {
|
|||||||
* property. */
|
* property. */
|
||||||
position += p.write(propertyStream, codepage);
|
position += p.write(propertyStream, codepage);
|
||||||
} else {
|
} else {
|
||||||
if (codepage == -1) {
|
|
||||||
throw new IllegalPropertySetDataException("Codepage (property 1) is undefined.");
|
|
||||||
}
|
|
||||||
position += writeDictionary(propertyStream, codepage);
|
position += writeDictionary(propertyStream, codepage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -865,7 +859,6 @@ public class Section {
|
|||||||
* Writes the section's dictionary.
|
* Writes the section's dictionary.
|
||||||
*
|
*
|
||||||
* @param out The output stream to write to.
|
* @param out The output stream to write to.
|
||||||
* @param dictionary The dictionary.
|
|
||||||
* @param codepage The codepage to be used to write the dictionary items.
|
* @param codepage The codepage to be used to write the dictionary items.
|
||||||
* @return The number of bytes written
|
* @return The number of bytes written
|
||||||
* @exception IOException if an I/O exception occurs.
|
* @exception IOException if an I/O exception occurs.
|
||||||
@ -956,8 +949,8 @@ public class Section {
|
|||||||
long hashCode = 0;
|
long hashCode = 0;
|
||||||
hashCode += getFormatID().hashCode();
|
hashCode += getFormatID().hashCode();
|
||||||
final Property[] pa = getProperties();
|
final Property[] pa = getProperties();
|
||||||
for (int i = 0; i < pa.length; i++) {
|
for (Property aPa : pa) {
|
||||||
hashCode += pa[i].hashCode();
|
hashCode += aPa.hashCode();
|
||||||
}
|
}
|
||||||
return (int) (hashCode & 0x0ffffffffL);
|
return (int) (hashCode & 0x0ffffffffL);
|
||||||
}
|
}
|
||||||
@ -973,7 +966,7 @@ public class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString(PropertyIDMap idMap) {
|
public String toString(PropertyIDMap idMap) {
|
||||||
final StringBuffer b = new StringBuffer();
|
final StringBuilder b = new StringBuilder();
|
||||||
final Property[] pa = getProperties();
|
final Property[] pa = getProperties();
|
||||||
b.append("\n\n\n");
|
b.append("\n\n\n");
|
||||||
b.append(getClass().getName());
|
b.append(getClass().getName());
|
||||||
|
@ -96,7 +96,8 @@ public class DataValidationEvaluator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazy load validations by sheet, since reading the CT* types is expensive
|
* Lazy load validations by sheet, since reading the CT* types is expensive
|
||||||
* @param sheet
|
*
|
||||||
|
* @param sheet The {@link Sheet} to load validations for.
|
||||||
* @return The {@link DataValidation}s for the sheet
|
* @return The {@link DataValidation}s for the sheet
|
||||||
*/
|
*/
|
||||||
private List<? extends DataValidation> getValidations(Sheet sheet) {
|
private List<? extends DataValidation> getValidations(Sheet sheet) {
|
||||||
@ -250,8 +251,9 @@ public class DataValidationEvaluator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Note that this assumes the cell cached value is up to date and in sync with data edits
|
* Note that this assumes the cell cached value is up to date and in sync with data edits
|
||||||
* @param cell
|
*
|
||||||
* @param type
|
* @param cell The {@link Cell} to check.
|
||||||
|
* @param type The {@link CellType} to check for.
|
||||||
* @return true if the cell or cached cell formula result type match the given type
|
* @return true if the cell or cached cell formula result type match the given type
|
||||||
*/
|
*/
|
||||||
public static boolean isType(Cell cell, CellType type) {
|
public static boolean isType(Cell cell, CellType type) {
|
||||||
@ -278,7 +280,7 @@ public class DataValidationEvaluator {
|
|||||||
if (super.isValidValue(cell, context)) {
|
if (super.isValidValue(cell, context)) {
|
||||||
// we know it is a number in the proper range, now check if it is an int
|
// we know it is a number in the proper range, now check if it is an int
|
||||||
final double value = cell.getNumericCellValue(); // can't get here without a valid numeric value
|
final double value = cell.getNumericCellValue(); // can't get here without a valid numeric value
|
||||||
return Double.valueOf(value).compareTo(Double.valueOf((int) value)) == 0;
|
return Double.compare(value, (int) value) == 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -342,7 +344,7 @@ public class DataValidationEvaluator {
|
|||||||
/**
|
/**
|
||||||
* Note the formula result must either be a boolean result, or anything not in error.
|
* Note the formula result must either be a boolean result, or anything not in error.
|
||||||
* If boolean, value must be true to pass, anything else valid is also passing, errors fail.
|
* If boolean, value must be true to pass, anything else valid is also passing, errors fail.
|
||||||
* @see org.apache.poi.ss.formula.DataValidationEvaluator.ValidationEnum#isValidValue(org.apache.poi.ss.usermodel.Cell, org.apache.poi.ss.usermodel.DataValidationConstraint, org.apache.poi.ss.formula.WorkbookEvaluator)
|
* @see org.apache.poi.ss.formula.DataValidationEvaluator.ValidationEnum#isValidValue(Cell, DataValidationContext)
|
||||||
*/
|
*/
|
||||||
public boolean isValidValue(Cell cell, DataValidationContext context) {
|
public boolean isValidValue(Cell cell, DataValidationContext context) {
|
||||||
// unwrapped single value
|
// unwrapped single value
|
||||||
@ -409,8 +411,9 @@ public class DataValidationEvaluator {
|
|||||||
* Evaluate a numeric formula value as either a constant or numeric expression.
|
* Evaluate a numeric formula value as either a constant or numeric expression.
|
||||||
* Note that Excel treats validations with constraint formulas that evaluate to null as valid,
|
* Note that Excel treats validations with constraint formulas that evaluate to null as valid,
|
||||||
* but evaluations in error or non-numeric are marked invalid.
|
* but evaluations in error or non-numeric are marked invalid.
|
||||||
* @param formula
|
*
|
||||||
* @param context
|
* @param formula The text of the formula or a numeric value
|
||||||
|
* @param context The {@link DataValidationContext} which is used for evaluation
|
||||||
* @return numeric value or null if not defined or the formula evaluates to an empty/missing cell.
|
* @return numeric value or null if not defined or the formula evaluates to an empty/missing cell.
|
||||||
* @throws NumberFormatException if the formula is non-numeric when it should be
|
* @throws NumberFormatException if the formula is non-numeric when it should be
|
||||||
*/
|
*/
|
||||||
@ -522,11 +525,7 @@ public class DataValidationEvaluator {
|
|||||||
private final CellReference target;
|
private final CellReference target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Populate the context with the necessary values.
|
||||||
* @param dv
|
|
||||||
* @param dve
|
|
||||||
* @param region
|
|
||||||
* @param target
|
|
||||||
*/
|
*/
|
||||||
public DataValidationContext(DataValidation dv, DataValidationEvaluator dve, CellRangeAddressBase region, CellReference target) {
|
public DataValidationContext(DataValidation dv, DataValidationEvaluator dve, CellRangeAddressBase region, CellReference target) {
|
||||||
this.dv = dv;
|
this.dv = dv;
|
||||||
|
@ -47,7 +47,6 @@ public class IntList
|
|||||||
{
|
{
|
||||||
private int[] _array;
|
private int[] _array;
|
||||||
private int _limit;
|
private int _limit;
|
||||||
private int fillval;
|
|
||||||
private static final int _default_size = 128;
|
private static final int _default_size = 128;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +60,8 @@ public class IntList
|
|||||||
|
|
||||||
public IntList(final int initialCapacity)
|
public IntList(final int initialCapacity)
|
||||||
{
|
{
|
||||||
this(initialCapacity,0);
|
_array = new int[ initialCapacity ];
|
||||||
|
_limit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,29 +79,7 @@ public class IntList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create an IntList with a predefined initial size
|
* add the specified value at the specified index
|
||||||
*
|
|
||||||
* @param initialCapacity the size for the internal array
|
|
||||||
*/
|
|
||||||
|
|
||||||
public IntList(final int initialCapacity, int fillvalue)
|
|
||||||
{
|
|
||||||
_array = new int[ initialCapacity ];
|
|
||||||
if (fillval != 0) {
|
|
||||||
fillval = fillvalue;
|
|
||||||
fillArray(fillval, _array, 0);
|
|
||||||
}
|
|
||||||
_limit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillArray(int val, int[] array, int index) {
|
|
||||||
for (int k = index; k < array.length; k++) {
|
|
||||||
array[k] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add the specfied value at the specified index
|
|
||||||
*
|
*
|
||||||
* @param index the index where the new value is to be added
|
* @param index the index where the new value is to be added
|
||||||
* @param value the new value
|
* @param value the new value
|
||||||
@ -651,12 +629,7 @@ public class IntList
|
|||||||
: new_size;
|
: new_size;
|
||||||
int[] new_array = new int[ size ];
|
int[] new_array = new int[ size ];
|
||||||
|
|
||||||
if (fillval != 0) {
|
|
||||||
fillArray(fillval, new_array, _array.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.arraycopy(_array, 0, new_array, 0, _limit);
|
System.arraycopy(_array, 0, new_array, 0, _limit);
|
||||||
_array = new_array;
|
_array = new_array;
|
||||||
}
|
}
|
||||||
} // end public class IntList
|
}
|
||||||
|
|
||||||
|
@ -63,15 +63,14 @@ public final class FileHelper {
|
|||||||
* If an I/O error occur.
|
* If an I/O error occur.
|
||||||
*/
|
*/
|
||||||
public static void copyFile(File in, File out) throws IOException {
|
public static void copyFile(File in, File out) throws IOException {
|
||||||
FileInputStream fis = new FileInputStream(in);
|
try (FileInputStream fis = new FileInputStream(in);
|
||||||
FileOutputStream fos = new FileOutputStream(out);
|
FileOutputStream fos = new FileOutputStream(out);
|
||||||
FileChannel sourceChannel = fis.getChannel();
|
FileChannel sourceChannel = fis.getChannel();
|
||||||
FileChannel destinationChannel = fos.getChannel();
|
FileChannel destinationChannel = fos.getChannel()) {
|
||||||
|
|
||||||
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
|
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
|
||||||
sourceChannel.close();
|
sourceChannel.close();
|
||||||
destinationChannel.close();
|
}
|
||||||
fos.close();
|
|
||||||
fis.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,5 +89,4 @@ public final class FileHelper {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,33 +17,23 @@
|
|||||||
|
|
||||||
package org.apache.poi.hwpf.model;
|
package org.apache.poi.hwpf.model;
|
||||||
|
|
||||||
import static org.apache.poi.POITestCase.assertReflectEquals;
|
|
||||||
|
|
||||||
import org.apache.poi.hwpf.HWPFDocFixture;
|
import org.apache.poi.hwpf.HWPFDocFixture;
|
||||||
import org.apache.poi.hwpf.model.types.DOPAbstractType;
|
import org.apache.poi.hwpf.model.types.DOPAbstractType;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.apache.poi.POITestCase.assertReflectEquals;
|
||||||
|
|
||||||
// TODO: Add DocumentProperties#equals ???
|
// TODO: Add DocumentProperties#equals ???
|
||||||
|
|
||||||
public final class TestDocumentProperties {
|
public final class TestDocumentProperties {
|
||||||
private DocumentProperties _documentProperties;
|
private DocumentProperties _documentProperties;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testReadWrite() throws Exception {
|
|
||||||
int size = DOPAbstractType.getSize();
|
|
||||||
byte[] buf = new byte[size];
|
|
||||||
_documentProperties.serialize(buf, 0);
|
|
||||||
DocumentProperties newDocProperties = new DocumentProperties(buf, 0, size);
|
|
||||||
|
|
||||||
assertReflectEquals(_documentProperties, newDocProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
/** TODO verify the constructors*/
|
// TODO verify the constructors
|
||||||
_hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
|
_hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
|
||||||
_hWPFDocFixture.setUp();
|
_hWPFDocFixture.setUp();
|
||||||
_documentProperties = new DocumentProperties(_hWPFDocFixture._tableStream, _hWPFDocFixture._fib.getFcDop(), _hWPFDocFixture._fib.getLcbDop());
|
_documentProperties = new DocumentProperties(_hWPFDocFixture._tableStream, _hWPFDocFixture._fib.getFcDop(), _hWPFDocFixture._fib.getLcbDop());
|
||||||
@ -55,4 +45,14 @@ public final class TestDocumentProperties {
|
|||||||
_hWPFDocFixture.tearDown();
|
_hWPFDocFixture.tearDown();
|
||||||
_hWPFDocFixture = null;
|
_hWPFDocFixture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadWrite() throws Exception {
|
||||||
|
int size = DOPAbstractType.getSize();
|
||||||
|
byte[] buf = new byte[size];
|
||||||
|
_documentProperties.serialize(buf, 0);
|
||||||
|
DocumentProperties newDocProperties = new DocumentProperties(buf, 0, size);
|
||||||
|
|
||||||
|
assertReflectEquals(_documentProperties, newDocProperties);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,21 @@
|
|||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test IntList
|
* Class to test IntList
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
public final class TestIntList extends TestCase {
|
public final class TestIntList {
|
||||||
|
@Test
|
||||||
public void testConstructors() {
|
public void testConstructors() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -40,6 +46,7 @@ public final class TestIntList extends TestCase {
|
|||||||
assertTrue(list3.isEmpty());
|
assertTrue(list3.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAdd() {
|
public void testAdd() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
int[] testArray =
|
int[] testArray =
|
||||||
@ -117,6 +124,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAddAll() {
|
public void testAddAll() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -191,6 +199,17 @@ public final class TestIntList extends TestCase {
|
|||||||
assertEquals(list.get(4), empty.get(14));
|
assertEquals(list.get(4), empty.get(14));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddAllGrow() {
|
||||||
|
IntList list = new IntList(0);
|
||||||
|
IntList addList = new IntList(0);
|
||||||
|
addList.add(1);
|
||||||
|
addList.add(2);
|
||||||
|
|
||||||
|
assertTrue(list.addAll(0, addList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testClear() {
|
public void testClear() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -212,6 +231,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testContains() {
|
public void testContains() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -227,11 +247,12 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue(!list.contains(j));
|
assertFalse(list.contains(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testContainsAll() {
|
public void testContainsAll() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -246,18 +267,19 @@ public final class TestIntList extends TestCase {
|
|||||||
assertTrue(list.containsAll(list2));
|
assertTrue(list.containsAll(list2));
|
||||||
list2.add(10);
|
list2.add(10);
|
||||||
assertTrue(list2.containsAll(list));
|
assertTrue(list2.containsAll(list));
|
||||||
assertTrue(!list.containsAll(list2));
|
assertFalse(list.containsAll(list2));
|
||||||
list.add(11);
|
list.add(11);
|
||||||
assertTrue(!list2.containsAll(list));
|
assertFalse(list2.containsAll(list));
|
||||||
assertTrue(!list.containsAll(list2));
|
assertFalse(list.containsAll(list2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testEquals() {
|
public void testEquals() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
assertEquals(list, list);
|
assertEquals(list, list);
|
||||||
//noinspection ObjectEqualsNull
|
//noinspection ObjectEqualsNull
|
||||||
assertTrue(!list.equals(null));
|
assertFalse(list.equals(null));
|
||||||
IntList list2 = new IntList(200);
|
IntList list2 = new IntList(200);
|
||||||
|
|
||||||
assertEquals(list, list2);
|
assertEquals(list, list2);
|
||||||
@ -267,16 +289,18 @@ public final class TestIntList extends TestCase {
|
|||||||
list.add(1);
|
list.add(1);
|
||||||
list2.add(1);
|
list2.add(1);
|
||||||
list2.add(0);
|
list2.add(0);
|
||||||
assertTrue(!list.equals(list2));
|
assertFalse(list.equals(list2));
|
||||||
list2.removeValue(1);
|
list2.removeValue(1);
|
||||||
list2.add(1);
|
list2.add(1);
|
||||||
assertEquals(list, list2);
|
assertEquals(list, list2);
|
||||||
assertEquals(list2, list);
|
assertEquals(list2, list);
|
||||||
|
assertEquals(list.hashCode(), list2.hashCode());
|
||||||
list2.add(2);
|
list2.add(2);
|
||||||
assertTrue(!list.equals(list2));
|
assertFalse(list.equals(list2));
|
||||||
assertTrue(!list2.equals(list));
|
assertFalse(list2.equals(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGet() {
|
public void testGet() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -304,6 +328,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testIndexOf() {
|
public void testIndexOf() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -324,6 +349,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testIsEmpty() {
|
public void testIsEmpty() {
|
||||||
IntList list1 = new IntList();
|
IntList list1 = new IntList();
|
||||||
IntList list2 = new IntList(1000);
|
IntList list2 = new IntList(1000);
|
||||||
@ -335,9 +361,9 @@ public final class TestIntList extends TestCase {
|
|||||||
list1.add(1);
|
list1.add(1);
|
||||||
list2.add(2);
|
list2.add(2);
|
||||||
list3 = new IntList(list2);
|
list3 = new IntList(list2);
|
||||||
assertTrue(!list1.isEmpty());
|
assertFalse(list1.isEmpty());
|
||||||
assertTrue(!list2.isEmpty());
|
assertFalse(list2.isEmpty());
|
||||||
assertTrue(!list3.isEmpty());
|
assertFalse(list3.isEmpty());
|
||||||
list1.clear();
|
list1.clear();
|
||||||
list2.remove(0);
|
list2.remove(0);
|
||||||
list3.removeValue(2);
|
list3.removeValue(2);
|
||||||
@ -346,6 +372,7 @@ public final class TestIntList extends TestCase {
|
|||||||
assertTrue(list3.isEmpty());
|
assertTrue(list3.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLastIndexOf() {
|
public void testLastIndexOf() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -366,6 +393,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRemove() {
|
public void testRemove() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -399,6 +427,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRemoveValue() {
|
public void testRemoveValue() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -413,10 +442,11 @@ public final class TestIntList extends TestCase {
|
|||||||
assertTrue(list.removeValue(j));
|
assertTrue(list.removeValue(j));
|
||||||
assertTrue(list.removeValue(j));
|
assertTrue(list.removeValue(j));
|
||||||
}
|
}
|
||||||
assertTrue(!list.removeValue(j));
|
assertFalse(list.removeValue(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRemoveAll() {
|
public void testRemoveAll() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -439,16 +469,26 @@ public final class TestIntList extends TestCase {
|
|||||||
listOdd.add(j);
|
listOdd.add(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.removeAll(listEven);
|
|
||||||
|
assertTrue(list.removeAll(listEven));
|
||||||
assertEquals(list, listOdd);
|
assertEquals(list, listOdd);
|
||||||
list.removeAll(listOdd);
|
|
||||||
|
assertTrue(list.removeAll(listOdd));
|
||||||
assertTrue(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
listCopy.removeAll(listOdd);
|
|
||||||
|
assertTrue(listCopy.removeAll(listOdd));
|
||||||
assertEquals(listCopy, listEven);
|
assertEquals(listCopy, listEven);
|
||||||
listCopy.removeAll(listEven);
|
|
||||||
|
assertTrue(listCopy.removeAll(listEven));
|
||||||
assertTrue(listCopy.isEmpty());
|
assertTrue(listCopy.isEmpty());
|
||||||
|
|
||||||
|
assertFalse(list.removeAll(listEven));
|
||||||
|
assertFalse(list.removeAll(listOdd));
|
||||||
|
assertFalse(listCopy.removeAll(listEven));
|
||||||
|
assertFalse(listCopy.removeAll(listEven));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRetainAll() {
|
public void testRetainAll() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -471,16 +511,25 @@ public final class TestIntList extends TestCase {
|
|||||||
listOdd.add(j);
|
listOdd.add(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.retainAll(listOdd);
|
assertTrue(list.retainAll(listOdd));
|
||||||
assertEquals(list, listOdd);
|
assertEquals(list, listOdd);
|
||||||
list.retainAll(listEven);
|
|
||||||
|
assertTrue(list.retainAll(listEven));
|
||||||
assertTrue(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
listCopy.retainAll(listEven);
|
|
||||||
|
assertTrue(listCopy.retainAll(listEven));
|
||||||
assertEquals(listCopy, listEven);
|
assertEquals(listCopy, listEven);
|
||||||
listCopy.retainAll(listOdd);
|
|
||||||
|
assertTrue(listCopy.retainAll(listOdd));
|
||||||
assertTrue(listCopy.isEmpty());
|
assertTrue(listCopy.isEmpty());
|
||||||
|
|
||||||
|
assertFalse(list.retainAll(listOdd));
|
||||||
|
assertFalse(list.retainAll(listEven));
|
||||||
|
assertFalse(listCopy.retainAll(listEven));
|
||||||
|
assertFalse(listCopy.retainAll(listOdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSet() {
|
public void testSet() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -509,6 +558,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSize() {
|
public void testSize() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
@ -526,6 +576,7 @@ public final class TestIntList extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testToArray() {
|
public void testToArray() {
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user