commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ki...@apache.org
Subject svn commit: r1365327 - /commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
Date Tue, 24 Jul 2012 22:16:56 GMT
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



Mime
View raw message