commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] [patch] TestList and TestCollection
Date Sat, 26 Apr 2003 10:34:53 GMT
Applied, thanks
Stephen

----- Original Message -----
From: "Neil O'Toole" <neilotoole@yahoo.com>
To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
Sent: Saturday, April 26, 2003 7:13 AM
Subject: [collections] [patch] TestList and TestCollection


> And of course, here come the actual patch files a little later...
>
> - Neil
>
> >>>>>>>>>>>
> A small bug from the glamourous side of open-source (down in the bowels
> of the test suite). TestList#BulkTestSubList was missing the
> isSetSupported() operation. This is added in the patch, as well as a
> few minor changes to the test output in TestList.java and
> TestCollection.java to make testing a bit easier, e.g.
>
>  assertTrue("Empty collection shouldn'y contain element",
>                        !collection.contains(elements[i]));
>
> becomes
>
> assertTrue("Empty collection shouldn't contain element[" + i + "]",
>                        !collection.contains(elements[i]));
>
> As a general note when writing test code, there is really no gain from
> writing succinct statements or trying to save on assignments, and it
> does make life harder for people using the test suites. So, instead of
> writing:
>
>     assertTrue( myObject.getSomething().equals( somethingElse ))
>
> we're better off doing
>
> Something s = myObject.getSomething();
> assertTrue( s.equals( somethingElse ));
>
> As that sort of code generally makes it much easier to debug (even with
> all these new-fangled fancy debuggers).
>
> - Neil
>


----------------------------------------------------------------------------
----


> Index: TestCollection.java
> ===================================================================
> RCS file:
x:/apps/cvsnt/cvs_repository/main/commons-collections-20030425/src/test/org/
apache/commons/collections/TestCollection.java,v
> retrieving revision 1.1
> diff -u -r1.1 TestCollection.java
> --- TestCollection.java 26 Apr 2003 03:37:33 -0000 1.1
> +++ TestCollection.java 26 Apr 2003 05:58:17 -0000
> @@ -579,7 +579,7 @@
>          resetEmpty();
>          elements = getFullElements();
>          for(int i = 0; i < elements.length; i++) {
> -            assertTrue("Empty collection shouldn'y contain element",
> +            assertTrue("Empty collection shouldn't contain element[" + i
+ "]",
>                         !collection.contains(elements[i]));
>          }
>          // make sure calls to "contains" don't change anything
> @@ -587,7 +587,7 @@
>
>          elements = getOtherElements();
>          for(int i = 0; i < elements.length; i++) {
> -            assertTrue("Empty collection shouldn'y contain element",
> +            assertTrue("Empty collection shouldn't contain element[" + i
+ "]",
>                         !collection.contains(elements[i]));
>          }
>          // make sure calls to "contains" don't change anything
> @@ -596,7 +596,7 @@
>          resetFull();
>          elements = getFullElements();
>          for(int i = 0; i < elements.length; i++) {
> -            assertTrue("Full collection should contain element.",
> +            assertTrue("Full collection should contain element[" + i +
"]",
>                         collection.contains(elements[i]));
>          }
>          // make sure calls to "contains" don't change anything
>


----------------------------------------------------------------------------
----


> Index: TestList.java
> ===================================================================
> RCS file:
x:/apps/cvsnt/cvs_repository/main/commons-collections-20030425/src/test/org/
apache/commons/collections/TestList.java,v
> retrieving revision 1.1
> diff -u -r1.1 TestList.java
> --- TestList.java 26 Apr 2003 03:37:34 -0000 1.1
> +++ TestList.java 26 Apr 2003 05:59:18 -0000
> @@ -804,10 +804,10 @@
>          List list = getList();
>
>          while (i > 0) {
> -            assertTrue("Iterator should have next", iter.hasPrevious());
> -            assertEquals("Iterator.nextIndex should work",
> +            assertTrue("Iterator should have previous, i:" + i,
iter.hasPrevious());
> +            assertEquals("Iterator.nextIndex should work, i:" + i,
>                iter.nextIndex(), i);
> -            assertEquals("Iterator.previousIndex should work",
> +            assertEquals("Iterator.previousIndex should work, i:" + i,
>                iter.previousIndex(), i - 1);
>              Object o = iter.previous();
>              assertEquals("Iterator returned correct element",
> @@ -816,8 +816,8 @@
>          }
>
>          assertTrue("Iterator shouldn't have previous",
!iter.hasPrevious());
> -        assertEquals("nextIndex should be 0", iter.nextIndex(), 0);
> -        assertEquals("previousIndex should be -1",
> +        assertEquals("nextIndex should be 0, actual value: " +
iter.nextIndex(), iter.nextIndex(), 0);
> +        assertEquals("previousIndex should be -1, actual value: " +
iter.previousIndex(),
>            iter.previousIndex(), -1);
>
>          try {
> @@ -1048,6 +1048,10 @@
>         protected boolean isAddSupported() {
>             return outer.isAddSupported();
>         }
> +
> + protected boolean isSetSupported() {
> + return outer.isSetSupported();
> + }
>
>
>         protected boolean isRemoveSupported() {
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message