CppUnit is not suitable for creating automated tests for the user interface. This is more for processing-only units. For example, suppose you created a replacement for std::vector and want to make sure that it behaves like the original, you could write tests that add elements to both your standard and standard implementation, and then do some additional processing (deleting, changing elements, etc.), and after each step, check whether they have a consistent result.
For the user interface, I am not aware of the good open source tools and free tools, but one good commercial tool is Test Bearplet from Smart Bear , among others.
In the second example that you specified, you first need to define a validation for the Reflect () method. For example, you can calculate the result of some values ββmanually to check if the return value for each of them is expected. Or you can use the inverse function, which is known to work completely.
Assuming the first option, you can write a test as follows:
class CRC32Test : public CppUnit::TestCase { public: CRC32Test( std::string name ) : CppUnit::TestCase( name ) {} void runTest() { struct Sample {unsigned long ulReflect; char cChar; unsigned long result}; static Sample samples[] = {
source share