Re: [Cppunit-devel] CPPUNIT_ASSERT_DOUBLES_EQUAL() with non-finite numbers
Brought to you by:
blep
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-16 10:05:02
|
CppUnit development mailing list wrote: > Contrary to the claim of Baptiste in the latter patch, isnan() > is standard: it is part of C99. Hopefully we can assume it is > portable by now. > My patch (below) uses isfinite() instead, which is also from C99. C99 is non-standard in the context of C++, which is a superset of C90. So, all C++ compilers might not support this. I've understood that there is a new C++ standard in the works (or is it out already), which is supposed to be a superset of C99. Of course using that is not exactly portable, especially with older compilers. > First, here are additional test cases to nail down the semantics of CPPUNIT_ASSERT_DOUBLES: > - NaN is not equal to anything, not even to another NaN > - infinity is equal to infinity Remember the sign in infinity. Why not then compare NaNs with (maybe with volatile x): if(x == x) { /* not NaN */ } Don't know about portable infinity test, though? -- Tuomo |