Feature #147

Tests as templates

Added by Peter Sommerlad over 4 years ago.

Status:NewStart date:17 Jan 2014
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


Idea from G+ (Rob Meijer)

I would be happy if there would be one unit testing framework that would allow me to:

1) Define a test as a template.
2) Define a types based for_each for each of the test
templates template parameters.

Something that would allow easy expression allong the lines of something like the following pseudo code:

template_tests<each_type<int,float,unsigned int>,each_type<std::string,std::wstring>,each_type<Foo,Bar>> tests;

This however doesn't seem like an important enough usecase to consider for the authors of any of the frameworks I've tried out so far, so each time I end up writing m4, perl or python scripts that generates the files needed to run the test for the distinct type sets.

Lacking support for this usecase, that IMHO for C++ should be the primary usecase, to me it feels like testing frameworks are just there to facilitate Java programmers that want to use C++ without learning C++.

C++ is no longer the language it was when Java was considered by many to be 'C++ the good parts'. Generic programming in C++ is an essential part of the modern C++ vocabulary, and in modern C++, all the most critical code lives in templates. For this reason, testing template code and testing it thoroughly should absolutely be the primary usecase for a C++ unit testing framework.

Without such support, unit testing frameworks for C++ remain nothing more than toys for Java programmers to lazy to learn the language. 


would require forcing C++11/14 and I haven't got it yet completely what the semantics of this should be.

Also available in: Atom PDF