#1182 New 'verify' request

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):

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!

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

I'd like to be able to compare Float values, approximately

See sys::Float.approx

And as long as I'm asking, it'd be nice to have some way to verify that a method throws a specific exception.

See sys::Test.verifyErr

yachris Fri 27 Aug 2010

Cool, thanks.

Login or Signup to reply.