### Question:
DoubleSumAggregatorBinaryFunction implements BinaryFunction<Double, Double, Double> { public Double evaluate(Double left, Double right) { if (left == null) { return right; } if (right == null) { return left; } return left + right; }  Double evaluate(Double left, Double right); @Override String toString();  }### Answer:
@Test public void testNulls() throws Exception { DoubleSumAggregatorBinaryFunction fct = (DoubleSumAggregatorBinaryFunction)makeFunctor(); Double d = fct.evaluate(null, null); assertNull( d ); d = fct.evaluate( null, 1.0 ); assertEquals( 1.0, d.doubleValue(), DELTA ); d = fct.evaluate( 2.0, null ); assertEquals( 2.0, d.doubleValue(), DELTA ); }
@Test public void testSum() throws Exception { DoubleSumAggregatorBinaryFunction fct = (DoubleSumAggregatorBinaryFunction)makeFunctor(); double total = 0.0; double result = 0.0; int calls = 31; Random rnd = new Random(); for( int i = 0; i < calls; i++ ) { double number = rnd.nextDouble(); total += number; result = fct.evaluate(result, number); assertEquals( result, total, DELTA ); } }