C++ Testing

Hey guys only a quick one. Does anyone have any ideas on how to go about testing a single class in the program I have written??

their are two classes altogether but i want to be able to test them indervidually

Thanks for your time
You right a program to test each one. You call each of the member methods and use a lot of cout or ofstream.
you call each of the member methods? does that mean you call each indervidual function within the class??

sorry if im sounding silly just trying to fully understand it before i commence
Well how complex of classes are we talking about? If it is just a simple class holding data and has some simple accessor methods, you can just do some cout's. If it is a complex class that has dynamic memory allocation or big algorithms going on, you could look in to boost::unit_test (if you have boost installed). The boost::unit_test library will do cool stuff like automatic memory leak detection(if your IDE supports it, such as visual studio).

The key is to test a variety of conditions. Ideally, you should test the two extremes (maximum scenario and minimum scenario), a common case, and some cases that are uncommon or could cause a crash. For example, if you were testing the resize() function of a custom container you made, try calling with it 0 (the min), something like 1073741823 (probably the max), a common case like 52, and a not so common case like -12 or 39.4.
Yes, just start by creating an object of the class and just cout it's functions: cout << objectname.function();, etc...
Excellent, I shall get cracking thanks alot for your help guys
Topic archived. No new replies allowed.