From: Joel VanderWerf Date: 2010-10-16T03:57:31+09:00 Subject: Re: [TestUnit pack] Unequal equality 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? > 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.