benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

Force users to specify delta in 'isEqualTo' for error margin in float and double assertions #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From Martin Ankerl:

Float and Double should not allow isEqualTo(). You should be forced to
specify an epsilon for error margin.

Original issue reported on code.google.com by Alex.Rui...@gmail.com on 24 Sep 2007 at 2:08

GoogleCodeExporter commented 9 years ago
Double Assert already had this functionality. Users can either use the regular
'isEqualTo(double)' or the version using a delta:

 double result = total(price, discount);
 assertThat(result).withDelta(0.4d).isEqualTo(expected);

Not sure if we need to do this for float, for example, JUnit offers this
functionality for double only.

Original comment by Alex.Rui...@gmail.com on 15 Oct 2007 at 6:13

GoogleCodeExporter commented 9 years ago
Float should support this too. Not only double. I particularly don't like the 
syntax:

  assertThat(result).withDelta(0.4d).isEqualTo(expected);

It would be better to have something like:

  assertThat(result).isEqualTo(expected, delta(0.4d));

We should always require the error margin. I'll take care of this bug.

Original comment by wanghy1...@gmail.com on 8 Nov 2007 at 11:06

GoogleCodeExporter commented 9 years ago
Removed 'withDelta' from DoubleAssert.

Added isEqualTo(expected, delta(value)) to both DoubleAssert and FloatAssert.

Original comment by wanghy1...@gmail.com on 9 Nov 2007 at 5:58

GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 12:13