c++ - Verify static_assert in a unit test -
i make sure static_assert works should in unit test. is, if have
class myclass {static_assert(my_type_trait<t>::value, "error"); }; then in unit test myclass<typewithtrait> myclass; should 'pass' , myclass<typewithouttrait> myclass; should 'fail'.
is possible this?
if want check fails compile, you'll have test external code. write simple file like:
#include "myclass.h" int main() { myclass<%t%> m; } and write unit test compiles file different values of %t%. verify compilation either succeeds expected, or fails static_assert in failure text expected.
Comments
Post a Comment