Adventures with Google Test.

Google Test proved fairly easy to setup and start using through compiling some of the examples  that are either provided on its  GitHub or found by searching the web. The real challenge would be creating unit  tests for the C++ variant of the FPE. After some thought it was decided that if these where going to be provided then some restructuring of the program was needed.

The two initial areas that  unit tests would be written for are the command line option processing and task action functionality. Both of these where initially situated in the main file but where factored out into separate files removing any global shared data in the same pass.

In the case of the command line processing it involved creating function  procCmdLine which takes argv as input, processes the command line arguments using the boost parameter library and outputs a structure that represents the command line. Creating a set of unit tests for this function just involves setting up argv with suitable commands, testing for supported error conditions and the state of the output structure (ParamArgData). At present there are a total of 10 unit tests for this area.

As the task action functions  are passed into the task class constructor and called from it; a different approach was adopted. Here an extra parameter was added to the constructor  that contains a void pointer for function data passed onto the action function when it is called. The unit tests for three currently available functions work by setting up the file  name parameters/ function data and observing any error conditions like asserts/exceptions and also any observable behavior; i.e. if you have set up a file to be copied that it actually is.

The area is still a work in progress (there are currently 22 unit tests) and  more are expected to be added and will be outlined in a future post along with what is decided to be done with the core Task class of the FPE.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s