One of my tests with assert_equal has the message:
<5.0e-006> expected but was
<5.0e-006>.
What seems to be this error?
One of my tests with assert_equal has the message:
<5.0e-006> expected but was
<5.0e-006>.
What seems to be this error?
On Feb 3, 9:35 am, Ranieri T. [email protected] wrote:
Pará (UFPA)http://rubytags.blogspot.com/
Can you post some of the code around this test? Chances are you are
testing for equality with real numbers and it’s rare that they will
ever be exactly equal. A similar situation arises with testing time.
The time object is stored internally in milliseconds, but visually it
is displayed in seconds. This results in failed tests with:
<10:01 AM Sun Feb 3 2008> expected but was
<10:01 AM Sub Fep 3 2008>.
The solution is to use a delta time to be used as a margin of error.
time_delta = 100
assert_in_delta time1, time2, time_delta
I used time as an example, but should work for any real numbers
Ranieri T. wrote:
One of my tests with assert_equal has the message:
<5.0e-006> expected but was
<5.0e-006>.
What seems to be this error?
Read this and you’ll understand.
“What Every Computer Scientist Should Know About Floating-Point”
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Clifford H…
Thanks for the help.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs