assert_equal problem

  • Thread starter Ranieri Teixeira
  • Start date
R

Ranieri Teixeira

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?

--=20
Ranieri Barros Teixeira
Ci=EAncia da Computa=E7=E3o - Faculdade de Computa=E7=E3o - Universidade F=
ederal do
Par=E1 (UFPA)
http://rubytags.blogspot.com/
 
R

Reacher

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?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top