Jun 202015
 

I have been using a library called libunittest for unit testing an open source project. A couple months ago I did a feature request for it, namely for an assertion for relative approximation. It’s an incredibly easy library to use and comes with a lot of documentation. Here is one of the examples which shows the “easy” way where you don’t have to register the test class:

After installing, link against it and compile, then execute:

This example and others are covered in the tutorial provided on the website: http://libunittest.sourceforge.net/tutorial.html

I personally like a different style that libunittest supports which is a bit more writing of code but I believe it’s a nice way of organizing a test suite:

For learning about the other types of assertions you can do, you may want to peruse the testing code:

http://sourceforge.net/p/libunittest/code/ci/master/tree/test/test_assertions.cpp

Happy testing!