net.sf.molae.pipe.test
Class BinaryFunctionTest<B extends BinaryFunction<S1,S2,T>,S1,S2,T>

java.lang.Object
  extended by org.junit.Assert
      extended by net.sf.molae.pipe.test.ObjectTest<B>
          extended by net.sf.molae.pipe.test.BinaryFunctionTest<B,S1,S2,T>
Direct Known Subclasses:
S2BinaryFunctionTest

public class BinaryFunctionTest<B extends BinaryFunction<S1,S2,T>,S1,S2,T>
extends ObjectTest<B>

Test methods to check the contract of BinaryFunction implementing classes.


Constructor Summary
protected BinaryFunctionTest(B testObject)
          Creates a new test with the specified candidate.
 
Method Summary
 void assertConsistency()
          Checks consistency of all reading methods.
static
<S1,S2,T> BinaryFunctionTest<BinaryFunction<S1,S2,T>,S1,S2,T>
getInstance(BinaryFunction<S1,S2,T> testObject)
          Creates a new instance of this class with the specified testObject as test object.
 void testWith(Object arg1)
          Performs various tests using the specified object as identity element and sink.
protected  void testWith(S1 arg1, S1 arg2, S2 arg3)
          Placeholder for associativity tests.
 void testWith(S1 arg1, S2 arg2)
          Performs various tests using the specified objects as arguments to the compute function of the tested binary function.
 
Methods inherited from class net.sf.molae.pipe.test.ObjectTest
assertFalse, assertTestValuesSet, getTestObject, setTestValuesSet, toString
 
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinaryFunctionTest

protected BinaryFunctionTest(B testObject)
Creates a new test with the specified candidate.

Parameters:
testObject - the candidate of the test
Throws:
NullPointerException - if the specified test objects is null.
Method Detail

getInstance

public static final <S1,S2,T> BinaryFunctionTest<BinaryFunction<S1,S2,T>,S1,S2,T> getInstance(BinaryFunction<S1,S2,T> testObject)
Creates a new instance of this class with the specified testObject as test object.

Parameters:
testObject - the candidate of the test
Returns:
an instance of this class with the specified testObject as test object.
Throws:
NullPointerException - if the specified test objects is null.

assertConsistency

public void assertConsistency()
Checks consistency of all reading methods.

Overrides:
assertConsistency in class ObjectTest<B extends BinaryFunction<S1,S2,T>>
Throws:
AssertionFailedError - if the BinaryFunction contract is broken by the test object.

testWith

public void testWith(S1 arg1,
                     S2 arg2)
Performs various tests using the specified objects as arguments to the compute function of the tested binary function.

Parameters:
arg1 - a valid left argument to the underlying binary function
arg2 - a valid right argument to the underlying binary function
Throws:
AssertionFailedError - if the BinaryFunction contract is broken by the test object.

testWith

public void testWith(Object arg1)
Performs various tests using the specified object as identity element and sink.

Parameters:
arg1 - an arbitrary object
Throws:
AssertionFailedError - if the BinaryFunction contract is broken by the test object.

testWith

protected void testWith(S1 arg1,
                        S1 arg2,
                        S2 arg3)
Placeholder for associativity tests.

Parameters:
arg1 - a valid left argument to the underlying binary function
arg2 - a valid left and right argument to the underlying binary function
arg3 - a valid right argument to the underlying binary function
Throws:
AssertionFailedError - if the BinaryFunction contract is broken by the test object.