I’m looking for a good way to unit test my templated methods, classes, and functions in c++.
I have a feeling that it is not enough to just test using with a single type, and it doesn’t feel right to just duplicate the unit tests and replace the types.
To be more specific, I’m working on a Matrix class and using Boost’s unit testing framework. The Matrix is to work with different types. It will mainly be used for basic types, but I would like it to support concrete types too.
Note, I doing this for learning purposes, which is why I’m not using a existing matrix implementation.
Boost test has a macro BOOST_AUTO_TEST_CASE_TEMPLATE that runs a test on a template for each type in a boost::mpl::list.
http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/utf/user-guide/test-organization/auto-test-case-template.html