[fixed] Do unit tests for fast_atof() check something ?

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
cerf
Posts: 2
Joined: Fri Apr 10, 2015 11:49 am

[fixed] Do unit tests for fast_atof() check something ?

Post by cerf »

Hello,

I was just looking the unit tests for fast_atof() in trunk/tests/fast_atof.cpp and wondering if the function testCalculation_atof() does really check something.

Here is the source code in irrlicht SVN repo :
http://sourceforge.net/p/irrlicht/code/ ... of.cpp#l84

Take a look at those lines (93 & 94) :

Code: Select all

 
        const f32 diffNew = fabs(newFastValue - atofValue) ;
        const f32 diffOld = fabs(newFastValue - atofValue) ;
        bool accurate = diffNew <= diffOld || equalsByUlp(diffNew, diffOld, 1); 
 
diffNew and diffOld have the same values, so the "accurate" test shall always return true.

Do I miss something ?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Do unit tests for fast_atof() really check something ?

Post by CuteAlien »

Thanks, should certainly use oldFastValue instead. I'll fix it later on.

edit: Fixed now in svn trunk.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
cerf
Posts: 2
Joined: Fri Apr 10, 2015 11:49 am

Re: [fixed] Do unit tests for fast_atof() check something ?

Post by cerf »

Glad to help.

Another question in my mind is why accuracy is not checked against libc's atof() too ?
Currently accuracy is only checked against old implementation of fast_atof().
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed] Do unit tests for fast_atof() check something ?

Post by CuteAlien »

Good question, don't know.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply