Change all calls from assert() to assertTrue() -- introduced in JUnit 3.7
-- to avoid future conflicts with the JDK standard assertion capability. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130488 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4a2e49fd8d
commit
90e83728ac
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestArrayIterator.java,v 1.2 2001/06/05 07:20:10 jstrachan Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestArrayIterator.java,v 1.3 2001/07/14 23:33:26 craigmcc Exp $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2001/06/05 07:20:10 $
|
* $Date: 2001/07/14 23:33:26 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -72,7 +72,7 @@ import java.util.NoSuchElementException;
|
||||||
*
|
*
|
||||||
* @author James Strachan
|
* @author James Strachan
|
||||||
* @author Mauricio S. Moura
|
* @author Mauricio S. Moura
|
||||||
* @version $Id: TestArrayIterator.java,v 1.2 2001/06/05 07:20:10 jstrachan Exp $
|
* @version $Id: TestArrayIterator.java,v 1.3 2001/07/14 23:33:26 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestArrayIterator extends TestObject {
|
public class TestArrayIterator extends TestObject {
|
||||||
|
|
||||||
|
@ -104,12 +104,12 @@ public class TestArrayIterator extends TestObject {
|
||||||
assertEquals( "Iteration value is correct", testValue, iterValue );
|
assertEquals( "Iteration value is correct", testValue, iterValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
assert("Iterator should now be empty", ! iter.hasNext() );
|
assertTrue("Iterator should now be empty", ! iter.hasNext() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object testValue = iter.next();
|
Object testValue = iter.next();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assert("NoSuchElementException must be thrown",
|
assertTrue("NoSuchElementException must be thrown",
|
||||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayList.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayList.java,v 1.2 2001/07/14 23:33:26 craigmcc Exp $
|
||||||
* $Revision: 1.1 $
|
* $Revision: 1.2 $
|
||||||
* $Date: 2001/04/21 12:22:30 $
|
* $Date: 2001/07/14 23:33:26 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -69,7 +69,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
||||||
* @version $Id: TestArrayList.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $
|
* @version $Id: TestArrayList.java,v 1.2 2001/07/14 23:33:26 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestArrayList extends TestList
|
public class TestArrayList extends TestList
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ public class TestArrayList extends TestList
|
||||||
|
|
||||||
public void testNewArrayList()
|
public void testNewArrayList()
|
||||||
{
|
{
|
||||||
assert("New list is empty", list.isEmpty());
|
assertTrue("New list is empty", list.isEmpty());
|
||||||
assertEquals("New list has size zero", list.size(), 0);
|
assertEquals("New list has size zero", list.size(), 0);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayStack.java,v 1.4 2001/04/21 12:22:30 craigmcc Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayStack.java,v 1.5 2001/07/14 23:33:26 craigmcc Exp $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2001/04/21 12:22:30 $
|
* $Date: 2001/07/14 23:33:26 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -66,7 +66,7 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Craig McClanahan
|
* @author Craig McClanahan
|
||||||
* @version $Id: TestArrayStack.java,v 1.4 2001/04/21 12:22:30 craigmcc Exp $
|
* @version $Id: TestArrayStack.java,v 1.5 2001/07/14 23:33:26 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TestArrayStack extends TestArrayList {
|
public class TestArrayStack extends TestArrayList {
|
||||||
|
@ -97,7 +97,7 @@ public class TestArrayStack extends TestArrayList {
|
||||||
|
|
||||||
public void testNewStack() {
|
public void testNewStack() {
|
||||||
|
|
||||||
assert("New stack is empty", stack.empty());
|
assertTrue("New stack is empty", stack.empty());
|
||||||
assertEquals("New stack has size zero", stack.size(), 0);
|
assertEquals("New stack has size zero", stack.size(), 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -120,7 +120,7 @@ public class TestArrayStack extends TestArrayList {
|
||||||
public void testPushPeekPop() {
|
public void testPushPeekPop() {
|
||||||
|
|
||||||
stack.push("First Item");
|
stack.push("First Item");
|
||||||
assert("Stack is not empty", !stack.empty());
|
assertTrue("Stack is not empty", !stack.empty());
|
||||||
assertEquals("Stack size is one", stack.size(), 1);
|
assertEquals("Stack size is one", stack.size(), 1);
|
||||||
assertEquals("Top item is 'First Item'",
|
assertEquals("Top item is 'First Item'",
|
||||||
(String) stack.peek(), "First Item");
|
(String) stack.peek(), "First Item");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestCollection.java,v 1.4 2001/04/24 23:48:04 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestCollection.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2001/04/24 23:48:04 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -78,7 +78,7 @@ import java.util.NoSuchElementException;
|
||||||
* test case (method) your {@link Collection} fails.
|
* test case (method) your {@link Collection} fails.
|
||||||
*
|
*
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @version $Id: TestCollection.java,v 1.4 2001/04/24 23:48:04 rwaldhoff Exp $
|
* @version $Id: TestCollection.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class TestCollection extends TestObject {
|
public abstract class TestCollection extends TestObject {
|
||||||
public TestCollection(String testName) {
|
public TestCollection(String testName) {
|
||||||
|
@ -138,13 +138,13 @@ public abstract class TestCollection extends TestObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cleared) {
|
if(cleared) {
|
||||||
assert("After Collection.clear(), Collection.isEmpty() should be true.",c.isEmpty());
|
assertTrue("After Collection.clear(), Collection.isEmpty() should be true.",c.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean added = tryToAdd(c,"element1");
|
boolean added = tryToAdd(c,"element1");
|
||||||
|
|
||||||
if(added) {
|
if(added) {
|
||||||
assert("After element is added, Collection.isEmpty() should be false.",!c.isEmpty());
|
assertTrue("After element is added, Collection.isEmpty() should be false.",!c.isEmpty());
|
||||||
boolean cleared2 = false;
|
boolean cleared2 = false;
|
||||||
try {
|
try {
|
||||||
c.clear();
|
c.clear();
|
||||||
|
@ -156,41 +156,41 @@ public abstract class TestCollection extends TestObject {
|
||||||
fail("Collection.clear should only throw UnsupportedOperationException. Found " + t.toString());
|
fail("Collection.clear should only throw UnsupportedOperationException. Found " + t.toString());
|
||||||
}
|
}
|
||||||
if(cleared2) {
|
if(cleared2) {
|
||||||
assert("After Collection.clear(), Collection.isEmpty() should be true.",c.isEmpty());
|
assertTrue("After Collection.clear(), Collection.isEmpty() should be true.",c.isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCollectionContains() {
|
public void testCollectionContains() {
|
||||||
Collection c = makeCollection();
|
Collection c = makeCollection();
|
||||||
assert("Empty Collection shouldn't contain element.",!c.contains("element1"));
|
assertTrue("Empty Collection shouldn't contain element.",!c.contains("element1"));
|
||||||
boolean added1 = tryToAdd(c,"element1");
|
boolean added1 = tryToAdd(c,"element1");
|
||||||
assert("[1] If an element was added, it should be contained, if it wasn't, it shouldn't.",added1 == c.contains("element1"));
|
assertTrue("[1] If an element was added, it should be contained, if it wasn't, it shouldn't.",added1 == c.contains("element1"));
|
||||||
|
|
||||||
assert("Shouldn't be contained.",!c.contains("element2"));
|
assertTrue("Shouldn't be contained.",!c.contains("element2"));
|
||||||
boolean added2 = tryToAdd(c,"element2");
|
boolean added2 = tryToAdd(c,"element2");
|
||||||
assert("[2] If an element was added, it should be contained, if it wasn't, it shouldn't.",added1 == c.contains("element1"));
|
assertTrue("[2] If an element was added, it should be contained, if it wasn't, it shouldn't.",added1 == c.contains("element1"));
|
||||||
assert("[3] If an element was added, it should be contained, if it wasn't, it shouldn't.",added2 == c.contains("element2"));
|
assertTrue("[3] If an element was added, it should be contained, if it wasn't, it shouldn't.",added2 == c.contains("element2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCollectionContainsAll() {
|
public void testCollectionContainsAll() {
|
||||||
Collection c = makeCollection();
|
Collection c = makeCollection();
|
||||||
Collection col = new ArrayList();
|
Collection col = new ArrayList();
|
||||||
assert("Every Collection should contain all elements of an empty Collection.",c.containsAll(col));
|
assertTrue("Every Collection should contain all elements of an empty Collection.",c.containsAll(col));
|
||||||
col.add("element1");
|
col.add("element1");
|
||||||
assert("Empty Collection shouldn't contain all elements of a non-empty Collection.",!c.containsAll(col));
|
assertTrue("Empty Collection shouldn't contain all elements of a non-empty Collection.",!c.containsAll(col));
|
||||||
|
|
||||||
boolean added1 = tryToAdd(c,"element1");
|
boolean added1 = tryToAdd(c,"element1");
|
||||||
if(added1) {
|
if(added1) {
|
||||||
assert("[1] Should contain all.",c.containsAll(col));
|
assertTrue("[1] Should contain all.",c.containsAll(col));
|
||||||
}
|
}
|
||||||
|
|
||||||
col.add("element2");
|
col.add("element2");
|
||||||
assert("Shouldn't contain all.",!c.containsAll(col));
|
assertTrue("Shouldn't contain all.",!c.containsAll(col));
|
||||||
|
|
||||||
boolean added2 = tryToAdd(c,"element2");
|
boolean added2 = tryToAdd(c,"element2");
|
||||||
if(added1 && added2) {
|
if(added1 && added2) {
|
||||||
assert("[2] Should contain all.",c.containsAll(col));
|
assertTrue("[2] Should contain all.",c.containsAll(col));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,8 +211,8 @@ public abstract class TestCollection extends TestObject {
|
||||||
|
|
||||||
boolean added1_1 = tryToAdd(c1,"element1");
|
boolean added1_1 = tryToAdd(c1,"element1");
|
||||||
if(added1_1) {
|
if(added1_1) {
|
||||||
assert("Empty Collection not equal to non-empty Collection.",!c2.equals(c1));
|
assertTrue("Empty Collection not equal to non-empty Collection.",!c2.equals(c1));
|
||||||
assert("Non-empty Collection not equal to empty Collection.",!c1.equals(c2));
|
assertTrue("Non-empty Collection not equal to empty Collection.",!c1.equals(c2));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean added1_2 = tryToAdd(c2,"element1");
|
boolean added1_2 = tryToAdd(c2,"element1");
|
||||||
|
@ -221,7 +221,7 @@ public abstract class TestCollection extends TestObject {
|
||||||
boolean added2_1 = tryToAdd(c1,"element2");
|
boolean added2_1 = tryToAdd(c1,"element2");
|
||||||
boolean added3_2 = tryToAdd(c2,"element3");
|
boolean added3_2 = tryToAdd(c2,"element3");
|
||||||
if(added2_1 || added3_2) {
|
if(added2_1 || added3_2) {
|
||||||
assert("Should not be equal.",!c1.equals(c2));
|
assertTrue("Should not be equal.",!c1.equals(c2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,17 +250,17 @@ public abstract class TestCollection extends TestObject {
|
||||||
|
|
||||||
public void testCollectionIsEmpty() {
|
public void testCollectionIsEmpty() {
|
||||||
Collection c = makeCollection();
|
Collection c = makeCollection();
|
||||||
assert("New Collection should be empty.",c.isEmpty());
|
assertTrue("New Collection should be empty.",c.isEmpty());
|
||||||
boolean added = tryToAdd(c,"element1");
|
boolean added = tryToAdd(c,"element1");
|
||||||
if(added) {
|
if(added) {
|
||||||
assert("If an element was added, the Collection.isEmpty() should return false.",!c.isEmpty());
|
assertTrue("If an element was added, the Collection.isEmpty() should return false.",!c.isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCollectionIterator() {
|
public void testCollectionIterator() {
|
||||||
Collection c = makeCollection();
|
Collection c = makeCollection();
|
||||||
Iterator it1 = c.iterator();
|
Iterator it1 = c.iterator();
|
||||||
assert("Iterator for empty Collection shouldn't have next.",!it1.hasNext());
|
assertTrue("Iterator for empty Collection shouldn't have next.",!it1.hasNext());
|
||||||
try {
|
try {
|
||||||
it1.next();
|
it1.next();
|
||||||
fail("Iterator at end of Collection should throw NoSuchElementException when next is called.");
|
fail("Iterator at end of Collection should throw NoSuchElementException when next is called.");
|
||||||
|
@ -274,9 +274,9 @@ public abstract class TestCollection extends TestObject {
|
||||||
boolean added = tryToAdd(c,"element1");
|
boolean added = tryToAdd(c,"element1");
|
||||||
if(added) {
|
if(added) {
|
||||||
Iterator it2 = c.iterator();
|
Iterator it2 = c.iterator();
|
||||||
assert("Iterator for non-empty Collection should have next.",it2.hasNext());
|
assertTrue("Iterator for non-empty Collection should have next.",it2.hasNext());
|
||||||
assertEquals("element1",it2.next());
|
assertEquals("element1",it2.next());
|
||||||
assert("Iterator at end of Collection shouldn't have next.",!it2.hasNext());
|
assertTrue("Iterator at end of Collection shouldn't have next.",!it2.hasNext());
|
||||||
try {
|
try {
|
||||||
it2.next();
|
it2.next();
|
||||||
fail("Iterator at end of Collection should throw NoSuchElementException when next is called.");
|
fail("Iterator at end of Collection should throw NoSuchElementException when next is called.");
|
||||||
|
@ -295,7 +295,7 @@ public abstract class TestCollection extends TestObject {
|
||||||
boolean added = tryToAdd(c,"element1");
|
boolean added = tryToAdd(c,"element1");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assert("Shouldn't be able to remove an element that wasn't added.",!c.remove("element2"));
|
assertTrue("Shouldn't be able to remove an element that wasn't added.",!c.remove("element2"));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
@ -303,8 +303,8 @@ public abstract class TestCollection extends TestObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assert("If added, should be removed by call to remove.",added == c.remove("element1"));
|
assertTrue("If added, should be removed by call to remove.",added == c.remove("element1"));
|
||||||
assert("If removed, shouldn't be contained.",!c.contains("element1"));
|
assertTrue("If removed, shouldn't be contained.",!c.contains("element1"));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
@ -315,7 +315,7 @@ public abstract class TestCollection extends TestObject {
|
||||||
// optional operation
|
// optional operation
|
||||||
public void testCollectionRemoveAll() {
|
public void testCollectionRemoveAll() {
|
||||||
Collection c = makeCollection();
|
Collection c = makeCollection();
|
||||||
assert("Initial Collection is empty.",c.isEmpty());
|
assertTrue("Initial Collection is empty.",c.isEmpty());
|
||||||
try {
|
try {
|
||||||
c.removeAll(c);
|
c.removeAll(c);
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
|
@ -324,14 +324,14 @@ public abstract class TestCollection extends TestObject {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
fail("Collection.removeAll should only throw UnsupportedOperationException. Found " + t.toString());
|
fail("Collection.removeAll should only throw UnsupportedOperationException. Found " + t.toString());
|
||||||
}
|
}
|
||||||
assert("Collection is still empty.",c.isEmpty());
|
assertTrue("Collection is still empty.",c.isEmpty());
|
||||||
|
|
||||||
boolean added = tryToAdd(c,"element1");
|
boolean added = tryToAdd(c,"element1");
|
||||||
if(added) {
|
if(added) {
|
||||||
assert("Collection is not empty.",!c.isEmpty());
|
assertTrue("Collection is not empty.",!c.isEmpty());
|
||||||
try {
|
try {
|
||||||
c.removeAll(c);
|
c.removeAll(c);
|
||||||
assert("Collection is empty.",c.isEmpty());
|
assertTrue("Collection is empty.",c.isEmpty());
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
@ -366,15 +366,15 @@ public abstract class TestCollection extends TestObject {
|
||||||
}
|
}
|
||||||
col.add("element4");
|
col.add("element4");
|
||||||
if(added) {
|
if(added) {
|
||||||
assert("Collection is not empty.",!c.isEmpty());
|
assertTrue("Collection is not empty.",!c.isEmpty());
|
||||||
try {
|
try {
|
||||||
assert("Should be changed",c.removeAll(col));
|
assertTrue("Should be changed",c.removeAll(col));
|
||||||
assert("Collection is not empty.",!c.isEmpty());
|
assertTrue("Collection is not empty.",!c.isEmpty());
|
||||||
assert("Collection should contain element",c.contains("element0"));
|
assertTrue("Collection should contain element",c.contains("element0"));
|
||||||
assert("Collection shouldn't contain removed element",!c.contains("element1"));
|
assertTrue("Collection shouldn't contain removed element",!c.contains("element1"));
|
||||||
assert("Collection shouldn't contain removed element",!c.contains("element2"));
|
assertTrue("Collection shouldn't contain removed element",!c.contains("element2"));
|
||||||
assert("Collection shouldn't contain removed element",!c.contains("element3"));
|
assertTrue("Collection shouldn't contain removed element",!c.contains("element3"));
|
||||||
assert("Collection shouldn't contain removed element",!c.contains("element4"));
|
assertTrue("Collection shouldn't contain removed element",!c.contains("element4"));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
@ -389,8 +389,8 @@ public abstract class TestCollection extends TestObject {
|
||||||
Collection a = makeCollection();
|
Collection a = makeCollection();
|
||||||
Collection b = makeCollection();
|
Collection b = makeCollection();
|
||||||
try {
|
try {
|
||||||
assert(!a.retainAll(b));
|
assertTrue(!a.retainAll(b));
|
||||||
assert(!a.retainAll(a));
|
assertTrue(!a.retainAll(a));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
@ -400,9 +400,9 @@ public abstract class TestCollection extends TestObject {
|
||||||
|
|
||||||
boolean added_b = b.add("element1");
|
boolean added_b = b.add("element1");
|
||||||
try {
|
try {
|
||||||
assert(!a.retainAll(b));
|
assertTrue(!a.retainAll(b));
|
||||||
assert(added_b == b.retainAll(a));
|
assertTrue(added_b == b.retainAll(a));
|
||||||
assert(b.isEmpty());
|
assertTrue(b.isEmpty());
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
@ -415,15 +415,15 @@ public abstract class TestCollection extends TestObject {
|
||||||
boolean added_a1 = a.add("element1");
|
boolean added_a1 = a.add("element1");
|
||||||
if(added_b1 && added_b2 && added_a1) {
|
if(added_b1 && added_b2 && added_a1) {
|
||||||
try {
|
try {
|
||||||
assert(!b.retainAll(b));
|
assertTrue(!b.retainAll(b));
|
||||||
assert(b.contains("element1"));
|
assertTrue(b.contains("element1"));
|
||||||
assert(b.contains("element2"));
|
assertTrue(b.contains("element2"));
|
||||||
|
|
||||||
assert(!a.retainAll(b));
|
assertTrue(!a.retainAll(b));
|
||||||
|
|
||||||
assert(b.retainAll(a));
|
assertTrue(b.retainAll(a));
|
||||||
assert(b.contains("element1"));
|
assertTrue(b.contains("element1"));
|
||||||
assert(!b.contains("element2"));
|
assertTrue(!b.contains("element2"));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
@ -471,7 +471,7 @@ public abstract class TestCollection extends TestObject {
|
||||||
String[] fits = new String[1];
|
String[] fits = new String[1];
|
||||||
String[] small = new String[0];
|
String[] small = new String[0];
|
||||||
assertSame(fits,c.toArray(fits));
|
assertSame(fits,c.toArray(fits));
|
||||||
assert(small != c.toArray(small));
|
assertTrue(small != c.toArray(small));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v 1.1 2001/04/24 18:48:38 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v 1.2 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.1 $
|
* $Revision: 1.2 $
|
||||||
* $Date: 2001/04/24 18:48:38 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -66,7 +66,7 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @version $Id: TestCollectionUtils.java,v 1.1 2001/04/24 18:48:38 rwaldhoff Exp $
|
* @version $Id: TestCollectionUtils.java,v 1.2 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestCollectionUtils extends TestCase {
|
public class TestCollectionUtils extends TestCase {
|
||||||
public TestCollectionUtils(String testName) {
|
public TestCollectionUtils(String testName) {
|
||||||
|
@ -117,10 +117,10 @@ public class TestCollectionUtils extends TestCase {
|
||||||
assertEquals(new Integer(2),freq.get("b"));
|
assertEquals(new Integer(2),freq.get("b"));
|
||||||
assertEquals(new Integer(3),freq.get("c"));
|
assertEquals(new Integer(3),freq.get("c"));
|
||||||
assertEquals(new Integer(4),freq.get("d"));
|
assertEquals(new Integer(4),freq.get("d"));
|
||||||
assert(null == freq.get("e"));
|
assertTrue(null == freq.get("e"));
|
||||||
|
|
||||||
freq = CollectionUtils.getCardinalityMap(_b);
|
freq = CollectionUtils.getCardinalityMap(_b);
|
||||||
assert(null == freq.get("a"));
|
assertTrue(null == freq.get("a"));
|
||||||
assertEquals(new Integer(4),freq.get("b"));
|
assertEquals(new Integer(4),freq.get("b"));
|
||||||
assertEquals(new Integer(3),freq.get("c"));
|
assertEquals(new Integer(3),freq.get("c"));
|
||||||
assertEquals(new Integer(2),freq.get("d"));
|
assertEquals(new Integer(2),freq.get("d"));
|
||||||
|
@ -162,19 +162,19 @@ public class TestCollectionUtils extends TestCase {
|
||||||
public void testIntersection() {
|
public void testIntersection() {
|
||||||
Collection col = CollectionUtils.intersection(_a,_b);
|
Collection col = CollectionUtils.intersection(_a,_b);
|
||||||
Map freq = CollectionUtils.getCardinalityMap(col);
|
Map freq = CollectionUtils.getCardinalityMap(col);
|
||||||
assert(null == freq.get("a"));
|
assertTrue(null == freq.get("a"));
|
||||||
assertEquals(new Integer(2),freq.get("b"));
|
assertEquals(new Integer(2),freq.get("b"));
|
||||||
assertEquals(new Integer(3),freq.get("c"));
|
assertEquals(new Integer(3),freq.get("c"));
|
||||||
assertEquals(new Integer(2),freq.get("d"));
|
assertEquals(new Integer(2),freq.get("d"));
|
||||||
assert(null == freq.get("e"));
|
assertTrue(null == freq.get("e"));
|
||||||
|
|
||||||
Collection col2 = CollectionUtils.intersection(_b,_a);
|
Collection col2 = CollectionUtils.intersection(_b,_a);
|
||||||
Map freq2 = CollectionUtils.getCardinalityMap(col2);
|
Map freq2 = CollectionUtils.getCardinalityMap(col2);
|
||||||
assert(null == freq2.get("a"));
|
assertTrue(null == freq2.get("a"));
|
||||||
assertEquals(new Integer(2),freq2.get("b"));
|
assertEquals(new Integer(2),freq2.get("b"));
|
||||||
assertEquals(new Integer(3),freq2.get("c"));
|
assertEquals(new Integer(3),freq2.get("c"));
|
||||||
assertEquals(new Integer(2),freq2.get("d"));
|
assertEquals(new Integer(2),freq2.get("d"));
|
||||||
assert(null == freq2.get("e"));
|
assertTrue(null == freq2.get("e"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisjunction() {
|
public void testDisjunction() {
|
||||||
|
@ -182,7 +182,7 @@ public class TestCollectionUtils extends TestCase {
|
||||||
Map freq = CollectionUtils.getCardinalityMap(col);
|
Map freq = CollectionUtils.getCardinalityMap(col);
|
||||||
assertEquals(new Integer(1),freq.get("a"));
|
assertEquals(new Integer(1),freq.get("a"));
|
||||||
assertEquals(new Integer(2),freq.get("b"));
|
assertEquals(new Integer(2),freq.get("b"));
|
||||||
assert(null == freq.get("c"));
|
assertTrue(null == freq.get("c"));
|
||||||
assertEquals(new Integer(2),freq.get("d"));
|
assertEquals(new Integer(2),freq.get("d"));
|
||||||
assertEquals(new Integer(1),freq.get("e"));
|
assertEquals(new Integer(1),freq.get("e"));
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class TestCollectionUtils extends TestCase {
|
||||||
Map freq2 = CollectionUtils.getCardinalityMap(col2);
|
Map freq2 = CollectionUtils.getCardinalityMap(col2);
|
||||||
assertEquals(new Integer(1),freq2.get("a"));
|
assertEquals(new Integer(1),freq2.get("a"));
|
||||||
assertEquals(new Integer(2),freq2.get("b"));
|
assertEquals(new Integer(2),freq2.get("b"));
|
||||||
assert(null == freq2.get("c"));
|
assertTrue(null == freq2.get("c"));
|
||||||
assertEquals(new Integer(2),freq2.get("d"));
|
assertEquals(new Integer(2),freq2.get("d"));
|
||||||
assertEquals(new Integer(1),freq2.get("e"));
|
assertEquals(new Integer(1),freq2.get("e"));
|
||||||
}
|
}
|
||||||
|
@ -199,115 +199,115 @@ public class TestCollectionUtils extends TestCase {
|
||||||
Collection dis = CollectionUtils.disjunction(_a,_b);
|
Collection dis = CollectionUtils.disjunction(_a,_b);
|
||||||
Collection un = CollectionUtils.union(_a,_b);
|
Collection un = CollectionUtils.union(_a,_b);
|
||||||
Collection inter = CollectionUtils.intersection(_a,_b);
|
Collection inter = CollectionUtils.intersection(_a,_b);
|
||||||
assert(CollectionUtils.isEqualCollection(dis,CollectionUtils.subtract(un,inter)));
|
assertTrue(CollectionUtils.isEqualCollection(dis,CollectionUtils.subtract(un,inter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisjunctionAsSymmetricDifference() {
|
public void testDisjunctionAsSymmetricDifference() {
|
||||||
Collection dis = CollectionUtils.disjunction(_a,_b);
|
Collection dis = CollectionUtils.disjunction(_a,_b);
|
||||||
Collection amb = CollectionUtils.subtract(_a,_b);
|
Collection amb = CollectionUtils.subtract(_a,_b);
|
||||||
Collection bma = CollectionUtils.subtract(_b,_a);
|
Collection bma = CollectionUtils.subtract(_b,_a);
|
||||||
assert(CollectionUtils.isEqualCollection(dis,CollectionUtils.union(amb,bma)));
|
assertTrue(CollectionUtils.isEqualCollection(dis,CollectionUtils.union(amb,bma)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSubtract() {
|
public void testSubtract() {
|
||||||
Collection col = CollectionUtils.subtract(_a,_b);
|
Collection col = CollectionUtils.subtract(_a,_b);
|
||||||
Map freq = CollectionUtils.getCardinalityMap(col);
|
Map freq = CollectionUtils.getCardinalityMap(col);
|
||||||
assertEquals(new Integer(1),freq.get("a"));
|
assertEquals(new Integer(1),freq.get("a"));
|
||||||
assert(null == freq.get("b"));
|
assertTrue(null == freq.get("b"));
|
||||||
assert(null == freq.get("c"));
|
assertTrue(null == freq.get("c"));
|
||||||
assertEquals(new Integer(2),freq.get("d"));
|
assertEquals(new Integer(2),freq.get("d"));
|
||||||
assert(null == freq.get("e"));
|
assertTrue(null == freq.get("e"));
|
||||||
|
|
||||||
Collection col2 = CollectionUtils.subtract(_b,_a);
|
Collection col2 = CollectionUtils.subtract(_b,_a);
|
||||||
Map freq2 = CollectionUtils.getCardinalityMap(col2);
|
Map freq2 = CollectionUtils.getCardinalityMap(col2);
|
||||||
assertEquals(new Integer(1),freq2.get("e"));
|
assertEquals(new Integer(1),freq2.get("e"));
|
||||||
assert(null == freq2.get("d"));
|
assertTrue(null == freq2.get("d"));
|
||||||
assert(null == freq2.get("c"));
|
assertTrue(null == freq2.get("c"));
|
||||||
assertEquals(new Integer(2),freq2.get("b"));
|
assertEquals(new Integer(2),freq2.get("b"));
|
||||||
assert(null == freq2.get("a"));
|
assertTrue(null == freq2.get("a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsSubCollectionOfSelf() {
|
public void testIsSubCollectionOfSelf() {
|
||||||
assert(CollectionUtils.isSubCollection(_a,_a));
|
assertTrue(CollectionUtils.isSubCollection(_a,_a));
|
||||||
assert(CollectionUtils.isSubCollection(_b,_b));
|
assertTrue(CollectionUtils.isSubCollection(_b,_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsSubCollection() {
|
public void testIsSubCollection() {
|
||||||
assert(!CollectionUtils.isSubCollection(_a,_b));
|
assertTrue(!CollectionUtils.isSubCollection(_a,_b));
|
||||||
assert(!CollectionUtils.isSubCollection(_b,_a));
|
assertTrue(!CollectionUtils.isSubCollection(_b,_a));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsSubCollection2() {
|
public void testIsSubCollection2() {
|
||||||
Collection c = new ArrayList();
|
Collection c = new ArrayList();
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("a");
|
c.add("a");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("b");
|
c.add("b");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("b");
|
c.add("b");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("c");
|
c.add("c");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("c");
|
c.add("c");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("c");
|
c.add("c");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("d");
|
c.add("d");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("d");
|
c.add("d");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("d");
|
c.add("d");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(!CollectionUtils.isSubCollection(_a,c));
|
assertTrue(!CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("d");
|
c.add("d");
|
||||||
assert(CollectionUtils.isSubCollection(c,_a));
|
assertTrue(CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(CollectionUtils.isSubCollection(_a,c));
|
assertTrue(CollectionUtils.isSubCollection(_a,c));
|
||||||
c.add("e");
|
c.add("e");
|
||||||
assert(!CollectionUtils.isSubCollection(c,_a));
|
assertTrue(!CollectionUtils.isSubCollection(c,_a));
|
||||||
assert(CollectionUtils.isSubCollection(_a,c));
|
assertTrue(CollectionUtils.isSubCollection(_a,c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsEqualCollectionToSelf() {
|
public void testIsEqualCollectionToSelf() {
|
||||||
assert(CollectionUtils.isEqualCollection(_a,_a));
|
assertTrue(CollectionUtils.isEqualCollection(_a,_a));
|
||||||
assert(CollectionUtils.isEqualCollection(_b,_b));
|
assertTrue(CollectionUtils.isEqualCollection(_b,_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsEqualCollection() {
|
public void testIsEqualCollection() {
|
||||||
assert(!CollectionUtils.isEqualCollection(_a,_b));
|
assertTrue(!CollectionUtils.isEqualCollection(_a,_b));
|
||||||
assert(!CollectionUtils.isEqualCollection(_b,_a));
|
assertTrue(!CollectionUtils.isEqualCollection(_b,_a));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsEqualCollection2() {
|
public void testIsEqualCollection2() {
|
||||||
Collection a = new ArrayList();
|
Collection a = new ArrayList();
|
||||||
Collection b = new ArrayList();
|
Collection b = new ArrayList();
|
||||||
assert(CollectionUtils.isEqualCollection(a,b));
|
assertTrue(CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(CollectionUtils.isEqualCollection(b,a));
|
assertTrue(CollectionUtils.isEqualCollection(b,a));
|
||||||
a.add("1");
|
a.add("1");
|
||||||
assert(!CollectionUtils.isEqualCollection(a,b));
|
assertTrue(!CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(!CollectionUtils.isEqualCollection(b,a));
|
assertTrue(!CollectionUtils.isEqualCollection(b,a));
|
||||||
b.add("1");
|
b.add("1");
|
||||||
assert(CollectionUtils.isEqualCollection(a,b));
|
assertTrue(CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(CollectionUtils.isEqualCollection(b,a));
|
assertTrue(CollectionUtils.isEqualCollection(b,a));
|
||||||
a.add("2");
|
a.add("2");
|
||||||
assert(!CollectionUtils.isEqualCollection(a,b));
|
assertTrue(!CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(!CollectionUtils.isEqualCollection(b,a));
|
assertTrue(!CollectionUtils.isEqualCollection(b,a));
|
||||||
b.add("2");
|
b.add("2");
|
||||||
assert(CollectionUtils.isEqualCollection(a,b));
|
assertTrue(CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(CollectionUtils.isEqualCollection(b,a));
|
assertTrue(CollectionUtils.isEqualCollection(b,a));
|
||||||
a.add("1");
|
a.add("1");
|
||||||
assert(!CollectionUtils.isEqualCollection(a,b));
|
assertTrue(!CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(!CollectionUtils.isEqualCollection(b,a));
|
assertTrue(!CollectionUtils.isEqualCollection(b,a));
|
||||||
b.add("1");
|
b.add("1");
|
||||||
assert(CollectionUtils.isEqualCollection(a,b));
|
assertTrue(CollectionUtils.isEqualCollection(a,b));
|
||||||
assert(CollectionUtils.isEqualCollection(b,a));
|
assertTrue(CollectionUtils.isEqualCollection(b,a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v 1.2 2001/04/20 16:54:07 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2001/04/20 16:54:07 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -66,7 +66,7 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @version $Id: TestCursorableLinkedList.java,v 1.2 2001/04/20 16:54:07 rwaldhoff Exp $
|
* @version $Id: TestCursorableLinkedList.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestCursorableLinkedList extends TestList {
|
public class TestCursorableLinkedList extends TestList {
|
||||||
public TestCursorableLinkedList(String testName) {
|
public TestCursorableLinkedList(String testName) {
|
||||||
|
@ -94,15 +94,15 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
|
|
||||||
public void testAdd() {
|
public void testAdd() {
|
||||||
assertEquals("[]",list.toString());
|
assertEquals("[]",list.toString());
|
||||||
assert(list.add(new Integer(1)));
|
assertTrue(list.add(new Integer(1)));
|
||||||
assertEquals("[1]",list.toString());
|
assertEquals("[1]",list.toString());
|
||||||
assert(list.add(new Integer(2)));
|
assertTrue(list.add(new Integer(2)));
|
||||||
assertEquals("[1, 2]",list.toString());
|
assertEquals("[1, 2]",list.toString());
|
||||||
assert(list.add(new Integer(3)));
|
assertTrue(list.add(new Integer(3)));
|
||||||
assertEquals("[1, 2, 3]",list.toString());
|
assertEquals("[1, 2, 3]",list.toString());
|
||||||
assert(list.addFirst(new Integer(0)));
|
assertTrue(list.addFirst(new Integer(0)));
|
||||||
assertEquals("[0, 1, 2, 3]",list.toString());
|
assertEquals("[0, 1, 2, 3]",list.toString());
|
||||||
assert(list.addLast(new Integer(4)));
|
assertTrue(list.addLast(new Integer(4)));
|
||||||
assertEquals("[0, 1, 2, 3, 4]",list.toString());
|
assertEquals("[0, 1, 2, 3, 4]",list.toString());
|
||||||
list.add(0,new Integer(-2));
|
list.add(0,new Integer(-2));
|
||||||
assertEquals("[-2, 0, 1, 2, 3, 4]",list.toString());
|
assertEquals("[-2, 0, 1, 2, 3, 4]",list.toString());
|
||||||
|
@ -116,79 +116,79 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
list2.add("B");
|
list2.add("B");
|
||||||
list2.add("C");
|
list2.add("C");
|
||||||
|
|
||||||
assert(list.addAll(list2));
|
assertTrue(list.addAll(list2));
|
||||||
assertEquals("[-2, -1, 0, 1, 2, 3, 4, 5, A, B, C]",list.toString());
|
assertEquals("[-2, -1, 0, 1, 2, 3, 4, 5, A, B, C]",list.toString());
|
||||||
assert(list.addAll(3,list2));
|
assertTrue(list.addAll(3,list2));
|
||||||
assertEquals("[-2, -1, 0, A, B, C, 1, 2, 3, 4, 5, A, B, C]",list.toString());
|
assertEquals("[-2, -1, 0, A, B, C, 1, 2, 3, 4, 5, A, B, C]",list.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClear() {
|
public void testClear() {
|
||||||
assertEquals(0,list.size());
|
assertEquals(0,list.size());
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
list.clear();
|
list.clear();
|
||||||
assertEquals(0,list.size());
|
assertEquals(0,list.size());
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
|
|
||||||
list.add("element");
|
list.add("element");
|
||||||
assertEquals(1,list.size());
|
assertEquals(1,list.size());
|
||||||
assert(!list.isEmpty());
|
assertTrue(!list.isEmpty());
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
assertEquals(0,list.size());
|
assertEquals(0,list.size());
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
|
|
||||||
list.add("element1");
|
list.add("element1");
|
||||||
list.add("element2");
|
list.add("element2");
|
||||||
assertEquals(2,list.size());
|
assertEquals(2,list.size());
|
||||||
assert(!list.isEmpty());
|
assertTrue(!list.isEmpty());
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
assertEquals(0,list.size());
|
assertEquals(0,list.size());
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
|
|
||||||
for(int i=0;i<1000;i++) {
|
for(int i=0;i<1000;i++) {
|
||||||
list.add(new Integer(i));
|
list.add(new Integer(i));
|
||||||
}
|
}
|
||||||
assertEquals(1000,list.size());
|
assertEquals(1000,list.size());
|
||||||
assert(!list.isEmpty());
|
assertTrue(!list.isEmpty());
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
assertEquals(0,list.size());
|
assertEquals(0,list.size());
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testContains() {
|
public void testContains() {
|
||||||
assert(!list.contains("A"));
|
assertTrue(!list.contains("A"));
|
||||||
assert(list.add("A"));
|
assertTrue(list.add("A"));
|
||||||
assert(list.contains("A"));
|
assertTrue(list.contains("A"));
|
||||||
assert(list.add("B"));
|
assertTrue(list.add("B"));
|
||||||
assert(list.contains("A"));
|
assertTrue(list.contains("A"));
|
||||||
assert(list.addFirst("a"));
|
assertTrue(list.addFirst("a"));
|
||||||
assert(list.contains("A"));
|
assertTrue(list.contains("A"));
|
||||||
assert(list.remove("a"));
|
assertTrue(list.remove("a"));
|
||||||
assert(list.contains("A"));
|
assertTrue(list.contains("A"));
|
||||||
assert(list.remove("A"));
|
assertTrue(list.remove("A"));
|
||||||
assert(!list.contains("A"));
|
assertTrue(!list.contains("A"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testContainsAll() {
|
public void testContainsAll() {
|
||||||
assert(list.containsAll(list));
|
assertTrue(list.containsAll(list));
|
||||||
java.util.List list2 = new java.util.LinkedList();
|
java.util.List list2 = new java.util.LinkedList();
|
||||||
assert(list.containsAll(list2));
|
assertTrue(list.containsAll(list2));
|
||||||
list2.add("A");
|
list2.add("A");
|
||||||
assert(!list.containsAll(list2));
|
assertTrue(!list.containsAll(list2));
|
||||||
list.add("B");
|
list.add("B");
|
||||||
list.add("A");
|
list.add("A");
|
||||||
assert(list.containsAll(list2));
|
assertTrue(list.containsAll(list2));
|
||||||
list2.add("B");
|
list2.add("B");
|
||||||
assert(list.containsAll(list2));
|
assertTrue(list.containsAll(list2));
|
||||||
list2.add("C");
|
list2.add("C");
|
||||||
assert(!list.containsAll(list2));
|
assertTrue(!list.containsAll(list2));
|
||||||
list.add("C");
|
list.add("C");
|
||||||
assert(list.containsAll(list2));
|
assertTrue(list.containsAll(list2));
|
||||||
list2.add("C");
|
list2.add("C");
|
||||||
assert(list.containsAll(list2));
|
assertTrue(list.containsAll(list2));
|
||||||
assert(list.containsAll(list));
|
assertTrue(list.containsAll(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCursorNavigation() {
|
public void testCursorNavigation() {
|
||||||
|
@ -198,50 +198,50 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
list.add("4");
|
list.add("4");
|
||||||
list.add("5");
|
list.add("5");
|
||||||
CursorableLinkedList.Cursor it = list.cursor();
|
CursorableLinkedList.Cursor it = list.cursor();
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals("1",it.next());
|
assertEquals("1",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("1",it.previous());
|
assertEquals("1",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals("1",it.next());
|
assertEquals("1",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("2",it.next());
|
assertEquals("2",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("2",it.previous());
|
assertEquals("2",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("2",it.next());
|
assertEquals("2",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("3",it.next());
|
assertEquals("3",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("4",it.next());
|
assertEquals("4",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("5",it.next());
|
assertEquals("5",it.next());
|
||||||
assert(!it.hasNext());
|
assertTrue(!it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("5",it.previous());
|
assertEquals("5",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("4",it.previous());
|
assertEquals("4",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("3",it.previous());
|
assertEquals("3",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("2",it.previous());
|
assertEquals("2",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals("1",it.previous());
|
assertEquals("1",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
it.close();
|
it.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
assertEquals("1",it.previous());
|
assertEquals("1",it.previous());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[3, 4, 5]",list.toString());
|
assertEquals("[3, 4, 5]",list.toString());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals("3",it.next());
|
assertEquals("3",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[4, 5]",list.toString());
|
assertEquals("[4, 5]",list.toString());
|
||||||
|
@ -330,66 +330,66 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEqualsAndHashCode() {
|
public void testEqualsAndHashCode() {
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
assertEquals(list.hashCode(),list.hashCode());
|
assertEquals(list.hashCode(),list.hashCode());
|
||||||
list.add("A");
|
list.add("A");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
assertEquals(list.hashCode(),list.hashCode());
|
assertEquals(list.hashCode(),list.hashCode());
|
||||||
|
|
||||||
CursorableLinkedList list2 = new CursorableLinkedList();
|
CursorableLinkedList list2 = new CursorableLinkedList();
|
||||||
assert(!list.equals(list2));
|
assertTrue(!list.equals(list2));
|
||||||
assert(!list2.equals(list));
|
assertTrue(!list2.equals(list));
|
||||||
|
|
||||||
java.util.List list3 = new java.util.LinkedList();
|
java.util.List list3 = new java.util.LinkedList();
|
||||||
assert(!list.equals(list3));
|
assertTrue(!list.equals(list3));
|
||||||
assert(!list3.equals(list));
|
assertTrue(!list3.equals(list));
|
||||||
assert(list2.equals(list3));
|
assertTrue(list2.equals(list3));
|
||||||
assert(list3.equals(list2));
|
assertTrue(list3.equals(list2));
|
||||||
assertEquals(list2.hashCode(),list3.hashCode());
|
assertEquals(list2.hashCode(),list3.hashCode());
|
||||||
|
|
||||||
list2.add("A");
|
list2.add("A");
|
||||||
assert(list.equals(list2));
|
assertTrue(list.equals(list2));
|
||||||
assert(list2.equals(list));
|
assertTrue(list2.equals(list));
|
||||||
assert(!list2.equals(list3));
|
assertTrue(!list2.equals(list3));
|
||||||
assert(!list3.equals(list2));
|
assertTrue(!list3.equals(list2));
|
||||||
|
|
||||||
list3.add("A");
|
list3.add("A");
|
||||||
assert(list2.equals(list3));
|
assertTrue(list2.equals(list3));
|
||||||
assert(list3.equals(list2));
|
assertTrue(list3.equals(list2));
|
||||||
assertEquals(list2.hashCode(),list3.hashCode());
|
assertEquals(list2.hashCode(),list3.hashCode());
|
||||||
|
|
||||||
list.add("B");
|
list.add("B");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
assert(!list.equals(list2));
|
assertTrue(!list.equals(list2));
|
||||||
assert(!list2.equals(list));
|
assertTrue(!list2.equals(list));
|
||||||
assert(!list.equals(list3));
|
assertTrue(!list.equals(list3));
|
||||||
assert(!list3.equals(list));
|
assertTrue(!list3.equals(list));
|
||||||
|
|
||||||
list2.add("B");
|
list2.add("B");
|
||||||
list3.add("B");
|
list3.add("B");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
assert(list.equals(list2));
|
assertTrue(list.equals(list2));
|
||||||
assert(list2.equals(list));
|
assertTrue(list2.equals(list));
|
||||||
assert(list2.equals(list3));
|
assertTrue(list2.equals(list3));
|
||||||
assert(list3.equals(list2));
|
assertTrue(list3.equals(list2));
|
||||||
assertEquals(list2.hashCode(),list3.hashCode());
|
assertEquals(list2.hashCode(),list3.hashCode());
|
||||||
|
|
||||||
list.add("C");
|
list.add("C");
|
||||||
list2.add("C");
|
list2.add("C");
|
||||||
list3.add("C");
|
list3.add("C");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
assert(list.equals(list2));
|
assertTrue(list.equals(list2));
|
||||||
assert(list2.equals(list));
|
assertTrue(list2.equals(list));
|
||||||
assert(list2.equals(list3));
|
assertTrue(list2.equals(list3));
|
||||||
assert(list3.equals(list2));
|
assertTrue(list3.equals(list2));
|
||||||
assertEquals(list.hashCode(),list2.hashCode());
|
assertEquals(list.hashCode(),list2.hashCode());
|
||||||
assertEquals(list2.hashCode(),list3.hashCode());
|
assertEquals(list2.hashCode(),list3.hashCode());
|
||||||
|
|
||||||
list.add("D");
|
list.add("D");
|
||||||
list2.addFirst("D");
|
list2.addFirst("D");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
assert(!list.equals(list2));
|
assertTrue(!list.equals(list2));
|
||||||
assert(!list2.equals(list));
|
assertTrue(!list2.equals(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGet() {
|
public void testGet() {
|
||||||
|
@ -400,9 +400,9 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(list.add("A"));
|
assertTrue(list.add("A"));
|
||||||
assertEquals("A",list.get(0));
|
assertEquals("A",list.get(0));
|
||||||
assert(list.add("B"));
|
assertTrue(list.add("B"));
|
||||||
assertEquals("A",list.get(0));
|
assertEquals("A",list.get(0));
|
||||||
assertEquals("B",list.get(1));
|
assertEquals("B",list.get(1));
|
||||||
|
|
||||||
|
@ -442,15 +442,15 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsEmpty() {
|
public void testIsEmpty() {
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
list.add("element");
|
list.add("element");
|
||||||
assert(!list.isEmpty());
|
assertTrue(!list.isEmpty());
|
||||||
list.remove("element");
|
list.remove("element");
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
list.add("element");
|
list.add("element");
|
||||||
assert(!list.isEmpty());
|
assertTrue(!list.isEmpty());
|
||||||
list.clear();
|
list.clear();
|
||||||
assert(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIterator() {
|
public void testIterator() {
|
||||||
|
@ -460,40 +460,40 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
list.add("4");
|
list.add("4");
|
||||||
list.add("5");
|
list.add("5");
|
||||||
Iterator it = list.iterator();
|
Iterator it = list.iterator();
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("1",it.next());
|
assertEquals("1",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("2",it.next());
|
assertEquals("2",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("3",it.next());
|
assertEquals("3",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("4",it.next());
|
assertEquals("4",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("5",it.next());
|
assertEquals("5",it.next());
|
||||||
assert(!it.hasNext());
|
assertTrue(!it.hasNext());
|
||||||
|
|
||||||
it = list.iterator();
|
it = list.iterator();
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("1",it.next());
|
assertEquals("1",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[2, 3, 4, 5]",list.toString());
|
assertEquals("[2, 3, 4, 5]",list.toString());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("2",it.next());
|
assertEquals("2",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[3, 4, 5]",list.toString());
|
assertEquals("[3, 4, 5]",list.toString());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("3",it.next());
|
assertEquals("3",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[4, 5]",list.toString());
|
assertEquals("[4, 5]",list.toString());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("4",it.next());
|
assertEquals("4",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[5]",list.toString());
|
assertEquals("[5]",list.toString());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals("5",it.next());
|
assertEquals("5",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[]",list.toString());
|
assertEquals("[]",list.toString());
|
||||||
assert(!it.hasNext());
|
assertTrue(!it.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListIteratorNavigation() {
|
public void testListIteratorNavigation() {
|
||||||
|
@ -503,78 +503,78 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
list.add("4");
|
list.add("4");
|
||||||
list.add("5");
|
list.add("5");
|
||||||
ListIterator it = list.listIterator();
|
ListIterator it = list.listIterator();
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals(-1,it.previousIndex());
|
assertEquals(-1,it.previousIndex());
|
||||||
assertEquals(0,it.nextIndex());
|
assertEquals(0,it.nextIndex());
|
||||||
assertEquals("1",it.next());
|
assertEquals("1",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(0,it.previousIndex());
|
assertEquals(0,it.previousIndex());
|
||||||
assertEquals(1,it.nextIndex());
|
assertEquals(1,it.nextIndex());
|
||||||
assertEquals("1",it.previous());
|
assertEquals("1",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals(-1,it.previousIndex());
|
assertEquals(-1,it.previousIndex());
|
||||||
assertEquals(0,it.nextIndex());
|
assertEquals(0,it.nextIndex());
|
||||||
assertEquals("1",it.next());
|
assertEquals("1",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(0,it.previousIndex());
|
assertEquals(0,it.previousIndex());
|
||||||
assertEquals(1,it.nextIndex());
|
assertEquals(1,it.nextIndex());
|
||||||
assertEquals("2",it.next());
|
assertEquals("2",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(1,it.previousIndex());
|
assertEquals(1,it.previousIndex());
|
||||||
assertEquals(2,it.nextIndex());
|
assertEquals(2,it.nextIndex());
|
||||||
assertEquals("2",it.previous());
|
assertEquals("2",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(0,it.previousIndex());
|
assertEquals(0,it.previousIndex());
|
||||||
assertEquals(1,it.nextIndex());
|
assertEquals(1,it.nextIndex());
|
||||||
assertEquals("2",it.next());
|
assertEquals("2",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(1,it.previousIndex());
|
assertEquals(1,it.previousIndex());
|
||||||
assertEquals(2,it.nextIndex());
|
assertEquals(2,it.nextIndex());
|
||||||
assertEquals("3",it.next());
|
assertEquals("3",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(2,it.previousIndex());
|
assertEquals(2,it.previousIndex());
|
||||||
assertEquals(3,it.nextIndex());
|
assertEquals(3,it.nextIndex());
|
||||||
assertEquals("4",it.next());
|
assertEquals("4",it.next());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(3,it.previousIndex());
|
assertEquals(3,it.previousIndex());
|
||||||
assertEquals(4,it.nextIndex());
|
assertEquals(4,it.nextIndex());
|
||||||
assertEquals("5",it.next());
|
assertEquals("5",it.next());
|
||||||
assert(!it.hasNext());
|
assertTrue(!it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(4,it.previousIndex());
|
assertEquals(4,it.previousIndex());
|
||||||
assertEquals(5,it.nextIndex());
|
assertEquals(5,it.nextIndex());
|
||||||
assertEquals("5",it.previous());
|
assertEquals("5",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(3,it.previousIndex());
|
assertEquals(3,it.previousIndex());
|
||||||
assertEquals(4,it.nextIndex());
|
assertEquals(4,it.nextIndex());
|
||||||
assertEquals("4",it.previous());
|
assertEquals("4",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(2,it.previousIndex());
|
assertEquals(2,it.previousIndex());
|
||||||
assertEquals(3,it.nextIndex());
|
assertEquals(3,it.nextIndex());
|
||||||
assertEquals("3",it.previous());
|
assertEquals("3",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(1,it.previousIndex());
|
assertEquals(1,it.previousIndex());
|
||||||
assertEquals(2,it.nextIndex());
|
assertEquals(2,it.nextIndex());
|
||||||
assertEquals("2",it.previous());
|
assertEquals("2",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(it.hasPrevious());
|
assertTrue(it.hasPrevious());
|
||||||
assertEquals(0,it.previousIndex());
|
assertEquals(0,it.previousIndex());
|
||||||
assertEquals(1,it.nextIndex());
|
assertEquals(1,it.nextIndex());
|
||||||
assertEquals("1",it.previous());
|
assertEquals("1",it.previous());
|
||||||
assert(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals(-1,it.previousIndex());
|
assertEquals(-1,it.previousIndex());
|
||||||
assertEquals(0,it.nextIndex());
|
assertEquals(0,it.nextIndex());
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
assertEquals("1",it.previous());
|
assertEquals("1",it.previous());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[3, 4, 5]",list.toString());
|
assertEquals("[3, 4, 5]",list.toString());
|
||||||
assert(!it.hasPrevious());
|
assertTrue(!it.hasPrevious());
|
||||||
assertEquals("3",it.next());
|
assertEquals("3",it.next());
|
||||||
it.remove();
|
it.remove();
|
||||||
assertEquals("[4, 5]",list.toString());
|
assertEquals("[4, 5]",list.toString());
|
||||||
|
@ -674,9 +674,9 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
set.add("4");
|
set.add("4");
|
||||||
set.add("D");
|
set.add("D");
|
||||||
|
|
||||||
assert(list.removeAll(set));
|
assertTrue(list.removeAll(set));
|
||||||
assertEquals("[1, 3, 5]",list.toString());
|
assertEquals("[1, 3, 5]",list.toString());
|
||||||
assert(!list.removeAll(set));
|
assertTrue(!list.removeAll(set));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemoveByIndex() {
|
public void testRemoveByIndex() {
|
||||||
|
@ -710,27 +710,27 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
list.add("4");
|
list.add("4");
|
||||||
list.add("5");
|
list.add("5");
|
||||||
assertEquals("[1, 1, 2, 3, 4, 5, 2, 3, 4, 5]",list.toString());
|
assertEquals("[1, 1, 2, 3, 4, 5, 2, 3, 4, 5]",list.toString());
|
||||||
assert(!list.remove("6"));
|
assertTrue(!list.remove("6"));
|
||||||
assert(list.remove("5"));
|
assertTrue(list.remove("5"));
|
||||||
assertEquals("[1, 1, 2, 3, 4, 2, 3, 4, 5]",list.toString());
|
assertEquals("[1, 1, 2, 3, 4, 2, 3, 4, 5]",list.toString());
|
||||||
assert(list.remove("5"));
|
assertTrue(list.remove("5"));
|
||||||
assertEquals("[1, 1, 2, 3, 4, 2, 3, 4]",list.toString());
|
assertEquals("[1, 1, 2, 3, 4, 2, 3, 4]",list.toString());
|
||||||
assert(!list.remove("5"));
|
assertTrue(!list.remove("5"));
|
||||||
assert(list.remove("1"));
|
assertTrue(list.remove("1"));
|
||||||
assertEquals("[1, 2, 3, 4, 2, 3, 4]",list.toString());
|
assertEquals("[1, 2, 3, 4, 2, 3, 4]",list.toString());
|
||||||
assert(list.remove("1"));
|
assertTrue(list.remove("1"));
|
||||||
assertEquals("[2, 3, 4, 2, 3, 4]",list.toString());
|
assertEquals("[2, 3, 4, 2, 3, 4]",list.toString());
|
||||||
assert(list.remove("2"));
|
assertTrue(list.remove("2"));
|
||||||
assertEquals("[3, 4, 2, 3, 4]",list.toString());
|
assertEquals("[3, 4, 2, 3, 4]",list.toString());
|
||||||
assert(list.remove("2"));
|
assertTrue(list.remove("2"));
|
||||||
assertEquals("[3, 4, 3, 4]",list.toString());
|
assertEquals("[3, 4, 3, 4]",list.toString());
|
||||||
assert(list.remove("3"));
|
assertTrue(list.remove("3"));
|
||||||
assertEquals("[4, 3, 4]",list.toString());
|
assertEquals("[4, 3, 4]",list.toString());
|
||||||
assert(list.remove("3"));
|
assertTrue(list.remove("3"));
|
||||||
assertEquals("[4, 4]",list.toString());
|
assertEquals("[4, 4]",list.toString());
|
||||||
assert(list.remove("4"));
|
assertTrue(list.remove("4"));
|
||||||
assertEquals("[4]",list.toString());
|
assertEquals("[4]",list.toString());
|
||||||
assert(list.remove("4"));
|
assertTrue(list.remove("4"));
|
||||||
assertEquals("[]",list.toString());
|
assertEquals("[]",list.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,9 +753,9 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
set.add("4");
|
set.add("4");
|
||||||
set.add("D");
|
set.add("D");
|
||||||
|
|
||||||
assert(list.retainAll(set));
|
assertTrue(list.retainAll(set));
|
||||||
assertEquals("[2, 2, 4, 4]",list.toString());
|
assertEquals("[2, 2, 4, 4]",list.toString());
|
||||||
assert(!list.retainAll(set));
|
assertTrue(!list.retainAll(set));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSet() {
|
public void testSet() {
|
||||||
|
@ -896,7 +896,7 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
|
|
||||||
String[] elts4 = new String[3];
|
String[] elts4 = new String[3];
|
||||||
String[] elts4b = (String[])(list.toArray(elts4));
|
String[] elts4b = (String[])(list.toArray(elts4));
|
||||||
assert(elts4 != elts4b);
|
assertTrue(elts4 != elts4b);
|
||||||
assertEquals("1",elts4b[0]);
|
assertEquals("1",elts4b[0]);
|
||||||
assertEquals("2",elts4b[1]);
|
assertEquals("2",elts4b[1]);
|
||||||
assertEquals("3",elts4b[2]);
|
assertEquals("3",elts4b[2]);
|
||||||
|
@ -922,9 +922,9 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
java.io.ObjectInputStream in = new java.io.ObjectInputStream(bufin);
|
java.io.ObjectInputStream in = new java.io.ObjectInputStream(bufin);
|
||||||
Object list2 = in.readObject();
|
Object list2 = in.readObject();
|
||||||
|
|
||||||
assert(list != list2);
|
assertTrue(list != list2);
|
||||||
assert(list2.equals(list));
|
assertTrue(list2.equals(list));
|
||||||
assert(list.equals(list2));
|
assertTrue(list.equals(list2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLongSerialization() throws Exception {
|
public void testLongSerialization() throws Exception {
|
||||||
|
@ -944,9 +944,9 @@ public class TestCursorableLinkedList extends TestList {
|
||||||
java.io.ObjectInputStream in = new java.io.ObjectInputStream(bufin);
|
java.io.ObjectInputStream in = new java.io.ObjectInputStream(bufin);
|
||||||
Object list2 = in.readObject();
|
Object list2 = in.readObject();
|
||||||
|
|
||||||
assert(list != list2);
|
assertTrue(list != list2);
|
||||||
assert(list2.equals(list));
|
assertTrue(list2.equals(list));
|
||||||
assert(list.equals(list2));
|
assertTrue(list.equals(list2));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestExtendedProperties.java,v 1.2 2001/05/10 00:40:09 geirm Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestExtendedProperties.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2001/05/10 00:40:09 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -70,7 +70,7 @@ import junit.framework.TestSuite;
|
||||||
* class
|
* class
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
|
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
|
||||||
* @version $Id: TestExtendedProperties.java,v 1.2 2001/05/10 00:40:09 geirm Exp $
|
* @version $Id: TestExtendedProperties.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestExtendedProperties extends TestCase
|
public class TestExtendedProperties extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -111,26 +111,26 @@ public class TestExtendedProperties extends TestCase
|
||||||
* now add another and get a Vector
|
* now add another and get a Vector
|
||||||
*/
|
*/
|
||||||
eprop.addProperty("number", "2");
|
eprop.addProperty("number", "2");
|
||||||
assert("This returns array", ( eprop.getVector("number") instanceof java.util.Vector ) );
|
assertTrue("This returns array", ( eprop.getVector("number") instanceof java.util.Vector ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* now test dan's new fix where we get the first scalar
|
* now test dan's new fix where we get the first scalar
|
||||||
* when we access a vector valued
|
* when we access a vector valued
|
||||||
* property
|
* property
|
||||||
*/
|
*/
|
||||||
assert("This returns scalar", ( eprop.getString("number") instanceof String ) );
|
assertTrue("This returns scalar", ( eprop.getString("number") instanceof String ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test comma separated string properties
|
* test comma separated string properties
|
||||||
*/
|
*/
|
||||||
String prop = "hey, that's a test";
|
String prop = "hey, that's a test";
|
||||||
eprop.setProperty("prop.string", prop);
|
eprop.setProperty("prop.string", prop);
|
||||||
assert("This returns vector", ( eprop.getVector("prop.string") instanceof java.util.Vector ) );
|
assertTrue("This returns vector", ( eprop.getVector("prop.string") instanceof java.util.Vector ) );
|
||||||
|
|
||||||
String prop2 = "hey\\, that's a test";
|
String prop2 = "hey\\, that's a test";
|
||||||
eprop.remove("prop.string");
|
eprop.remove("prop.string");
|
||||||
eprop.setProperty("prop.string", prop2);
|
eprop.setProperty("prop.string", prop2);
|
||||||
assert("This returns array", ( eprop.getString("prop.string") instanceof java.lang.String) );
|
assertTrue("This returns array", ( eprop.getString("prop.string") instanceof java.lang.String) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test subset : we want to make sure that the EP doesn't reprocess the data
|
* test subset : we want to make sure that the EP doesn't reprocess the data
|
||||||
|
@ -139,9 +139,9 @@ public class TestExtendedProperties extends TestCase
|
||||||
|
|
||||||
ExtendedProperties subEprop = eprop.subset("prop");
|
ExtendedProperties subEprop = eprop.subset("prop");
|
||||||
|
|
||||||
assert("Returns the full string", subEprop.getString("string").equals( prop ) );
|
assertTrue("Returns the full string", subEprop.getString("string").equals( prop ) );
|
||||||
assert("This returns string for subset", ( subEprop.getString("string") instanceof java.lang.String) );
|
assertTrue("This returns string for subset", ( subEprop.getString("string") instanceof java.lang.String) );
|
||||||
assert("This returns array for subset", ( subEprop.getVector("string") instanceof java.util.Vector) );
|
assertTrue("This returns array for subset", ( subEprop.getVector("string") instanceof java.util.Vector) );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestHashMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestHashMap.java,v 1.2 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.1 $
|
* $Revision: 1.2 $
|
||||||
* $Date: 2001/04/21 12:22:30 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -69,7 +69,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
||||||
* @version $Id: TestHashMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $
|
* @version $Id: TestHashMap.java,v 1.2 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestHashMap extends TestMap
|
public class TestHashMap extends TestMap
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ public class TestHashMap extends TestMap
|
||||||
|
|
||||||
public void testNewMap()
|
public void testNewMap()
|
||||||
{
|
{
|
||||||
assert("New map is empty", map.isEmpty());
|
assertTrue("New map is empty", map.isEmpty());
|
||||||
assertEquals("New map has size zero", map.size(), 0);
|
assertEquals("New map has size zero", map.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestList.java,v 1.4 2001/05/04 16:34:27 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestList.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2001/05/04 16:34:27 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -80,7 +80,7 @@ import java.util.ListIterator;
|
||||||
* test case (method) your {@link List} fails.
|
* test case (method) your {@link List} fails.
|
||||||
*
|
*
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @version $Id: TestList.java,v 1.4 2001/05/04 16:34:27 rwaldhoff Exp $
|
* @version $Id: TestList.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class TestList extends TestCollection {
|
public abstract class TestList extends TestCollection {
|
||||||
public TestList(String testName) {
|
public TestList(String testName) {
|
||||||
|
@ -189,11 +189,11 @@ public abstract class TestList extends TestCollection {
|
||||||
if(tryToAdd(list,0,"element2")) {
|
if(tryToAdd(list,0,"element2")) {
|
||||||
assertEquals(1,list.size());
|
assertEquals(1,list.size());
|
||||||
if(tryToAdd(list,0,"element0")) {
|
if(tryToAdd(list,0,"element0")) {
|
||||||
assert(Arrays.equals(new String[] { "element0", "element2" },list.toArray()));
|
assertTrue(Arrays.equals(new String[] { "element0", "element2" },list.toArray()));
|
||||||
if(tryToAdd(list,1,"element1")) {
|
if(tryToAdd(list,1,"element1")) {
|
||||||
assert(Arrays.equals(new String[] { "element0", "element1", "element2" },list.toArray()));
|
assertTrue(Arrays.equals(new String[] { "element0", "element1", "element2" },list.toArray()));
|
||||||
if(tryToAdd(list,4,"element3")) {
|
if(tryToAdd(list,4,"element3")) {
|
||||||
assert(Arrays.equals(new String[] { "element0", "element1", "element2", "element3" },list.toArray()));
|
assertTrue(Arrays.equals(new String[] { "element0", "element1", "element2", "element3" },list.toArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,19 +203,19 @@ public abstract class TestList extends TestCollection {
|
||||||
public void testListAdd() {
|
public void testListAdd() {
|
||||||
List list = makeList();
|
List list = makeList();
|
||||||
if(tryToAdd(list,"1")) {
|
if(tryToAdd(list,"1")) {
|
||||||
assert(list.contains("1"));
|
assertTrue(list.contains("1"));
|
||||||
if(tryToAdd(list,"2")) {
|
if(tryToAdd(list,"2")) {
|
||||||
assert(list.contains("1"));
|
assertTrue(list.contains("1"));
|
||||||
assert(list.contains("2"));
|
assertTrue(list.contains("2"));
|
||||||
if(tryToAdd(list,"3")) {
|
if(tryToAdd(list,"3")) {
|
||||||
assert(list.contains("1"));
|
assertTrue(list.contains("1"));
|
||||||
assert(list.contains("2"));
|
assertTrue(list.contains("2"));
|
||||||
assert(list.contains("3"));
|
assertTrue(list.contains("3"));
|
||||||
if(tryToAdd(list,"4")) {
|
if(tryToAdd(list,"4")) {
|
||||||
assert(list.contains("1"));
|
assertTrue(list.contains("1"));
|
||||||
assert(list.contains("2"));
|
assertTrue(list.contains("2"));
|
||||||
assert(list.contains("3"));
|
assertTrue(list.contains("3"));
|
||||||
assert(list.contains("4"));
|
assertTrue(list.contains("4"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,20 +224,20 @@ public abstract class TestList extends TestCollection {
|
||||||
|
|
||||||
public void testListEqualsSelf() {
|
public void testListEqualsSelf() {
|
||||||
List list = makeList();
|
List list = makeList();
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
tryToAdd(list,"elt");
|
tryToAdd(list,"elt");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
tryToAdd(list,"elt2");
|
tryToAdd(list,"elt2");
|
||||||
assert(list.equals(list));
|
assertTrue(list.equals(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListEqualsArrayList() {
|
public void testListEqualsArrayList() {
|
||||||
List list1 = makeList();
|
List list1 = makeList();
|
||||||
List list2 = new ArrayList();
|
List list2 = new ArrayList();
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
assertEquals(list1.hashCode(),list2.hashCode());
|
assertEquals(list1.hashCode(),list2.hashCode());
|
||||||
tryToAdd(list1,"a");
|
tryToAdd(list1,"a");
|
||||||
assert(!list1.equals(list2));
|
assertTrue(!list1.equals(list2));
|
||||||
tryToAdd(list1,"b");
|
tryToAdd(list1,"b");
|
||||||
tryToAdd(list1,"c");
|
tryToAdd(list1,"c");
|
||||||
tryToAdd(list1,"d");
|
tryToAdd(list1,"d");
|
||||||
|
@ -247,22 +247,22 @@ public abstract class TestList extends TestCollection {
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
list2.add(it.next());
|
list2.add(it.next());
|
||||||
}
|
}
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
assertEquals(list1.hashCode(),list2.hashCode());
|
assertEquals(list1.hashCode(),list2.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListEquals() {
|
public void testListEquals() {
|
||||||
List list1 = makeList();
|
List list1 = makeList();
|
||||||
List list2 = makeList();
|
List list2 = makeList();
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
if(tryToAdd(list1,"a") && tryToAdd(list2,"a")) {
|
if(tryToAdd(list1,"a") && tryToAdd(list2,"a")) {
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
if(tryToAdd(list1,"b") && tryToAdd(list2,"b")) {
|
if(tryToAdd(list1,"b") && tryToAdd(list2,"b")) {
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
if(tryToAdd(list1,"c") && tryToAdd(list2,"c")) {
|
if(tryToAdd(list1,"c") && tryToAdd(list2,"c")) {
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
if(tryToAdd(list1,"b") && tryToAdd(list2,"b")) {
|
if(tryToAdd(list1,"b") && tryToAdd(list2,"b")) {
|
||||||
assert(list1.equals(list2));
|
assertTrue(list1.equals(list2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ public abstract class TestList extends TestCollection {
|
||||||
Object obj = list.set(i,String.valueOf(i));
|
Object obj = list.set(i,String.valueOf(i));
|
||||||
assertEquals(obj,values[i]);
|
assertEquals(obj,values[i]);
|
||||||
values[i] = String.valueOf(i);
|
values[i] = String.valueOf(i);
|
||||||
assert(Arrays.equals(values,list.toArray()));
|
assertTrue(Arrays.equals(values,list.toArray()));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(ClassCastException e) {
|
} catch(ClassCastException e) {
|
||||||
|
@ -626,10 +626,10 @@ public abstract class TestList extends TestCollection {
|
||||||
|
|
||||||
for(int i=0;i<values.length;i++) {
|
for(int i=0;i<values.length;i++) {
|
||||||
try {
|
try {
|
||||||
assert(!list.remove("X"));
|
assertTrue(!list.remove("X"));
|
||||||
assert(list.contains(values[i]));
|
assertTrue(list.contains(values[i]));
|
||||||
assert(list.remove(values[i]));
|
assertTrue(list.remove(values[i]));
|
||||||
assert(!list.contains(values[i]));
|
assertTrue(!list.contains(values[i]));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
@ -646,20 +646,20 @@ public abstract class TestList extends TestCollection {
|
||||||
Object[] values = list.toArray();
|
Object[] values = list.toArray();
|
||||||
ListIterator iter = list.listIterator();
|
ListIterator iter = list.listIterator();
|
||||||
for(int i=0;i<values.length;i++) {
|
for(int i=0;i<values.length;i++) {
|
||||||
assert( iter.hasNext() );
|
assertTrue( iter.hasNext() );
|
||||||
assert((i!=0) == iter.hasPrevious());
|
assertTrue((i!=0) == iter.hasPrevious());
|
||||||
assertEquals(values[i],iter.next());
|
assertEquals(values[i],iter.next());
|
||||||
}
|
}
|
||||||
assert(!iter.hasNext());
|
assertTrue(!iter.hasNext());
|
||||||
for(int i=values.length-1;i>=0;i--) {
|
for(int i=values.length-1;i>=0;i--) {
|
||||||
assert( iter.hasPrevious() );
|
assertTrue( iter.hasPrevious() );
|
||||||
assert((i!=(values.length-1)) == iter.hasNext());
|
assertTrue((i!=(values.length-1)) == iter.hasNext());
|
||||||
assertEquals(values[i],iter.previous());
|
assertEquals(values[i],iter.previous());
|
||||||
}
|
}
|
||||||
assert(!iter.hasPrevious());
|
assertTrue(!iter.hasPrevious());
|
||||||
for(int i=0;i<values.length;i++) {
|
for(int i=0;i<values.length;i++) {
|
||||||
assert( iter.hasNext() );
|
assertTrue( iter.hasNext() );
|
||||||
assert((i!=0) == iter.hasPrevious());
|
assertTrue((i!=0) == iter.hasPrevious());
|
||||||
assertEquals(values[i],iter.next());
|
assertEquals(values[i],iter.next());
|
||||||
assertEquals(values[i],iter.previous());
|
assertEquals(values[i],iter.previous());
|
||||||
assertEquals(values[i],iter.next());
|
assertEquals(values[i],iter.next());
|
||||||
|
@ -680,7 +680,7 @@ public abstract class TestList extends TestCollection {
|
||||||
assertEquals("previousIndex should be " + (i-1),i-1,iter.previousIndex());
|
assertEquals("previousIndex should be " + (i-1),i-1,iter.previousIndex());
|
||||||
assertEquals(values[i],iter.next());
|
assertEquals(values[i],iter.next());
|
||||||
}
|
}
|
||||||
assert(!iter.hasNext());
|
assertTrue(!iter.hasNext());
|
||||||
for(int i=values.length-1;i>=0;i--) {
|
for(int i=values.length-1;i>=0;i--) {
|
||||||
assertEquals("previousIndex should be " + i,i,iter.previousIndex());
|
assertEquals("previousIndex should be " + i,i,iter.previousIndex());
|
||||||
assertEquals("nextIndex should be " + (i+1),i+1,iter.nextIndex());
|
assertEquals("nextIndex should be " + (i+1),i+1,iter.nextIndex());
|
||||||
|
@ -716,7 +716,7 @@ public abstract class TestList extends TestCollection {
|
||||||
try {
|
try {
|
||||||
iter.set(new Integer(i));
|
iter.set(new Integer(i));
|
||||||
values[i] = new Integer(i);
|
values[i] = new Integer(i);
|
||||||
assert(Arrays.equals(values,list.toArray()));
|
assertTrue(Arrays.equals(values,list.toArray()));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(IllegalStateException e) {
|
} catch(IllegalStateException e) {
|
||||||
|
@ -727,13 +727,13 @@ public abstract class TestList extends TestCollection {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(!iter.hasNext());
|
assertTrue(!iter.hasNext());
|
||||||
for(int i=values.length-1;i>=0;i--) {
|
for(int i=values.length-1;i>=0;i--) {
|
||||||
iter.previous();
|
iter.previous();
|
||||||
try {
|
try {
|
||||||
iter.set(String.valueOf(i));
|
iter.set(String.valueOf(i));
|
||||||
values[i] = String.valueOf(i);
|
values[i] = String.valueOf(i);
|
||||||
assert(Arrays.equals(values,list.toArray()));
|
assertTrue(Arrays.equals(values,list.toArray()));
|
||||||
} catch(UnsupportedOperationException e) {
|
} catch(UnsupportedOperationException e) {
|
||||||
// expected
|
// expected
|
||||||
} catch(IllegalStateException e) {
|
} catch(IllegalStateException e) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestTreeMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestTreeMap.java,v 1.2 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
* $Revision: 1.1 $
|
* $Revision: 1.2 $
|
||||||
* $Date: 2001/04/21 12:22:30 $
|
* $Date: 2001/07/14 23:33:27 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -69,7 +69,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
||||||
* @version $Id: TestTreeMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $
|
* @version $Id: TestTreeMap.java,v 1.2 2001/07/14 23:33:27 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class TestTreeMap extends TestMap
|
public class TestTreeMap extends TestMap
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ public class TestTreeMap extends TestMap
|
||||||
|
|
||||||
public void testNewMap()
|
public void testNewMap()
|
||||||
{
|
{
|
||||||
assert("New map is empty", map.isEmpty());
|
assertTrue("New map is empty", map.isEmpty());
|
||||||
assertEquals("New map has size zero", map.size(), 0);
|
assertEquals("New map has size zero", map.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue