I made up an example vc6 project loosely based on the 'cookbook' example, and thought it might be useful to make a full vc6 project available. It also illustrates a possible cppunit flaw.
The expanded class, Employee, has two std::string member variables, _first and _last. For the purpose of this 'tutorial', equality is considered to be case insensitive. (e.g. "John Doe" == "john doe")
Therefore, a member or friend function must be reached for CPPUNIT_ASSERT_EQUAL to make sense. Also, any tests inside a CPPUNIT_ASSERT related to operator== or Employee.equal must reach a member or friend function to be valid.
This vc6 project (including .dsw, .dsp, .cpp, and .exe) has the settings for includes, multi-thread dll's, and .lib. It assumes that it is installed at:
<cppunit_home>\examples\msvc6\Emp_Vc6
Because of case insensitivity, the following should work:
CPPUNIT_ASSERT_EQUAL(_john, _john); // ok for wrong reason
CPPUNIT_ASSERT_EQUAL(_john, _John); // is ok, but fails
I was unable to define a member or friend function with a signature that the cppunit framework would invoke to determine if _john and _John are equal. I would appreciate assistance to define such a function.
In that actual 'cookbook' example, the member variables for Complex are Doubles. CppUnit seems to have special handling for doubles, but this doesn't seem to apply to an arbitary class with an arbitrary definition of equality.
Regards,
Lynn Allan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cookbook'ish vc6 project with work-arounds
I made up an example vc6 project loosely based on the 'cookbook' example, and thought it might be useful to make a full vc6 project available. It also illustrates a possible cppunit flaw.
The expanded class, Employee, has two std::string member variables, _first and _last. For the purpose of this 'tutorial', equality is considered to be case insensitive. (e.g. "John Doe" == "john doe")
Therefore, a member or friend function must be reached for CPPUNIT_ASSERT_EQUAL to make sense. Also, any tests inside a CPPUNIT_ASSERT related to operator== or Employee.equal must reach a member or friend function to be valid.
This vc6 project (including .dsw, .dsp, .cpp, and .exe) has the settings for includes, multi-thread dll's, and .lib. It assumes that it is installed at:
<cppunit_home>\examples\msvc6\Emp_Vc6
It is available directly at:
http://prdownloads.sourceforge.net/inverse/CppUnit_EmpVc6_5.zip
or:
http://home.att.net/~bibleinverse/Misc/CppUnit_EmpVc6_5.zip
This example directly illustrates either a flaw in cppunit, or ignorance/incompetence on my part. There are three employees defined:
Employee _john("john", "doe");
Employee -John("John", "Doe");
Employee _bill("bill", "smith");
Because of case insensitivity, the following should work:
CPPUNIT_ASSERT_EQUAL(_john, _john); // ok for wrong reason
CPPUNIT_ASSERT_EQUAL(_john, _John); // is ok, but fails
I was unable to define a member or friend function with a signature that the cppunit framework would invoke to determine if _john and _John are equal. I would appreciate assistance to define such a function.
In that actual 'cookbook' example, the member variables for Complex are Doubles. CppUnit seems to have special handling for doubles, but this doesn't seem to apply to an arbitary class with an arbitrary definition of equality.
Regards,
Lynn Allan
Oops ... user error on my part
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