I'd like to be able to compare Float values, approximately. From a project I'm working on (no, I'm not reimplementing basic math, this is just a simplification):
verifyEq(3.3f, o.sum(1.1f, 2.2f))
This fails with:
sys::TestErr: Test failed: 3.3 != 3.3000000000000003
I've seen other test frameworks with something like:
verifyEqDelta(3.3f, o.sum(1.1f, 2.2f), 0.00001)
which is much nicer than:
verify((3.3f - o.sum(1.1f, 2.2f)).abs < 0.00001f)
Thanks!
yachrisFri 27 Aug 2010
And as long as I'm asking, it'd be nice to have some way to verify that a method throws a specific exception.
brianFri 27 Aug 2010
I'd like to be able to compare Float values, approximately
yachris Fri 27 Aug 2010
Hello,
I'd like to be able to compare Float values, approximately. From a project I'm working on (no, I'm not reimplementing basic math, this is just a simplification):
This fails with:
I've seen other test frameworks with something like:
which is much nicer than:
Thanks!
yachris Fri 27 Aug 2010
And as long as I'm asking, it'd be nice to have some way to verify that a method throws a specific exception.
brian Fri 27 Aug 2010
See
sys::Float.approx
See
sys::Test.verifyErr
yachris Fri 27 Aug 2010
Cool, thanks.