1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.functor.adapter;
18
19 import static org.junit.Assert.*;
20
21 import org.apache.commons.functor.BaseFunctorTest;
22 import org.apache.commons.functor.BinaryFunction;
23 import org.apache.commons.functor.BinaryProcedure;
24 import org.apache.commons.functor.core.Constant;
25 import org.apache.commons.functor.core.NoOp;
26 import org.junit.Test;
27
28
29
30
31
32 public class TestBinaryProcedureBinaryFunction extends BaseFunctorTest {
33
34
35
36
37 protected Object makeFunctor() {
38 return new BinaryProcedureBinaryFunction<Object, Object, Object>(NoOp.instance());
39 }
40
41
42
43
44 @Test
45 public void testEvaluate() throws Exception {
46 BinaryFunction<Object, Object, Object> f = new BinaryProcedureBinaryFunction<Object, Object, Object>(NoOp.instance());
47 assertNull(f.evaluate(null,null));
48 }
49
50 @Test
51 public void testEquals() throws Exception {
52 BinaryFunction<Object, Object, Object> f = new BinaryProcedureBinaryFunction<Object, Object, Object>(new NoOp());
53 assertEquals(f,f);
54 assertObjectsAreEqual(f,new BinaryProcedureBinaryFunction<Object, Object, Object>(new NoOp()));
55 assertObjectsAreNotEqual(f,Constant.of("x"));
56 assertObjectsAreNotEqual(f, new BinaryProcedureBinaryFunction<Object, Object, Object>(
57 new BinaryProcedure<Object, Object>() {
58 public void run(Object a, Object b) {
59 }
60 }));
61 assertObjectsAreNotEqual(f,Constant.of(null));
62 }
63
64 @Test
65 public void testAdaptNull() throws Exception {
66 assertNull(BinaryFunctionBinaryProcedure.adapt(null));
67 }
68
69 @Test
70 public void testAdapt() throws Exception {
71 assertNotNull(BinaryProcedureBinaryFunction.adapt(NoOp.instance()));
72 }
73 }