commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/comparators TestComparator.java
Date Fri, 01 Mar 2002 23:30:58 GMT
morgand     02/03/01 15:30:58

  Modified:    collections/src/test/org/apache/commons/collections/comparators
                        TestComparator.java
  Log:
  renamed random sort test to more appropriate reverse sort, and
  added real random sort test
  
  Revision  Changes    Path
  1.3       +27 -1     jakarta-commons/collections/src/test/org/apache/commons/collections/comparators/TestComparator.java
  
  Index: TestComparator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/comparators/TestComparator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestComparator.java	1 Mar 2002 19:42:42 -0000	1.2
  +++ TestComparator.java	1 Mar 2002 23:30:58 -0000	1.3
  @@ -4,6 +4,7 @@
   import java.io.Serializable;
   import java.util.Collections;
   import java.util.Comparator;
  +import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
   
  @@ -36,6 +37,10 @@
           Collections.reverse(list);
       }
   
  +    public void randomizeObjects(List list) {
  +        Collections.shuffle(list);
  +    }
  +
       /**
        * Sort object according to the given Comparator.
        * 
  @@ -66,7 +71,7 @@
                      list2.equals(list));
       }
   
  -    public void testRandomListSort() {
  +    public void testReverseListSort() {
           Comparator comparator = makeComparator();
   
           List randomList = getComparableObjectsOrdered();
  @@ -74,6 +79,27 @@
           sortObjects(randomList,comparator);
   
           List orderedList = getComparableObjectsOrdered();
  +
  +        assertTrue("Comparator did not reorder the List correctly",
  +                   orderedList.equals(randomList));
  +
  +    }
  +
  +    public void testRandomListSort() {
  +        Comparator comparator = makeComparator();
  +
  +        List randomList = getComparableObjectsOrdered();
  +        randomizeObjects(randomList);
  +        sortObjects(randomList,comparator);
  +
  +        List orderedList = getComparableObjectsOrdered();
  +
  +        /* debug 
  +        Iterator i = randomList.iterator();
  +        while (i.hasNext()) {
  +            System.out.println(i.next());
  +        }
  +        */
   
           assertTrue("Comparator did not reorder the List correctly",
                      orderedList.equals(randomList));
  
  
  

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


Mime
View raw message