commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r689992 - in /commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter: TestAll.java TestBinaryFunctionUnaryFunction.java
Date Thu, 28 Aug 2008 21:19:53 GMT
Author: mbenson
Date: Thu Aug 28 14:19:52 2008
New Revision: 689992

URL: http://svn.apache.org/viewvc?rev=689992&view=rev
Log:
add test for BinaryFunctionUnaryFunction

Added:
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java
  (with props)
Modified:
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestAll.java

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestAll.java?rev=689992&r1=689991&r2=689992&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestAll.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestAll.java
Thu Aug 28 14:19:52 2008
@@ -39,6 +39,7 @@
         suite.addTest(TestProcedureFunction.suite());
         suite.addTest(TestUnaryProcedureUnaryFunction.suite());
         suite.addTest(TestBinaryProcedureBinaryFunction.suite());
+        suite.addTest(TestBinaryFunctionUnaryFunction.suite());
 
         suite.addTest(TestFunctionPredicate.suite());
         suite.addTest(TestUnaryFunctionUnaryPredicate.suite());

Added: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java?rev=689992&view=auto
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java
(added)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java
Thu Aug 28 14:19:52 2008
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.adapter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.core.Constant;
+import org.apache.commons.functor.core.IsNotSame;
+import org.apache.commons.functor.core.IsSame;
+
+/**
+ * @version $Revision$ $Date$
+ * @author Matt Benson
+ */
+public class TestBinaryFunctionUnaryFunction extends BaseFunctorTest {
+
+    // Conventional
+    // ------------------------------------------------------------------------
+
+    public TestBinaryFunctionUnaryFunction(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestBinaryFunctionUnaryFunction.class);
+    }
+
+    // Functor Testing Framework
+    // ------------------------------------------------------------------------
+
+    protected Object makeFunctor() {
+        return new BinaryFunctionUnaryFunction<Object, Object>(BinaryPredicateBinaryFunction.adapt(IsSame.INSTANCE));
+    }
+
+    // Lifecycle
+    // ------------------------------------------------------------------------
+
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // Tests
+    // ------------------------------------------------------------------------
+
+    public void testTestWhenTrue() throws Exception {
+        UnaryFunction<Object, Boolean> f = new BinaryFunctionUnaryFunction<Object,
Boolean>(BinaryPredicateBinaryFunction.adapt(IsSame.INSTANCE));
+        assertTrue(f.evaluate(null));
+    }
+
+    public void testTestWhenFalse() throws Exception {
+        UnaryFunction<Object, Boolean> f = new BinaryFunctionUnaryFunction<Object,
Boolean>(BinaryPredicateBinaryFunction.adapt(IsNotSame.INSTANCE));
+        assertFalse(f.evaluate(null));
+    }
+
+    public void testEquals() throws Exception {
+        UnaryFunction<Object, Boolean> f = new BinaryFunctionUnaryFunction<Object,
Boolean>(BinaryPredicateBinaryFunction.adapt(IsSame.INSTANCE));
+        assertEquals(f, f);
+        assertObjectsAreEqual(f, new BinaryFunctionUnaryFunction<Object, Boolean>(BinaryPredicateBinaryFunction.adapt(IsSame.INSTANCE)));
+        assertObjectsAreNotEqual(f, Constant.truePredicate());
+        assertObjectsAreNotEqual(f, new BinaryFunctionUnaryFunction<Object, Boolean>(BinaryPredicateBinaryFunction.adapt(IsNotSame.INSTANCE)));
+    }
+
+    public void testAdaptNull() throws Exception {
+        assertNull(BinaryFunctionUnaryFunction.adapt(null));
+    }
+
+    public void testAdapt() throws Exception {
+        assertNotNull(BinaryFunctionUnaryFunction.adapt(Constant.TRUE));
+    }
+}

Propchange: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionUnaryFunction.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Thu Aug 28 14:19:52 2008
@@ -0,0 +1,5 @@
+Date
+Author
+Id
+Revision
+HeadURL



Mime
View raw message