开发者

Can I use BOOST_CHECK only in unit tests?

Or Can I use it in regular code?

If the answer is "no", then is there C++ library that will provide me with all the macros like CHECK_EQUAL, CHEC开发者_Go百科K_CLOSE, etc.?


It is only meaningful in unit tests, since its purpose is to alert the unit testing framework that a test failed, and then continue. If the unit testing framework isn't running, that won't work.

Outside unit tests, you'll usually want to use some flavor of assert instead.


If the answer is "no", then is there C++ library that will provide me with all the macros like CHECK_EQUAL, CHECK_CLOSE, etc.?

The short answer is no. The longer answer: These macros are part of Boost.Test. So, if you are not using Boost.Test you will have to roll your own.


It's fairly easy to write this functionality based on boost/assert or cassert.
Note, however, that assertions may require some definitions (such as DEBUG)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜