commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor TestAlgorithms.java
Date Tue, 25 Nov 2003 21:29:17 GMT
rwaldhoff    2003/11/25 13:29:17

  Modified:    functor/src/test/org/apache/commons/functor
                        TestAlgorithms.java
  Log:
  improved test
  
  Revision  Changes    Path
  1.9       +11 -11    jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/TestAlgorithms.java
  
  Index: TestAlgorithms.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/TestAlgorithms.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestAlgorithms.java	25 Nov 2003 21:24:19 -0000	1.8
  +++ TestAlgorithms.java	25 Nov 2003 21:29:17 -0000	1.9
  @@ -225,23 +225,17 @@
   
       public void testApplyToGenerator() {
           Generator gen = new IntegerRange(1,5);
  -        UnaryFunction dbl = new UnaryFunction() {
  -            public Object evaluate(Object obj) {
  -                return new Integer(2*((Number)obj).intValue());
  -            }
  -        };
           Summer summer = new Summer();
                   
  -        Algorithms.apply(gen,dbl).run(summer);
  +        Algorithms.apply(gen,new Doubler()).run(summer);
           
           assertEquals(2*(1+2+3+4),summer.sum);
       }
   
       public void testApply() {
  -        Collection result = IteratorToGeneratorAdapter.adapt(Algorithms.apply(list.iterator(),IdentityFunction.instance())).toCollection();
  +        Collection result = IteratorToGeneratorAdapter.adapt(Algorithms.apply(list.iterator(),new
Doubler())).toCollection();
           assertNotNull(result);
  -        assertEquals(list.size(),result.size());
  -        assertEquals(list,result);
  +        assertEquals(doubled,result);
       }
   
       public void testApply2() {
  @@ -347,5 +341,11 @@
               sum += ((Number)that).intValue();
           }
           public int sum = 0;
  +    }
  +    
  +    static class Doubler implements UnaryFunction {
  +        public Object evaluate(Object obj) {
  +            return new Integer(2*((Number)obj).intValue());
  +        }
       }
   }
  
  
  

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