Page 1 of 1

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

Posted: Fri Apr 10, 2015 12:36 pm
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 ?

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

Posted: Fri Apr 10, 2015 1:18 pm
by CuteAlien
Thanks, should certainly use oldFastValue instead. I'll fix it later on.

edit: Fixed now in svn trunk.

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

Posted: Mon Apr 13, 2015 9:26 am
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().

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

Posted: Mon Apr 13, 2015 9:46 am
by CuteAlien
Good question, don't know.