cppunit-devel Mailing List for CppUnit - C++ port of JUnit (Page 4)
Brought to you by:
blep
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
(21) |
May
(96) |
Jun
(109) |
Jul
(42) |
Aug
(6) |
Sep
(106) |
Oct
(60) |
Nov
(20) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(7) |
Feb
(11) |
Mar
(49) |
Apr
(124) |
May
(30) |
Jun
(37) |
Jul
(53) |
Aug
(33) |
Sep
(21) |
Oct
(22) |
Nov
(19) |
Dec
(15) |
2003 |
Jan
(34) |
Feb
(25) |
Mar
(11) |
Apr
(12) |
May
(16) |
Jun
(24) |
Jul
(23) |
Aug
(23) |
Sep
(42) |
Oct
(7) |
Nov
(32) |
Dec
(33) |
2004 |
Jan
(41) |
Feb
(41) |
Mar
(24) |
Apr
(25) |
May
(18) |
Jun
(13) |
Jul
(11) |
Aug
(15) |
Sep
(22) |
Oct
(10) |
Nov
(15) |
Dec
(9) |
2005 |
Jan
(4) |
Feb
(15) |
Mar
(11) |
Apr
(16) |
May
(29) |
Jun
(17) |
Jul
(27) |
Aug
(12) |
Sep
(9) |
Oct
(10) |
Nov
(5) |
Dec
(6) |
2006 |
Jan
(2) |
Feb
(6) |
Mar
(7) |
Apr
(2) |
May
(1) |
Jun
(5) |
Jul
(8) |
Aug
(6) |
Sep
(10) |
Oct
(11) |
Nov
(15) |
Dec
(2) |
2007 |
Jan
(12) |
Feb
(22) |
Mar
(10) |
Apr
(7) |
May
(1) |
Jun
(8) |
Jul
(4) |
Aug
(1) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
|
2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-31 20:18:06
|
Folks - I am a novice user of cppUnit but a pretty experienced one of JUnit & MbUnit. I was wondering if one of you could provide an answer to the following query: JUnit & MbUnit have the capability to loop over test cases defined in XML files, parse them, dynamically create test cases and run these test cases using their respective runners - I was wondering if cppUnit offered the same capability so that I could refrain from statically defining all my test cases. This would permit me to execute the same sequence of test steps though with disparate data defined in these XML files Any hints, suggestions will be greatly appreciated. Thanks Ranji Raghavan Software Developer OpenSpirit Corporation Sugar Land, TX - 77478 Phone: (281)295-1427 Email: ran...@op... |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-24 22:28:21
|
> I am not at all familiar with windows API. Your patch changes a > couple of calls from "foo()" to "fooA()"; how do the "A" functions > different from their non-A version? Does this now *require* > compilation in unicode? What does that mean, exactly? It is quite simple (?) In the Win32 API, every function taking a string in argument (or a=20 structure containing strings) exists in two versions : - the A version : ANSI, takes "strings" of char - the W version : UNICODE, takes L"strings" of WCHAR The "normal" untagged version is in fact a define : If UNICODE is defined, the define is bound to the W version. If not, the define is bound to the A version. Ugly example taken from winbase.h : WINBASEAPI HMODULE WINAPI LoadLibraryA( LPCSTR lpLibFileName ); WINBASEAPI HMODULE WINAPI LoadLibraryW( LPCWSTR lpLibFileName ); #ifdef UNICODE #define LoadLibrary LoadLibraryW #else #define LoadLibrary LoadLibraryA #endif // !UNICODE Furthermore, there is something like this in winnt.h : typedef wchar_t WCHAR; // wc, 16-bit UNICODE character #ifdef UNICODE // r_winnt typedef WCHAR TCHAR, *PTCHAR; #else /* UNICODE */ // r_winnt typedef char TCHAR, *PTCHAR; #endif /* UNICODE */ // r_winnt An UNICODE program : - store strings into WCHAR[] instead of char[] - calls the UNICODE "W" API instead of the classic ANSI "A" API. Because each character is coded on 16 bits, it can store any character=20 in the world without having to deal with codepages. Windows NT works=20 internally in UNICODE, so UNICODE programs are the best choice for=20 Windows NT. But they don't work on Win9x. Thanks to the UNICODE define, a program written carefully with TCHAR=20 instead of char (and a LOT of other macros) can be compiled either in=20 ANSI or UNICODE version. CppUnit is not UNICODE-aware, because it stores its strings in=20 std::string, which is internally a char[]. So it should always call the=20 ANSI version of the Win32 API, regardless to the UNICODE define. My patch just replaces the untagged Win32 functions with the specific A=20 versions. When UNICODE is not defined, there is absolutely no difference with or=20 without my patch. But when UNICODE is defined, the file Win32DynamicLibraryManager.cpp=20 does not compile becauses it passes std::string (which are always ANSI=20 as far as I know) to the UNICODE "W" API. It fails with type mismatch. The simpliest solution to make this source compile when UNICODE is=20 defined is to call explicitly the ANSI API. Another solution may have been to convert the strings before calling the=20 generic API. And of course, the best solution would be to make CppUnit fully=20 unicode-aware (not using std::string but... I don't know what). In conclusion : this tiny patch avoids compilation errors when compiling=20 the CppUnit library when UNICODE is defined. But of course it is not=20 required to define it ! You may ask : "Why the hell do you compile CppUnit with UNICODE defined=20 ?" Well, it's just to have exactly the same compilation options for all=20 the static libraries composing my projects - including CppUnit itself. Vincent Rivi=E8re vri...@us... |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-24 22:26:49
|
> I am not at all familiar with windows API. Your patch changes a > couple of calls from "foo()" to "fooA()"; how do the "A" functions > different from their non-A version? Does this now *require* > compilation in unicode? What does that mean, exactly? It is quite simple (?) In the Win32 API, every function taking a string in argument (or a=20 structure containing strings) exists in two versions : - the A version : ANSI, takes "strings" of char - the W version : UNICODE, takes L"strings" of WCHAR The "normal" untagged version is in fact a define : If UNICODE is defined, the define is bound to the W version. If not, the define is bound to the A version. Ugly example taken from winbase.h : WINBASEAPI HMODULE WINAPI LoadLibraryA( LPCSTR lpLibFileName ); WINBASEAPI HMODULE WINAPI LoadLibraryW( LPCWSTR lpLibFileName ); #ifdef UNICODE #define LoadLibrary LoadLibraryW #else #define LoadLibrary LoadLibraryA #endif // !UNICODE Furthermore, there is something like this in winnt.h : typedef wchar_t WCHAR; // wc, 16-bit UNICODE character #ifdef UNICODE // r_winnt typedef WCHAR TCHAR, *PTCHAR; #else /* UNICODE */ // r_winnt typedef char TCHAR, *PTCHAR; #endif /* UNICODE */ // r_winnt An UNICODE program : - store strings into WCHAR[] instead of char[] - calls the UNICODE "W" API instead of the classic ANSI "A" API. Because each character is coded on 16 bits, it can store any character=20 in the world without having to deal with codepages. Windows NT works=20 internally in UNICODE, so UNICODE programs are the best choice for=20 Windows NT. But they don't work on Win9x. Thanks to the UNICODE define, a program written carefully with TCHAR=20 instead of char (and a LOT of other macros) can be compiled either in=20 ANSI or UNICODE version. CppUnit is not UNICODE-aware, because it stores its strings in=20 std::string, which is internally a char[]. So it should always call the=20 ANSI version of the Win32 API, regardless to the UNICODE define. My patch just replaces the untagged Win32 functions with the specific A=20 versions. When UNICODE is not defined, there is absolutely no difference with or=20 without my patch. But when UNICODE is defined, the file Win32DynamicLibraryManager.cpp=20 does not compile becauses it passes std::string (which are always ANSI=20 as far as I know) to the UNICODE "W" API. It fails with type mismatch. The simpliest solution to make this source compile when UNICODE is=20 defined is to call explicitly the ANSI API. Another solution may have been to convert the strings before calling the=20 generic API. And of course, the best solution would be to make CppUnit fully=20 unicode-aware (not using std::string but... I don't know what). In conclusion : this tiny patch avoids compilation errors when compiling=20 the CppUnit library when UNICODE is defined. But of course it is not=20 required to define it ! You may ask : "Why the hell do you compile CppUnit with UNICODE defined=20 ?" Well, it's just to have exactly the same compilation options for all=20 the static libraries composing my projects - including CppUnit itself. Vincent Rivi=E8re vri...@us... |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-24 03:04:49
|
On Tue, Jan 16, 2007 at 08:38:25PM +0100, CppUnit development mailing list wrote: > Happy to see some activity here again ! > > Here is a small patch to allow the compilation of CppUnit in UNICODE. > The only file affected is Win32DynamicLibraryManager.cpp I am not at all familiar with windows API. Your patch changes a couple of calls from "foo()" to "fooA()"; how do the "A" functions different from their non-A version? Does this now *require* compilation in unicode? What does that mean, exactly? -Steve |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-18 11:30:03
|
Hi, I am building the CPPUNIT on linux i have followed the following steps to build it .. STEPS 1. ./configure 2. make 3. make check 4. make install Now when i am at step 3 i.e when giving the command "make check" i am recieveing the following on my computer screen ... TestResultCollectorTest::testWasSuccessfulWithErrorsAndFailures : OK TestResultCollectorTest::testWasSuccessfulWithSuccessfulTest : OK TestResultCollectorTest::testSynchronizationAddFailure : OK TestResultCollectorTest::testSynchronizationStartTest : OK TestResultCollectorTest::testSynchronizationRunTests : OK TestResultCollectorTest::testSynchronizationTestErrors : OK TestResultCollectorTest::testSynchronizationTestFailures : OK TestResultCollectorTest::testSynchronizationFailures : OK TestResultCollectorTest::testSynchronizationWasSuccessful : OK TestResultTest::testConstructor : OK TestResultTest::testStop : OK TestResultTest::testAddError after printing the last statement here i.e " TestResultTest::testAddError" , it does not move ahead ... and i am not able to go to step 4 i.e "check install" I would be highly obliged if you can provide me the solution to tackle this problem ... Regards, Gaurav Bhateja .. |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-17 19:15:25
|
> Here is a small patch to allow the compilation of CppUnit in UNICODE. Sorry I forgot to attach the diffs :-7 Vincent Rivi=E8re vri...@us... |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-16 19:38:30
|
Happy to see some activity here again ! Here is a small patch to allow the compilation of CppUnit in UNICODE. The only file affected is Win32DynamicLibraryManager.cpp Could someone check this in, please ? Thank you. Vincent Rivi=E8re vri...@us... |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-16 07:23:12
|
Hi I have complied the CppUnit project and example project successfully, and got the *TestPlugInRunner(d).exe*, *CppUnitTestPlugIn(d).dll* and * simple_plugin(d).dll*. But when I use TestPlugInRunner.exe loading CppUnitTestPlugIn.dll first then load simple_plugin.dll, after that click the Browse button, in the Test hierarchy dialog's tree view, there is still the CppUnitTestPlugIn.dll 's sub-registry test suites, Core, Extensions, Helpers, Output, Tools and UnitTestTool, remained even containing nothing. I have browsed part of the source code, and found that in the CppUnitTestSuite.cpp, it uses macro *CPPUNIT_TEST_SUITE_NAMED_REGISTRATION** (ATestFixtureType, suiteName)** (cppunit-1.12.0\include\cppunit\extensions\ HelperMacros.h)* and *CPPUNIT_REGISTRY_ADD_TO_DEFAULT(which)** ( cppunit-1.12.0\include\cppunit\extensions\ HelperMacros.h),* which in turn using *CPPUNIT_NS::AutoRegisterRegistry** **( cppunit-1.12.0\include\cppunit\extensions\* *AutoRegisterSuite.h)*, to implement the test suites' hierarchy. But when the dll is unload, there seems no destroy of those sub-registries. So if other dll loaded, the remaining registries will also be displayed with no test. I wonder if there is some place in the source code do the registry cleaning job when a new dll is loaded. Thanks in advance. Amo |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-12 13:04:14
|
Hello, =20 I'm trying to build CPPUNIT (1.10.2 and 1.12.0) in Visual C++ 2005 Express Edition but it gives the following output. Can you help?=20 =20 Thanks in advance, Steve =20 ------ Build started: Project: cppunit, Configuration: Debug Win32 ------ Compiling... BriefTestProgressListener.cpp TestResultCollector.cpp TestSuccessListener.cpp TextTestProgressListener.cpp TextTestResult.cpp TextTestRunner.cpp CompilerOutputter.cpp TextOutputter.cpp XmlOutputter.cpp C:\Program Files\Microsoft Visual Studio 8\VC\include\map(170) : error C2039: '_Mytype' : is not a member of 'std::_Tree<_Traits>::iterator' with [ _Traits=3Dstd::_Tmap_traits<CppUnit::Test *,CppUnit::TestFailure *,std::less<CppUnit::Test *>,std::allocator<std::pair<CppUnit::Test *const ,CppUnit::TestFailure *>>,false> ] C:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(412) : see declaration of 'std::_Tree<_Traits>::iterator' with [ _Traits=3Dstd::_Tmap_traits<CppUnit::Test *,CppUnit::TestFailure *,std::less<CppUnit::Test *>,std::allocator<std::pair<CppUnit::Test *const ,CppUnit::TestFailure *>>,false> ] C:\Program Files\Microsoft Visual Studio 8\VC\include\map(167) : while compiling class template member function 'CppUnit::TestFailure *&std::map<_Kty,_Ty,_Pr>::operator [](CppUnit::Test *const &)' with [ _Kty=3DCppUnit::Test *, _Ty=3DCppUnit::TestFailure *, _Pr=3Dstd::less<CppUnit::Test *> ] .\XmlOutputter.cpp(77) : see reference to class template instantiation 'std::map<_Kty,_Ty,_Pr>' being compiled with [ _Kty=3DCppUnit::Test *, _Ty=3DCppUnit::TestFailure *, _Pr=3Dstd::less<CppUnit::Test *> ] XmlOutputterHook.cpp AdditionalMessage.cpp Asserter.cpp Exception.cpp Message.cpp SourceLine.cpp SynchronizedObject.cpp Test.cpp TestAssert.cpp TestCase.cpp TestComposite.cpp Generating Code... Compiling... TestFailure.cpp TestLeaf.cpp TestPath.cpp TestResult.cpp TestRunner.cpp TestSuite.cpp TestFactoryRegistry.cpp TestNamer.cpp TestSuiteBuilderContext.cpp TypeInfoHelper.cpp RepeatedTest.cpp TestCaseDecorator.cpp TestDecorator.cpp TestSetUp.cpp BeOsDynamicLibraryManager.cpp DynamicLibraryManager.cpp DynamicLibraryManagerException.cpp PlugInManager.cpp PlugInParameters.cpp ShlDynamicLibraryManager.cpp Generating Code... Compiling... TestPlugInDefaultImpl.cpp UnixDynamicLibraryManager.cpp Win32DynamicLibraryManager.cpp StringTools.cpp XmlDocument.cpp XmlElement.cpp DefaultProtector.cpp Protector.cpp ProtectorChain.cpp Generating Code... Build log was saved at "file://c:\Development\VS2005Express\cppunit\cppunit-1.12.0\src\cppunit\ Debug\BuildLog.htm" cppunit - 1 error(s), 0 warning(s) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Build: 0 succeeded, 1 failed, 0 up-to-date= , 0 skipped =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 This email (including attachments) is confidential and is solely intended= for the addressee. Unless you are the addressee, you may not read, use o= r store this email in any way, or permit others to. If you have received = it in error, please contact Visa Europe on +44 (0)20 7937 8111. |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-10 08:46:07
|
Steve M. Robbins wrote: > Hello, > > There are a couple of patches that I'd like to see in CppUnit. > > I've emailed to this list and to Baptiste privately a couple of times, > but I've seen no response from Baptiste. Anyone heard from him > lately? Is he still maintaining cppunit? Yes I'm still around. You just contacted me during a holiday vacation were I'm usually MIA (no internet access). > I'd like to see one or more people added as developers to CppUnit so > that maintenance can continue. I was a CppUnit developer a few years > ago, and am willing to be re-added. Baptiste? Consider this done. Just send me your sf login, I can't find it. Thanks for the offer, Baptiste. > > Thanks, > -Steve |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-09 02:55:41
|
I have put together a set of project files for DevStudio8 based on the converted DevStudio6 .dsp files. They utilize the new property sheets (.vsprop) files and clean up the projects considerably. If you are intestered in these, I'd be more than happy to share. AJ Sahukar Senior Technical Specialist Altair Engineering, Inc. asa...@al... |
From: CppUnit d. m. l. <cpp...@li...> - 2007-01-08 17:21:37
|
Hello, There are a couple of patches that I'd like to see in CppUnit. I've emailed to this list and to Baptiste privately a couple of times, but I've seen no response from Baptiste. Anyone heard from him lately? Is he still maintaining cppunit? I'd like to see one or more people added as developers to CppUnit so that maintenance can continue. I was a CppUnit developer a few years ago, and am willing to be re-added. Baptiste? Thanks, -Steve |
From: CppUnit d. m. l. <cpp...@li...> - 2006-12-09 08:34:48
|
Hi ! I tried to check out the sources of cppunit2 from cvs but it doesn't connect. I followed the instructions from the cppunit2 wiki ( http://cppunit.sourceforge.net/cppunit-wiki/CppUnit2 ) and I catch an error ( connect to cvs.sourceforge.net:2401 failed: A socket operation was attempted to an unreachable host. ). Because cppunit2 is a module of cppunit cvs repository I followed the instructions from cppunit wiki ( https://sourceforge.net/cvs/?group_id=11795 ) and I checked out the cppunit2 module. So, I guess, the instructions for cppunit2 cvs repository have to be changed on cppunit2 wiki from " cvs -d:pserver:ano...@cv...:/cvsroot/cppunit login cvs -z3 -d:pserver:ano...@cv...:/cvsroot/cppunit co cppunit2 " to " cvs -d:pserver:ano...@cp...:/cvsroot/cppunit login cvs -z3 -d:pserver:ano...@cp...:/cvsroot/cppunit co cppunit2 " -- View this message in context: http://www.nabble.com/cppunit2-cvs-server-name-tf2784891.html#a7770297 Sent from the cppunit-devel mailing list archive at Nabble.com. |
From: CppUnit d. m. l. <cpp...@li...> - 2006-12-07 12:12:20
|
Hi Folks, i guess I found a bug at URL: http://cppunit.sourceforge.net/doc/lastest/money_example.html in Section: Setting up your project (Unix) Makefile.am > ... > MoneyApp_LDFLAGS = $(CPPUNIT_LIBS) > MoneyApp_LDFLAGS = -ldl >.... should more likely : > MoneyApp_LDFLAGS = $(CPPUNIT_LIBS) -ldl I cost's me some hours of investigation, because totally new to autoconf and friends, after fixing the above the makefile append the library cppunit correctly. Using: ubuntu 5.10, kernel 2.6.12, aclocal 1-1.6, autoconf (GNU Autoconf) 2.59, automake (GNU automake) 1.4-p6 |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-30 20:41:16
|
Thanks for these points. I will get around to fixing up the issues raised soon. Paul _____ From: cpp...@li... [mailto:cpp...@li...] On Behalf Of CppUnit development mailing list Sent: 28 November 2006 14:16 To: cpp...@li... Subject: [Cppunit-devel] CppUnitVisualStudio2005Wizard - more settings, items Hi Further to my previous message, I also notice that the Wizard does not set the additional library path But I also see that this has already been covered by a previous post to cpp-devel., and is described as being in progress. How easy would it be to extend the wizard to include not just a "new project" entry but a "new item" entry, to allow further class/test-case pairs to be added to an already created CppUnit project? |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-28 14:16:29
|
Hi =20 Further to my previous message, I also notice that the Wizard does not set the additional library path But I also see that this has already been covered by a previous post to cpp-devel., and is described as being in progress. =20 How easy would it be to extend the wizard to include not just a "new project" entry but a "new item" entry, to allow further class/test-case pairs to be added to an already created CppUnit project? =20 |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-28 10:21:37
|
I tried using this. Having installed it according to the instructions,=20 =20 First, it took me ages to notice that the new project type was listed only in the main group of Visual C++ templates. I had been looking for it in all the sub-types. A minor point, I know. =20 Second, the project it created immediately failed to compile: "Cannot open include file: 'cppunit/plugin/TestPlugIn.h': No such file or directory" because the include path was not set as part of the project properties. Surely it is supposed to be set? =20 Regards Ian |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-22 03:25:44
|
Hello, I just went through the sources from CVS head and fixed three kinds of = warnings (from gcc -Wall): 1. class member initializers listed out of order 2. no virtual destructor in class with virtual functions 3. "statement has no effect", from CPPUNIT_ASSERT_THROW( 1234, ... ) There is a fourth error: 4. ISO C++ forbids casting between pointer-to-function and = pointer-to-object in cppunit/PlugInManager.cpp that apparently cannot be fixed=20 (http://www.trilithium.com/johan/2004/12/problem-with-dlsym/)=20 so I left it. Patch follows. -Steve Index: examples/cppunittest/MockFunctor.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/examples/cppunittest/MockFunctor.h,v retrieving revision 1.2 diff -u -b -B -r1.2 MockFunctor.h --- examples/cppunittest/MockFunctor.h 7 May 2003 21:13:38 -0000 1.2 +++ examples/cppunittest/MockFunctor.h 22 Nov 2006 03:11:17 -0000 @@ -11,12 +11,12 @@ { public: MockFunctor() - : m_shouldThrow( false ) + : m_shouldSucceed( true ) + , m_shouldThrow( false ) , m_shouldThrowFailureException( false ) , m_hasExpectation( false ) , m_actualCallCount( 0 ) , m_expectedCallCount( 0 ) - , m_shouldSucceed( true ) { } =20 Index: examples/cppunittest/MockProtector.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/examples/cppunittest/MockProtector.h,v retrieving revision 1.2 diff -u -b -B -r1.2 MockProtector.h --- examples/cppunittest/MockProtector.h 7 May 2003 21:13:38 -0000 1.2 +++ examples/cppunittest/MockProtector.h 22 Nov 2006 03:11:17 -0000 @@ -19,10 +19,10 @@ { public: MockProtector() - : m_expectException( false ) - , m_hasExpectation( false ) - , m_wasCalled( false ) + : m_wasCalled( false ) , m_wasTrapped( false ) + , m_expectException( false ) + , m_hasExpectation( false ) , m_shouldPropagateException( false ) { } Index: examples/cppunittest/TestAssertTest.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/examples/cppunittest/TestAssertTest.cpp,v retrieving revision 1.9 diff -u -b -B -r1.9 TestAssertTest.cpp --- examples/cppunittest/TestAssertTest.cpp 5 Nov 2004 22:47:21 -0000 = 1.9 +++ examples/cppunittest/TestAssertTest.cpp 22 Nov 2006 03:11:17 -0000 @@ -45,7 +45,8 @@ =20 try { - CPPUNIT_ASSERT_THROW( 1234, std::string ); + int x; + CPPUNIT_ASSERT_THROW( x =3D 1234, std::string ); } catch ( CPPUNIT_NS::Exception & ) { @@ -59,7 +60,8 @@ void=20 TestAssertTest::testAssertNoThrow() { - CPPUNIT_ASSERT_NO_THROW( 1234 ); + int x; + CPPUNIT_ASSERT_NO_THROW( x =3D 1234 ); =20 try { @@ -80,7 +82,8 @@ =20 try { - CPPUNIT_ASSERT_ASSERTION_FAIL( 1234 ); + int x; + CPPUNIT_ASSERT_ASSERTION_FAIL( x =3D 1234 ); } catch ( CPPUNIT_NS::Exception & ) { @@ -94,8 +97,9 @@ void=20 TestAssertTest::testAssertAssertionPass() { - CPPUNIT_ASSERT_ASSERTION_PASS( 1234 ); + int x; + CPPUNIT_ASSERT_ASSERTION_PASS( x =3D 1234 ); =20 try { =20 Index: examples/cppunittest/XmlOutputterTest.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/examples/cppunittest/XmlOutputterTest.cpp,v retrieving revision 1.13 diff -u -b -B -r1.13 XmlOutputterTest.cpp --- examples/cppunittest/XmlOutputterTest.cpp 13 Oct 2005 20:13:15 -0000 = 1.13 +++ examples/cppunittest/XmlOutputterTest.cpp 22 Nov 2006 03:11:17 -0000 @@ -230,11 +230,11 @@ int &statisticsCalls, int &successfulTestCalls, int &failedTestCalls ) - : m_successfulTestCalls( successfulTestCalls ) - , m_failedTestCalls( failedTestCalls ) - , m_beginCalls( beginCalls ) + : m_beginCalls( beginCalls ) , m_endCalls( endCalls ) , m_statisticsCalls( statisticsCalls ) + , m_successfulTestCalls( successfulTestCalls ) + , m_failedTestCalls( failedTestCalls ) { } =20 Index: examples/cppunittest/XmlUniformiser.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/examples/cppunittest/XmlUniformiser.cpp,v retrieving revision 1.7 diff -u -b -B -r1.7 XmlUniformiser.cpp --- examples/cppunittest/XmlUniformiser.cpp 15 Mar 2003 10:21:44 -0000 = 1.7 +++ examples/cppunittest/XmlUniformiser.cpp 22 Nov 2006 03:11:17 -0000 @@ -41,8 +41,8 @@ =20 =20 XmlUniformiser::XmlUniformiser( const std::string &xml ) : - m_xml( xml ), - m_index( 0 ) + m_index( 0 ), + m_xml( xml ) { } =20 Index: examples/hierarchy/main.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/examples/hierarchy/main.cpp,v retrieving revision 1.12 diff -u -b -B -r1.12 main.cpp --- examples/hierarchy/main.cpp 14 Jul 2002 19:48:31 -0000 1.12 +++ examples/hierarchy/main.cpp 22 Nov 2006 03:11:17 -0000 @@ -15,9 +15,9 @@ runner.addTest( BoardGameTest<BoardGame>::suite() ); runner.addTest( ChessTest<Chess>::suite() ); =20 - bool wasSucessful =3D runner.run(); + bool wasSuccessful =3D runner.run(); =20 // should be: // return wasSuccessful ? 0 : 1; - return 0; + return wasSuccessful ? 0 : 0; } Index: include/cppunit/XmlOutputterHook.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/include/cppunit/XmlOutputterHook.h,v retrieving revision 1.5 diff -u -b -B -r1.5 XmlOutputterHook.h --- include/cppunit/XmlOutputterHook.h 9 Jul 2005 07:42:47 -0000 1.5 +++ include/cppunit/XmlOutputterHook.h 22 Nov 2006 03:11:17 -0000 @@ -153,6 +153,8 @@ */ virtual void statisticsAdded( XmlDocument *document, XmlElement *statisticsElement ); + + virtual ~XmlOutputterHook() {} }; =20 =20 Index: include/cppunit/extensions/TestFixtureFactory.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/include/cppunit/extensions/TestFixtureFactory.h,= v retrieving revision 1.2 diff -u -b -B -r1.2 TestFixtureFactory.h --- include/cppunit/extensions/TestFixtureFactory.h 16 Sep 2002 18:36:52 = -0000 1.2 +++ include/cppunit/extensions/TestFixtureFactory.h 22 Nov 2006 03:11:17 = -0000 @@ -18,6 +18,8 @@ public: //! Creates a new TestFixture instance. virtual TestFixture *makeFixture() =3D0; + + virtual ~TestFixtureFactory() {} }; =20 =20 Index: include/cppunit/plugin/TestPlugIn.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/include/cppunit/plugin/TestPlugIn.h,v retrieving revision 1.14 diff -u -b -B -r1.14 TestPlugIn.h --- include/cppunit/plugin/TestPlugIn.h 9 Jul 2005 07:42:47 -0000 1.14 +++ include/cppunit/plugin/TestPlugIn.h 22 Nov 2006 03:11:17 -0000 @@ -92,6 +92,8 @@ * unregistered. */ virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry = ) =3D0; + + virtual ~CppUnitTestPlugIn() {} }; =20 =20 Index: src/DllPlugInTester/CommandLineParser.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/src/DllPlugInTester/CommandLineParser.cpp,v retrieving revision 1.6 diff -u -b -B -r1.6 CommandLineParser.cpp --- src/DllPlugInTester/CommandLineParser.cpp 18 Jun 2004 08:15:29 -0000 = 1.6 +++ src/DllPlugInTester/CommandLineParser.cpp 22 Nov 2006 03:11:18 -0000 @@ -3,14 +3,14 @@ =20 CommandLineParser::CommandLineParser( int argc,=20 const char *argv[] ) - : m_currentArgument( 0 ) - , m_useCompiler( false ) + : m_useCompiler( false ) , m_useXml( false ) , m_briefProgress( false ) , m_noProgress( false ) , m_useText( false ) , m_useCout( false ) , m_waitBeforeExit( false ) + , m_currentArgument( 0 ) { for ( int index =3D1; index < argc; ++index ) { Index: src/cppunit/DynamicLibraryManagerException.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/src/cppunit/DynamicLibraryManagerException.cpp,v= retrieving revision 1.3 diff -u -b -B -r1.3 DynamicLibraryManagerException.cpp --- src/cppunit/DynamicLibraryManagerException.cpp 12 Jul 2002 05:59:57 = -0000 1.3 +++ src/cppunit/DynamicLibraryManagerException.cpp 22 Nov 2006 03:11:18 = -0000 @@ -9,8 +9,8 @@ const std::string = &libraryName, const std::string = &errorDetail, Cause cause ) - : m_cause( cause ) - , std::runtime_error( "" ) + : std::runtime_error( "" ), + m_cause( cause ) { if ( cause =3D=3D loadingFailed ) m_message =3D "Failed to load dynamic library: " + libraryName + = "\n" +=20 Index: src/cppunit/TestCaseDecorator.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/src/cppunit/TestCaseDecorator.cpp,v retrieving revision 1.1 diff -u -b -B -r1.1 TestCaseDecorator.cpp --- src/cppunit/TestCaseDecorator.cpp 3 Aug 2002 15:47:52 -0000 1.1 +++ src/cppunit/TestCaseDecorator.cpp 22 Nov 2006 03:11:18 -0000 @@ -4,8 +4,8 @@ =20 =20 TestCaseDecorator::TestCaseDecorator( TestCase *test ) - : m_test( test ) - , TestCase( test->getName() ) + : TestCase( test->getName() ), + m_test( test ) {=20 } =20 Index: src/cppunit/TextTestRunner.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/src/cppunit/TextTestRunner.cpp,v retrieving revision 1.20 diff -u -b -B -r1.20 TextTestRunner.cpp --- src/cppunit/TextTestRunner.cpp 29 Jun 2006 18:38:10 -0000 1.20 +++ src/cppunit/TextTestRunner.cpp 22 Nov 2006 03:11:18 -0000 @@ -18,9 +18,9 @@ * \param outputter used to print text result. Owned by the runner. */ TextTestRunner::TextTestRunner( Outputter *outputter )=20 - : m_outputter( outputter ) - , m_result( new TestResultCollector() ) + : m_result( new TestResultCollector() ) , m_eventManager( new TestResult() ) + , m_outputter( outputter ) { if ( !m_outputter ) m_outputter =3D new TextOutputter( m_result, stdCOut() ); Index: src/cppunit/XmlDocument.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/src/cppunit/XmlDocument.cpp,v retrieving revision 1.5 diff -u -b -B -r1.5 XmlDocument.cpp --- src/cppunit/XmlDocument.cpp 13 Oct 2005 20:13:16 -0000 1.5 +++ src/cppunit/XmlDocument.cpp 22 Nov 2006 03:11:18 -0000 @@ -8,8 +8,8 @@ =20 XmlDocument::XmlDocument( const std::string &encoding, const std::string &styleSheet ) - : m_rootElement( new XmlElement( "DummyRoot" ) ) - , m_styleSheet( styleSheet ) + : m_styleSheet( styleSheet ) + , m_rootElement( new XmlElement( "DummyRoot" ) ) , m_standalone( true ) { setEncoding( encoding ); |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-20 10:31:58
|
CppUnit development mailing list wrote: >> C99 is non-standard in the context of C++, which is a superset of C90. >> So, all C++ compilers might not support this. > > True, they might not; do you know of a current compiler that has > neither isfinite() nor the older, BSD finite()? You're right, I don't. Then again, I'm sure I don't know all compilers currently in use. I prefer to erring to side of caution as it isn't standard. > Hmm. Now that I think of it, just flipping the expression from > testing "is not equal" to "is equal" fixes the problem with NaNs > anyway: all boolean expressions involving a NaN are false. > Maybe we don't need the isfinite() test after all ... or maybe > we do; I can't remember whether "Inf - Inf" evaluates to 0. Inf - Inf evaluates to NaN. But that assumes the right signs, I think. How about (0.0 * <x>)? That should evaluate to NaN only if <x> is Inf, -Inf or NaN. So something like ((0.0 * <x>) == 0.0), if not optimized away, should be equal to finite(<x>). http://steve.hollasch.net/cgindex/coding/ieeefloat.html -- Tuomo |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-16 16:55:02
|
Quoting CppUnit development mailing list =20 <cpp...@li...>: > 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. True, they might not; do you know of a current compiler that has =20 neither isfinite() nor the older, BSD finite()? I can revise the patch to include testing for isfinite() and finite() at configuration time. Then inside TestAssert.cpp, add code like this: #if !defined(HAS_ISFINITE) # if defined(HAS_FINITE) # define isfinite(x) finite(x) # else # define isfinite(x) 1 # endif #endif Recall that the rest of the patch is: Index: src/cppunit/TestAssert.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/src/cppunit/TestAssert.cpp,v retrieving revision 1.12 diff -u -b -B -r1.12 TestAssert.cpp --- src/cppunit/TestAssert.cpp 5 Nov 2004 22:47:20 -0000 1.12 +++ src/cppunit/TestAssert.cpp 11 Nov 2006 03:57:56 -0000 @@ -21,7 +21,13 @@ assertion_traits<double>::toString(delta) ); msg.addDetail( AdditionalMessage(message) ); - Asserter::failNotEqualIf( fabs( expected - actual ) > delta, + bool equal; + if ( isfinite(expected) && isfinite(actual) ) + equal =3D fabs( expected - actual ) <=3D delta; + else + equal =3D expected =3D=3D actual; + + Asserter::failNotEqualIf( !equal, assertion_traits<double>::toString(expected), assertion_traits<double>::toString(actual), sourceLine, This revision keeps systems with neither isfinite() nor finite() able to compile CppUnit, but they retain the old buggy behaviour with respect to NaN and Inf. Would that be more acceptable? Hmm. Now that I think of it, just flipping the expression from testing "is not equal" to "is equal" fixes the problem with NaNs anyway: all boolean expressions involving a NaN are false. Maybe we don't need the isfinite() test after all ... or maybe we do; I can't remember whether "Inf - Inf" evaluates to 0. -Steve |
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 |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-16 06:18:39
|
Howdy, I recently received a Debian bug report for CppUnit = (http://bugs.debian.org/396865) that CPPUNIT_ASSERT_DOUBLES_EQUAL() does = not work as expected if one value is NaN. This bug has previously been reported to CppUnit at least twice: = http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1179131&grou= p_id=3D11795&atid=3D111795 = http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D754638&group= _id=3D11795&atid=3D111795 In addition, there have been at least two patches for the problem: = http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1591244&grou= p_id=3D11795&atid=3D311795 = http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D756340&group= _id=3D11795&atid=3D311795 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. 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 This patch is against CVS. Index: examples/cppunittest/TestAssertTest.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /cvsroot/cppunit/cppunit/examples/cppunittest/TestAssertTest.cpp,v retrieving revision 1.9 diff -u -b -B -r1.9 TestAssertTest.cpp --- examples/cppunittest/TestAssertTest.cpp 5 Nov 2004 22:47:21 = -0000 1.9 +++ examples/cppunittest/TestAssertTest.cpp 11 Nov 2006 03:57:43 = -0000 @@ -167,6 +167,17 @@ =20 CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.1, = 1.2, 0.09 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.2, = 1.1, 0.09 ) ); + + double inf =3D std::numeric_limits<double>::infinity(); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, = 0.0, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, = inf, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, = inf, 1.0 ) ); + + double nan =3D std::numeric_limits<double>::quiet_NaN(); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, = 0.0, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, = nan, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, = inf, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, = nan, 1.0 ) ); } =20 =20 Now, here is my proposed fix. I'm applying this to Debian's CppUnit = package. Index: src/cppunit/TestAssert.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/cppunit/cppunit/src/cppunit/TestAssert.cpp,v retrieving revision 1.12 diff -u -b -B -r1.12 TestAssert.cpp --- src/cppunit/TestAssert.cpp 5 Nov 2004 22:47:20 -0000 1.12 +++ src/cppunit/TestAssert.cpp 11 Nov 2006 03:57:56 -0000 @@ -21,7 +21,13 @@ assertion_traits<double>::toString(delta) ); msg.addDetail( AdditionalMessage(message) ); =20 - Asserter::failNotEqualIf( fabs( expected - actual ) > delta, + bool equal; + if ( isfinite(expected) && isfinite(actual) ) + equal =3D fabs( expected - actual ) <=3D delta; + else + equal =3D expected =3D=3D actual; + + Asserter::failNotEqualIf( !equal, = assertion_traits<double>::toString(expected), assertion_traits<double>::toString(actual), sourceLine,=20 Cheers, -Steve |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-16 06:10:42
|
Hello, The macro CPPUNIT_ASSERT_EQUAL uses a templated traits class, CppUnit::assertion_traits<T> with member function equals() to test for =20 equality. For the generic case, equals() is defined using operator=3D=3D(), which is reasonable for most types. Except for floating point. Thus the macro CPPUNIT_ASSERT_DOUBLES_EQUAL() is provided. This macro does *NOT* use assertion_traits<double>. Rather, it uses special logic embodied in functio= n CppUnit::assertDoublesEquals(). Note that since there are no specializations of assertion_traits<> provided = by CppUnit, the user is free to define their own. For example, I frequently specialize assertion_traits<double>, defining equals() using a global =20 tolerance. In revision 1.26 of include/cppunit/TestAssert.h, the specialization assertion_traits<double> was introduced. I propose that this is a mistake that should be reverted. The main reason is that one can no longer define one's own specialization. Furthermore, contrary to the comment above it, assertion_traits<double> is *NOT* used by CPPUNIT_ASSERT_DOUBLES_EQUAL. Baptiste? -Steve |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-13 19:04:12
|
Thanks Alexandre I will update my copy and post a new version on the wiki in the next couple of days. Paul _____ From: cpp...@li... [mailto:cpp...@li...] On Behalf Of CppUnit development mailing list Sent: 13 November 2006 00:21 To: cpp...@li... Subject: [Cppunit-devel] small changes for CPPUnitProjectWizard Dear Paul Gibbons I made for me a couple of cosmetic changes in default.js. \Microsoft Visual Studio 8\VC\VCWizards\CPPUnitProjectWizard\CPPUnitProjectWizard\Scripts\1033 File: default.js I replaced "DllPlugInTesterd_dll.exe" by "DllPlugInTesterd.exe" "DllPlugInTester_dll.exe" by "DllPlugInTester.exe" Because, by me these _dll.exe files are not generated by build of cppunit. For config.Tools('VCCLCompilerTool'), I added one line: AdditionalIncludeDirectories="$(CPPUNITDIR)\\Include"; For config.Tools('VCLinkerTool') AdditionalLibraryDirectories="$(CPPUNITDIR)\\Lib"; Now it works fine Best regards Alexandre |
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-13 19:04:09
|
Thanks Alexandre I will update my copy and post a new version on the wiki in the next couple of days. Paul _____ From: cpp...@li... [mailto:cpp...@li...] On Behalf Of CppUnit development mailing list Sent: 13 November 2006 00:21 To: cpp...@li... Subject: [Cppunit-devel] small changes for CPPUnitProjectWizard Dear Paul Gibbons I made for me a couple of cosmetic changes in default.js. \Microsoft Visual Studio 8\VC\VCWizards\CPPUnitProjectWizard\CPPUnitProjectWizard\Scripts\1033 File: default.js I replaced "DllPlugInTesterd_dll.exe" by "DllPlugInTesterd.exe" "DllPlugInTester_dll.exe" by "DllPlugInTester.exe" Because, by me these _dll.exe files are not generated by build of cppunit. For config.Tools('VCCLCompilerTool'), I added one line: AdditionalIncludeDirectories="$(CPPUNITDIR)\\Include"; For config.Tools('VCLinkerTool') AdditionalLibraryDirectories="$(CPPUNITDIR)\\Lib"; Now it works fine Best regards Alexandre |