Assert_equal problem

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?

···

--
Ranieri Barros Teixeira
Ciência da Computação - Faculdade de Computação - Universidade Federal do
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

···

On Feb 3, 9:35 am, Ranieri Teixeira <ranieri...@gmail.com> 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?

--
Ranieri Barros Teixeira
Ciência da Computação - Faculdade de Computação - Universidade Federal do
Pará (UFPA)http://rubytags.blogspot.com/

Ranieri Teixeira 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&gt;

Clifford Heath.

Thanks for the help.

···

On Feb 3, 2008 5:24 PM, Clifford Heath <no@spam.please.net> wrote:

Ranieri Teixeira 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&gt;

Clifford Heath.

--
Ranieri Barros Teixeira
Ciência da Computação - Faculdade de Computação - Universidade Federal do
Pará (UFPA)
http://rubytags.blogspot.com/