Catsfoot is a C++ library providing:
In short, it is intended to provide testing utilities for C++ template libraries.
Catsfoot is developed at Bergen Language Design Laboratory.
Unlike BCCL, Catsfoot is capable of not failing when concept requirements are not met, and instead use the concept as a static predicate.
C++2011 already provides several predicates in
<type_traits> (c.f. section 20.7.2). Some other are provided by the library, mostly inspired by
has_member, but also using interestring properties of
decltype from C++2011. With this, we are capable for instance of testing the call-ability of functions or operators.
Since our concepts are testable like predicates, we can then use similar constructs to Boost's
enable_if to be able to overload function templates based on both static and dynamic properties of our types.
The rejected concept proposal provided syntax for axioms. It proved to be useful for automatic testing. Axioms were similar to functions, so making Catsfoot able to treat functions as axioms did the trick.
As in QuickCheck, axioms are functions which parameters represent universally quantified variables. Since C++2011 introduced variadic template parameters, it was possible to write test driver "parsing" those parameters and feed the axiom with data from a generator.
Like QuickCheck, Catsfoot provides generator combinators.
The most interesting example of data generator is based on a list of functions, methods and operators which a random generator will use to generate random instances. If the set of functions covers all methods, constructors and friend functions of a class, in theory, it is possible to cover all possible generate-able instances (if we had infinite time and memory).
It is possible to combine unit testing with axiom testing. However, you should note that several OOP testing techniques become deprecated with concept-based testing.
Fixtures are generally not needed since data set generator will generate them. Probably, it is a bad sign if you have fixtures. Your only fixture should be your data generator.
Mock implementations can be easily made through concept-based programming. Better, you can check the mock implementation itself with the concept it is supposed to implement. Concepts do not require virtual methods nor inheritance. For that case, instead of modifying the original implementation to mock. Which is good, because after all, the implementation you need to mock is probably not your code. You just need first to define its specification as a concept, and then modify your code to accept the implementation to choose as a template parameter.
Catsfoot is just a library. It leaves you the choice to use any testing framework. Most of the time, you probably want to write small programs making the test. In that case, function
main will just basically configure the data set generators and test the different concepts. If the environment of your test suite requires a different approach, it will certainly be possible for you use Catsfoot anyway.