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
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:> 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 > _______________________________________________ > 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
Francois Beausoleil
2006-Mar-22 13:33 UTC
[Rails] Test Failure: <0.01> expected but was <0.01>
2006/3/22, Pat Maddox <pergesu@gmail.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 ! -- Fran?ois Beausoleil http://blog.teksol.info/
Maybe Matching Threads
- foreign key support in mysql adapter
- PTC 0.01 / 0.2 $ global-click.info
- how to get a row with its its p value below 0.01 ??
- Call picked up from queue and transferred gets disconnected - about 0.01% of calls
- Configuration is not applied notice: Finished catalog run in 0.01 seconds