You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2012/07/25 00:16:56 UTC

svn commit: r1365327 - /commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java

Author: kinow
Date: Tue Jul 24 22:16:56 2012
New Revision: 1365327

URL: http://svn.apache.org/viewvc?rev=1365327&view=rev
Log:
[FUNCTOR-12] Added tests for FindWithinGenerator that cover untested branches. Replaced a try/catch + fail() by @Test(expected=SomeClass.class).

Modified:
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java?rev=1365327&r1=1365326&r2=1365327&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java (original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java Tue Jul 24 22:16:56 2012
@@ -19,7 +19,6 @@ package org.apache.commons.functor.core.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.Arrays;
 import java.util.List;
@@ -29,7 +28,6 @@ import org.apache.commons.functor.BaseFu
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.adapter.LeftBoundPredicate;
 import org.apache.commons.functor.core.IsEqual;
-import org.apache.commons.functor.core.algorithm.FindWithinGenerator;
 import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
@@ -76,14 +74,19 @@ public class TestFindWithinGenerator ext
     }
 
     @Test
+    public void testEquals() {
+        FindWithinGenerator<Object> f = new FindWithinGenerator<Object>();
+        assertEquals(f,f);
+
+        assertObjectsAreEqual(f,new FindWithinGenerator<Object>());
+        assertObjectsAreEqual(new FindWithinGenerator<Object>(new Double(0)),new FindWithinGenerator<Object>(new Double(0)));
+        assertObjectsAreNotEqual(f, new FindWithinGenerator<Object>(new Integer(0)));
+    }
+
+    @Test(expected=NoSuchElementException.class)
     public void testDetect() {
         assertEquals(new Integer(3),new FindWithinGenerator<Integer>().evaluate(IteratorToGeneratorAdapter.adapt(numbers.iterator()),equalsThree));
-        try {
-            new FindWithinGenerator<Integer>().evaluate(IteratorToGeneratorAdapter.adapt(numbers.iterator()),equalsTwentyThree);
-            fail("Expected NoSuchElementException");
-        } catch(NoSuchElementException e) {
-            // expected
-        }
+        new FindWithinGenerator<Integer>().evaluate(IteratorToGeneratorAdapter.adapt(numbers.iterator()),equalsTwentyThree);
     }
 
     @Test