Is there a way to test compile-time errors, but without actually generating the error? For example, if I create a class which is non-copyable, I\'d like to test the fact tha
Unfortunately there is no easy way to test a compile error in the way you want to, I've also wanted to do this before.
Anyways if your tests are small enough you can write short uncompilable code, like your sample, and verify with a script if the errors generated are correct or not (again you just said it).
An example of this sort of thing would be Unix's configure scripts, in more than a few scripts I've seen them try to compile little samples to verify the version/abilities of the compiler, to configure the makefile correctly.
So at least you can know you're not alone. Now if you wrote a successful test framework for this sort of thing you'd probably become famous :)
Edit: You could possibly also use a #define that either tries or not compile uncompilable code something like this:
#ifdef _COMPILETEST
#define TRY_COMPILE(...) (__VA_ARG__)
#else
#define TRY_COMPILE(...)
#end
Note that this is something I just though about and there are probably many problems with this pattern, but it might serve as a seed for some better ideas.