[TestUnit pack] Unequal equality

I've got such that output during testing my program:
[terminal_output]
Loaded suite ./niep_test
Started
....F.
Finished in 0.009922 seconds.

   1) Failure:
test_sanity(SFTester)
     [./niep_test.rb:12:in `sanity'
      ./niep_test.rb:19:in `test_sanity']:
<7.8e-11> expected but was
<7.8e-11>.

6 tests, 9 assertions, 1 failures, 0 errors
[/terminal_output]

A you can see the assert_equal function reports that something equal is not equal. WTF? Is it some bug in TestUnit package, or my program just looks to work fine?

Probably it's due to IEEE floating point inaccuracy. Try using assert_in_delta instead of assert_equal whenever you compare floats in a test.

···

On 10/15/2010 11:45 AM, felix.leg wrote:

I've got such that output during testing my program:
[terminal_output]
Loaded suite ./niep_test
Started
....F.
Finished in 0.009922 seconds.

1) Failure:
test_sanity(SFTester)
[./niep_test.rb:12:in `sanity'
./niep_test.rb:19:in `test_sanity']:
<7.8e-11> expected but was
<7.8e-11>.

6 tests, 9 assertions, 1 failures, 0 errors
[/terminal_output]

A you can see the assert_equal function reports that something equal is
not equal. WTF? Is it some bug in TestUnit package, or my program just
looks to work fine?

Welcome to floating point math. Equality is a no-no with floats. What you want is assert_in_delta.

···

On Oct 15, 2010, at 11:45 , felix.leg wrote:

A you can see the assert_equal function reports that something equal is not equal. WTF? Is it some bug in TestUnit package, or my program just looks to work fine?