I have two database fields, and then I have a method which shows the difference. It's simply def ev_diff ev_push - ev_fold end The value of ev_push is 0.26, value of ev_fold is 0.05, so the diff is obviously 0.01. I have an assertion written as: assert_equal 0.01, stats.ev_diff Which fails..but I have no clue why. The failure message follow: 1) Failure: test_calc_stats(HandStatsTest) [test/unit/hand_stats_test.rb:54]: <0.01> expected but was <0.01>. That makes absolutely no sense to me. It expects 0.01 and gets 0.01, but somehow fails? What's up with that? Pat
on 2006-03-22 08:53
on 2006-03-22 09:06
Hi, To assert float values, you should use: assert_in_delta expected_float, actual_float, delta Look at Test::Unit rdocumentation for details. Hope this helps. Simon Pat Maddox wrote: > assert_equal 0.01, stats.ev_diff > > Pat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > -- Simon PASQUIER Quiconnect <http://www.quiconnect.com> Tel: +33 4 56 58 61 02 Skype Name: simonpasquier This message may contain privileged or confidential information
on 2006-03-22 14:34
2006/3/22, Pat Maddox <email@example.com>: > Which fails..but I have no clue why. The failure message follow: > > 1) Failure: > test_calc_stats(HandStatsTest) [test/unit/hand_stats_test.rb:54]: > <0.01> expected but was > <0.01>. > > That makes absolutely no sense to me. It expects 0.01 and gets 0.01, > but somehow fails? What's up with that? Another option is to test the String value of each: assert_equal '0.01', stats.ev_diff.to_s Hope that helps !