tags:

views:

265

answers:

3

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, CHECK_CLOSE, etc.?

+2  A: 

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.

jalf
Thanks, for the answer, I updated my question.
Łukasz Lew
What does it exactly mean that "unit testing framework is running". Does it mean that it is lined or that we are in BOOST_AUTO_TEST_CASE?What will happen if I call BOOST_CHECK_EQUAL outside of BOOST_AUTO_TEST_CASE? (with or without test framework linked?)
Łukasz Lew
+1  A: 

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.

dirkgently
I do use boost test. The first question is whether I cant use them outside unit test case.
Łukasz Lew
Import the definitions (i.e. copy-paste the specific portion of the headers that define these macros in a separate header and add it to your project, you wouldn't want the whole of Boost.Test to be shipped with your code.)
dirkgently
A: 

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)

Oren S