Menu

Complex Cookbook example for VC6 & ver 1.8

Lynn Allan
2002-04-19
2002-04-21
  • Lynn Allan

    Lynn Allan - 2002-04-19

    Complex Cookbook example for VC6 & ver 1.8

    I've been 'wrestling' with learning cppunit ver 1.8.0 and getting it to work with visual c++ 6.0.  I thought it would be helpful to submit a version of the Complex 'cookbook' that uses cppunit 1.8.0 features such as HelpMacros.h and TestFactoryRegistry.  It also cleans up some of the compiler errors in the (outdated?) Cookbook that comes with the documentation.

    As with the earlier submitted EmpVc6Cookbook, this example doesn't particularly do anything,. It is 'pruned down' enough to determine if your setup is correct enough to compile/link. It can serve as a template for a real class. 

    Note that there is only one file which contains the Complex class definition and implementation, and also the ComplexTestCase definition and implementation. This was done as a simplification and is not recommended for real code.

    Also, there are some cout's sprinkled through the code to indicate with member or friend function was actually invoked.

    The included .dsw and .dsp already have the settings for resolving includes, libs, and dll's. (Otherwise, the code itself is 'probably' portable)  It is assumed to be 'installed' at:
    <cppunit_home>\exmaples\msvc6\ComplexVc6Cookbook.

    The vc6 project (including .dsw, .dsp, .cpp, and .exe) is available directly from:
    http://prdownloads.sourceforge.net/inverse/ComplexVc6Cookbook.zip
    or:
    http://home.att.net/~bibleinverse/Misc/ComplexVc6Cookbook.zip

    I'm hoping one of the more veteran participants of this project will let me know of any flaws.  In the meantime ...

    Enjoy!

     
    • Baptiste Lepilleur

      I haven't looked into it deeply yet, but:

          CPPUNIT_ASSERT( _john == _john ); //not resolved - ok only because pts same
          CPPUNIT_ASSERT( _john == _John ); //not resolved - fail - should work

      => you are testing pointer equality, not objects. It should be:

      CPPUNIT_ASSERT( *_john == *_John );
      or
      CPPUNIT_ASSERT( *_john == _John );
      since you have == for both a reference and a pointer (which is plain confusin if you ask me).

      A side remarks too:
          Employee* pEmp = _john;
          Employee& emp = *_john;
          CPPUNIT_ASSERT(pEmp->equal(*_john));    //9e
          CPPUNIT_ASSERT(pEmp->equal(_john));     //9d
          CPPUNIT_ASSERT(pEmp->equal(*_John));    //9e
      don't do stuff like that, it's plain imposible to follow what you are testing.
          CPPUNIT_ASSERT(_john->equal(*_john));    //9e
          CPPUNIT_ASSERT(_john->equal(_john));     //9d
          CPPUNIT_ASSERT(_john->equal(*_John));    //9e

      Is much more clearer (don't need as much context to understand it.

      Baptiste.

       
    • Lynn Allan

      Lynn Allan - 2002-04-20

      Hi Baptiste,

      Actually, it appears your comments are in response to another question rather than this one.  The ComplexVc6Cookbook doesn't have my 'rantings and ravings', and is simply an attempt to be helpful by updating the cookbook exmaple for 1.8.0.  I believe your response is related to my earlier "Cookbook'ish vc6 project with work-arounds".

      It is very frustrating and discouraging for a new user of cppunit to have compiler errors in the 'hello, world' example that is provided.  In the project summary of cppunit, the 'Development Status' is listed as '2 pre-alpha'.  My impression is that cppunit is much further along than that, but the flawed cookbook example contributes to a new user considering cppunit to be very immature and not ready to use.

       
    • Lynn Allan

      Lynn Allan - 2002-04-21

      Oops ... user error on my part

      Hi Baptiste,

      I stared at my code a while longer, and realized my error ... I'd lost track of which variables were pointers and which were references.  Sorry for the carelessness on my part ... and thanks for your patience.

      Regards,
      Lynn Allan

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.