My patch is currently in moderation because it's to large to be accepted
automatically. So while I'm waiting to get mod approval here is the
description of what the patch does, just to let you all know it's ready.

I've just finished the relative error patch, I of course added all the tests
as well. This is a new feature and doesn't touch and of the existing
functions, so it should be an easy addition. It does however, require cmath
for the fabs function, if this is a problem and someone can offer a non
library dependent absolute value function I'd be happy to replace fabs. VC++
has a fabs funcion but I'm not sure about the includes nessecary for it,
etc. It also treats comparisons with zero as a special case, to avoid
division by zero it calls AreClose for (expected==0.0).

The interface is as follows:

For all instances of the *CLOSE macro or *Close function the word RELATIVELY
or Relatively have been appended.

Example

CHECK_RELATIVELY_CLOSE(1.0f,1.
01f,0.01f)


On Thu, Feb 4, 2010 at 4:36 PM, Sean Farrell <sean.farr...@rioki.org> wrote:

> Hi looks interesting.
>
> Since it is very small and portable, care to make a patch?
>
> Sean
>
> On Thu, Feb 4, 2010 at 9:18 PM, Charles Mark Maynard <cmayn...@gmail.com>
> wrote:
> > Hello all, I have been using UnitTest++ and am currently working on a
> > project and researching 3 numerical libraries(TET,GSL,BOOST MATH). While
> > testing I've ran into a problem using CHECK_ARRAY_CLOSE. It is not a bug,
> > but rather that in some cases the numbers are so large that is would be
> > better to check relative error then absolute. I would like to propose a
> new
> > comparison test CHECK_ARRAY_RELATIVE, which would use relative error
> instead
> > for values larger than the tolerance value.
> >
> > Currently I have resorted to using the following conditional to check
> > absolute or relatvie based on the size of the values I'm comparing:
> >
> > bool pass=true;
> > //choose between checking relative or absolute error
> > if(fabs(pnm.TET_pnm_r()[j])<accuracy ||
> fabs(pnm.GSL_pnm_r()[j])<accuracy)
> > {
> >   //absolute error
> >   if(fabs(pnm.TET_pnm_r()[j]-pnm.GSL_pnm_r()[j])<accuracy)
> >     std::cout<<"Absolute N: "<<n<<" M: "<<m<<" TET:
> "<<pnm.TET_pnm_r()[j]<<"
> > GSL: " << pnm.GSL_pnm_r()[j]<<" RIGHT\n";
> >   else
> >   {
> >     std::cout<<"***** Absolute N: "<<n<<" M: "<<m<<" TET:
> > "<<pnm.TET_pnm_r()[j]<<" GSL: " << pnm.GSL_pnm_r()[j]<<" WRONG\n";
> >     pass=false;
> >   }
> > }
> > else
> > {
> >   //relative error
> >
> >
> if((fabs(pnm.TET_pnm_r()[j]-pnm.GSL_pnm_r()[j])/pnm.TET_pnm_r()[j])<accuracy)
> >     std::cout<<"Relative N: "<<n<<" M: "<<m<<" TET:
> "<<pnm.TET_pnm_r()[j]<<"
> > GSL: " << pnm.GSL_pnm_r()[j]<<" RIGHT\n";
> >   else
> >   {
> >     std::cout<<"***** Relative N: "<<n<<" M: "<<m<<" TET:
> > "<<pnm.TET_pnm_r()[j]<<" GSL: " << pnm.GSL_pnm_r()[j]<<" WRONG\n";
> >     pass=false;
> >   }
> > }
> >
> > Let me know if this is of interest, I would be willing to help with
> > development. I've looked at through the repository, and this shouldn't
> take
> > too much effort to add, mostly a new AreRelativelyClose method and a less
> > than comparison of the expected term with the tolerance to decide which
> one
> > to call.
> >
> > Cheers,
> > Mark
> >
> >
> ------------------------------------------------------------------------------
> > The Planet: dedicated and managed hosting, cloud storage, colocation
> > Stay online with enterprise data centers and the best network in the
> > business
> > Choose flexible plans and management services without long-term contracts
> > Personal 24x7 support from experience hosting pros just a phone call
> away.
> > http://p.sf.net/sfu/theplanet-com
> > _______________________________________________
> > unittest-cpp-devel mailing list
> > unittest-cpp-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel
> >
> >
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> unittest-cpp-devel mailing list
> unittest-cpp-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel
>
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
unittest-cpp-devel mailing list
unittest-cpp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel

Reply via email to