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 TestComparatorChain.java
Date Tue, 19 Mar 2002 22:25:58 GMT
morgand     02/03/19 14:25:58

  Modified:    collections/src/test/org/apache/commons/collections/comparators
                        TestComparatorChain.java
  Log:
  now throws an exception for comparisons on an empty chain and
  added no-op constructor
  
  Revision  Changes    Path
  1.2       +46 -0     jakarta-commons/collections/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java
  
  Index: TestComparatorChain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestComparatorChain.java	1 Mar 2002 23:31:35 -0000	1.1
  +++ TestComparatorChain.java	19 Mar 2002 22:25:58 -0000	1.2
  @@ -31,6 +31,52 @@
           return chain;
       }
   
  +    public void testNoopComparatorChain() {
  +        ComparatorChain chain = new ComparatorChain();
  +        Integer i1 = new Integer(4);
  +        Integer i2 = new Integer(6);
  +        chain.addComparator(new ComparableComparator());
  +
  +        int correctValue = i1.compareTo(i2);
  +        assertTrue("Comparison returns the right order",chain.compare(i1,i2) == correctValue);
  +    }
  +
  +    public void testBadNoopComparatorChain() {
  +        ComparatorChain chain = new ComparatorChain();
  +        Integer i1 = new Integer(4);
  +        Integer i2 = new Integer(6);
  +        try {
  +            chain.compare(i1,i2);
  +            fail("An exception should be thrown when a chain contains zero comparators.");
  +        } catch (UnsupportedOperationException e) {
  +
  +        }
  +    }
  +
  +    public void testListComparatorChain() {
  +        List list = new LinkedList();
  +        list.add(new ComparableComparator());
  +        ComparatorChain chain = new ComparatorChain(list);
  +        Integer i1 = new Integer(4);
  +        Integer i2 = new Integer(6);
  +
  +        int correctValue = i1.compareTo(i2);
  +        assertTrue("Comparison returns the right order",chain.compare(i1,i2) == correctValue);
  +    }
  +
  +    public void testBadListComparatorChain() {
  +        List list = new LinkedList();
  +        ComparatorChain chain = new ComparatorChain(list);
  +        Integer i1 = new Integer(4);
  +        Integer i2 = new Integer(6);
  +        try {
  +            chain.compare(i1,i2);
  +            fail("An exception should be thrown when a chain contains zero comparators.");
  +        } catch (UnsupportedOperationException e) {
  +
  +        }
  +    }
  +
       public List getComparableObjectsOrdered() {
           List list = new LinkedList();
           // this is the correct order assuming a
  
  
  

--
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