Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
assert_equal problem
Ranieri Teixeira
2/3/2008 2:35:00 PM
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.blo...
3 Answers
Reacher
2/3/2008 3:04:00 PM
0
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.blo...
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
Clifford Heath
2/3/2008 8:24:00 PM
0
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_goldber...
Clifford Heath.
Ranieri Teixeira
2/4/2008 10:17:00 PM
0
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_goldber...
>
> Clifford Heath.
>
>
--=20
Ranieri Barros Teixeira
Ci=EAncia da Computa=E7=E3o - Faculdade de Computa=E7=E3o - Universidade F=
ederal do
Par=E1 (UFPA)
http://rubytags.blo...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
assert_equal problem
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password